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

Unified Diff: LayoutTests/netinfo/multiple-frames.html

Issue 291203002: Adds NetInfo v3 Web API to Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@netinfo1
Patch Set: Comment typo Created 6 years, 7 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: LayoutTests/netinfo/multiple-frames.html
diff --git a/LayoutTests/netinfo/multiple-frames.html b/LayoutTests/netinfo/multiple-frames.html
new file mode 100644
index 0000000000000000000000000000000000000000..3c9ecc97b6f71fd16dcd6aef2e8e7bd06b702628
--- /dev/null
+++ b/LayoutTests/netinfo/multiple-frames.html
@@ -0,0 +1,58 @@
+<!DOCTYPE html>
+<head>
+<script src="../resources/js-test.js"></script>
+<script src="resources/netinfo_common.js"></script>
+</head>
+<body>
+<script>
+
+description('Tests using NetInfo from multiple frames.');
+
+shouldBe('typeof window.internals.observeGC', '"function"',
+'this test requires window.internals');
+
+var childFrame = document.createElement('iframe');
+document.body.appendChild(childFrame);
+
+var childConnection = childFrame.contentWindow.navigator.connection;
+
+if (connection.type != childConnection.type)
+ testFailed("Connection type not the same between main frame and child.");
+
+var hasMainFrameEventFired = false;
+var hasChildFrameEventFired = false;
+
+function mainFrameListener() {
+ hasMainFrameEventFired = true;
+ if (connection.type != newConnectionType)
+ testFailed("Event fired event but type not yet changed.");
+ if (!hasChildFrameEventFired && childConnection.type != initialType)
+ testFailed("Child frame connection type changed before firing its event.");
+ maybeFinishTest();
+}
+
+function childFrameListener() {
+ hasChildFrameEventFired = true;
+ if (childConnection.type != newConnectionType)
+ testFailed("Child frame fired event but type not yet changed.");
+ if (!hasMainFrameEventFired && connection.type != initialType)
+ testFailed("Main frame connection type changed before firing its event.");
+ maybeFinishTest();
+}
+
+function maybeFinishTest() {
+ if (hasMainFrameEventFired && hasChildFrameEventFired) {
+ if (connection.type != newConnectionType && childConnection.type == newConnectionType)
+ testFailed("Connection types did not change in both frames.");
+ finishJSTest();
+ }
+}
+
+connection.addEventListener('typechange', mainFrameListener);
+childConnection.addEventListener('typechange', childFrameListener);
+
+internals.setNetworkConnectionInfo(newConnectionType);
+
+</script>
+</body>
+</html>
« no previous file with comments | « LayoutTests/netinfo/gc-used-listeners-expected.txt ('k') | LayoutTests/netinfo/multiple-frames-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698