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

Side by Side 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, 6 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 unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <head>
3 <script src="../resources/js-test.js"></script>
4 <script src="resources/netinfo_common.js"></script>
5 </head>
6 <body>
7 <script>
8
9 description('Tests using NetInfo from multiple frames.');
10
11 shouldBe('typeof window.internals.observeGC', '"function"',
12 'this test requires window.internals');
13
14 var childFrame = document.createElement('iframe');
15 document.body.appendChild(childFrame);
16
17 var childConnection = childFrame.contentWindow.navigator.connection;
18
19 if (connection.effectiveType != childConnection.effectiveType)
20 testFailed("Effective type not the same between main frame and child.");
21 if (connection.rtt != childConnection.rtt)
22 testFailed("RTT not the same between main frame and child.");
23 if (connection.downlink != childConnection.downlink)
24 testFailed("Downlink not the same between main frame and child.");
25
26 var hasMainFrameEventFired = false;
27 var hasChildFrameEventFired = false;
28
29 function mainFrameListener() {
30 hasMainFrameEventFired = true;
31 if (connection.effectiveType != newEffectiveType)
32 testFailed("Event fired but effectiveType not yet changed.");
33 if (connection.rtt != newRtt)
34 testFailed("Event fired but rtt not yet changed.");
35 if (connection.downlink != newDownlink)
36 testFailed("Event fired but downlink not yet changed.");
37 if (!hasChildFrameEventFired && childConnection.rtt != initialRtt)
38 testFailed("Child frame connection rtt changed before firing its event." );
39 maybeFinishTest();
40 }
41
42 function childFrameListener() {
43 hasChildFrameEventFired = true;
44 if (childConnection.effectiveType != newEffectiveType)
45 testFailed("Child frame fired event but effectiveType not yet changed.") ;
46 if (childConnection.rtt != newRtt)
47 testFailed("Child frame fired event but rtt not yet changed.");
48 if (childConnection.downlink != newDownlink)
49 testFailed("Child frame fired event but downlink not yet changed.");
50 if (!hasMainFrameEventFired && connection.rtt != initialRtt)
51 testFailed("Main frame rtt changed before firing its event.");
52 maybeFinishTest();
53 }
54
55 function maybeFinishTest() {
56 if (hasMainFrameEventFired && hasChildFrameEventFired) {
57 finishJSTest();
58 }
59 }
60
61 connection.addEventListener('change', mainFrameListener);
62 childConnection.addEventListener('change', childFrameListener);
63
64 internals.setNetworkQualityInfoOverride(newEffectiveType, newRtt, newDownlink);
65
66 </script>
67 </body>
68 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698