Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1649)

Unified Diff: android_webview/javatests/src/org/chromium/android_webview/test/LoadUrlTest.java

Issue 536593004: Revert "Merge 281715 "[Android WebView] Terminate execution of stuck JS ..."" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2062
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: android_webview/javatests/src/org/chromium/android_webview/test/LoadUrlTest.java
diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/LoadUrlTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/LoadUrlTest.java
index 77fb3704fd3c45b8f658d5914b9980b7880f691a..4a6bab55c7560e251fd9b143673134be9e0e3761 100644
--- a/android_webview/javatests/src/org/chromium/android_webview/test/LoadUrlTest.java
+++ b/android_webview/javatests/src/org/chromium/android_webview/test/LoadUrlTest.java
@@ -4,12 +4,9 @@
package org.chromium.android_webview.test;
-import android.test.suitebuilder.annotation.LargeTest;
import android.test.suitebuilder.annotation.SmallTest;
import android.util.Pair;
-import junit.framework.Assert;
-
import org.apache.http.Header;
import org.apache.http.HttpRequest;
import org.chromium.android_webview.AwContents;
@@ -334,71 +331,4 @@ public class LoadUrlTest extends AwTestBase {
if (webServer != null) webServer.shutdown();
}
}
-
- private static class TestController {
- private final Object mLock = new Object();
- private boolean mIsReady = false;
- public void notifyPageIsReady() {
- synchronized (mLock) {
- mIsReady = true;
- mLock.notify();
- }
- }
- public void waitUntilIsReady() {
- synchronized (mLock) {
- while (!mIsReady) {
- try {
- mLock.wait(WAIT_TIMEOUT_MS);
- } catch (Exception e) {
- continue;
- }
- if (!mIsReady) {
- Assert.fail("Wait timed out");
- }
- }
- mIsReady = false;
- }
- }
- }
-
- // Verify that it is possible to interrupt JS scripts stuck in an infinite loop
- // by calling loadUrl on a WebView.
- @LargeTest
- @Feature({"AndroidWebView"})
- public void testLoadUrlInterruptsLoopedScripts() throws Throwable {
- final String infiniteLoopPage =
- "<html><head>" +
- " <script>" +
- " function infiniteLoop() {" +
- " test.notifyPageIsReady();" +
- " while(1);" +
- " }" +
- " </script>" +
- "</head><body onload='setTimeout(infiniteLoop, 0)'>" +
- "</body></html>";
- final String simplePage = "<html><body onload='test.notifyPageIsReady()'></body></html>";
- final String expectedTitle = "PASS";
- final String pageWithTitle = "<html><body onload='document.title=\"" + expectedTitle +
- "\"; test.notifyPageIsReady()'></body></html>";
-
- final AwTestContainerView testContainerView =
- createAwTestContainerViewOnMainSync(new TestAwContentsClient());
- final AwContents awContents = testContainerView.getAwContents();
- getAwSettingsOnUiThread(awContents).setJavaScriptEnabled(true);
- final TestController testController = new TestController();
- getInstrumentation().runOnMainSync(new Runnable() {
- @Override
- public void run() {
- awContents.addPossiblyUnsafeJavascriptInterface(testController, "test", null);
- }
- });
- loadDataAsync(awContents, infiniteLoopPage, "text/html", false);
- testController.waitUntilIsReady();
- loadDataAsync(awContents, simplePage, "text/html", false);
- testController.waitUntilIsReady();
- // Load another page that runs JS to make sure that the WebView is still functional.
- loadDataAsync(awContents, pageWithTitle, "text/html", false);
- testController.waitUntilIsReady();
- assertEquals(expectedTitle, getTitleOnUiThread(awContents));
- }
}
« no previous file with comments | « android_webview/java/src/org/chromium/android_webview/AwContents.java ('k') | android_webview/native/aw_contents.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698