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

Side by Side 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, 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.type != childConnection.type)
20 testFailed("Connection type not the same between main frame and child.");
21
22 var hasMainFrameEventFired = false;
23 var hasChildFrameEventFired = false;
24
25 function mainFrameListener() {
26 hasMainFrameEventFired = true;
27 if (connection.type != newConnectionType)
28 testFailed("Event fired event but type not yet changed.");
29 if (!hasChildFrameEventFired && childConnection.type != initialType)
30 testFailed("Child frame connection type changed before firing its event. ");
31 maybeFinishTest();
32 }
33
34 function childFrameListener() {
35 hasChildFrameEventFired = true;
36 if (childConnection.type != newConnectionType)
37 testFailed("Child frame fired event but type not yet changed.");
38 if (!hasMainFrameEventFired && connection.type != initialType)
39 testFailed("Main frame connection type changed before firing its event." );
40 maybeFinishTest();
41 }
42
43 function maybeFinishTest() {
44 if (hasMainFrameEventFired && hasChildFrameEventFired) {
45 if (connection.type != newConnectionType && childConnection.type == newC onnectionType)
46 testFailed("Connection types did not change in both frames.");
47 finishJSTest();
48 }
49 }
50
51 connection.addEventListener('typechange', mainFrameListener);
52 childConnection.addEventListener('typechange', childFrameListener);
53
54 internals.setNetworkConnectionInfo(newConnectionType);
55
56 </script>
57 </body>
58 </html>
OLDNEW
« 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