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

Unified Diff: third_party/WebKit/LayoutTests/netinfo/estimate-multiple-frames.html

Issue 2903493002: NetInfo network quality extension: Add callbacks and Layout tests (Closed)
Patch Set: haraken comments Created 3 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: third_party/WebKit/LayoutTests/netinfo/estimate-multiple-frames.html
diff --git a/third_party/WebKit/LayoutTests/netinfo/estimate-multiple-frames.html b/third_party/WebKit/LayoutTests/netinfo/estimate-multiple-frames.html
new file mode 100644
index 0000000000000000000000000000000000000000..88643d21fa4be0ada254c9c5531c5ea003531470
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/netinfo/estimate-multiple-frames.html
@@ -0,0 +1,68 @@
+<!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.effectiveType != childConnection.effectiveType)
+ testFailed("Effective type not the same between main frame and child.");
+if (connection.rtt != childConnection.rtt)
+ testFailed("RTT not the same between main frame and child.");
+if (connection.downlink != childConnection.downlink)
+ testFailed("Downlink not the same between main frame and child.");
+
+var hasMainFrameEventFired = false;
+var hasChildFrameEventFired = false;
+
+function mainFrameListener() {
+ hasMainFrameEventFired = true;
+ if (connection.effectiveType != newEffectiveType)
+ testFailed("Event fired but effectiveType not yet changed.");
+ if (connection.rtt != newRtt)
+ testFailed("Event fired but rtt not yet changed.");
+ if (connection.downlink != newDownlink)
+ testFailed("Event fired but downlink not yet changed.");
+ if (!hasChildFrameEventFired && childConnection.rtt != initialRtt)
+ testFailed("Child frame connection rtt changed before firing its event.");
+ maybeFinishTest();
+}
+
+function childFrameListener() {
+ hasChildFrameEventFired = true;
+ if (childConnection.effectiveType != newEffectiveType)
+ testFailed("Child frame fired event but effectiveType not yet changed.");
+ if (childConnection.rtt != newRtt)
+ testFailed("Child frame fired event but rtt not yet changed.");
+ if (childConnection.downlink != newDownlink)
+ testFailed("Child frame fired event but downlink not yet changed.");
+ if (!hasMainFrameEventFired && connection.rtt != initialRtt)
+ testFailed("Main frame rtt changed before firing its event.");
+ maybeFinishTest();
+}
+
+function maybeFinishTest() {
+ if (hasMainFrameEventFired && hasChildFrameEventFired) {
+ finishJSTest();
+ }
+}
+
+connection.addEventListener('change', mainFrameListener);
+childConnection.addEventListener('change', childFrameListener);
+
+internals.setNetworkQualityInfoOverride(newEffectiveType, newRtt, newDownlink);
+
+</script>
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698