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

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

Issue 22986033: [Android WebView] Add an API to toggle the JS navigator.online property (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Really improve the test Created 7 years, 4 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/AwContentsTest.java
diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsTest.java
index 455d30bd9aadbcc5a3102f2b6445e1f2353772e1..6d508ed90d979762b5a8f975c209ddea39c1968f 100644
--- a/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsTest.java
+++ b/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsTest.java
@@ -392,4 +392,29 @@ public class AwContentsTest extends AwTestBase {
if (webServer != null) webServer.shutdown();
}
}
+
+ @Feature({"AndroidWebView", "setNetworkAvailable"})
+ @SmallTest
+ public void testSetNetworkAvailable() throws Throwable {
+ AwTestContainerView testView = createAwTestContainerViewOnMainSync(mContentsClient);
+ AwContents awContents = testView.getAwContents();
+ String SCRIPT = "navigator.onLine";
+
+ enableJavaScriptOnUiThread(awContents);
+ loadUrlSync(awContents, mContentsClient.getOnPageFinishedHelper(), "about:blank");
+
+ // Default to "online".
+ assertEquals("true", executeJavaScriptAndWaitForResult(awContents, mContentsClient,
+ SCRIPT));
+
+ // Forcing "offline".
+ awContents.setNetworkAvailable(false);
+ assertEquals("false", executeJavaScriptAndWaitForResult(awContents, mContentsClient,
+ SCRIPT));
+
+ // Forcing "online".
+ awContents.setNetworkAvailable(true);
+ assertEquals("true", executeJavaScriptAndWaitForResult(awContents, mContentsClient,
+ SCRIPT));
+ }
}
« 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