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

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: Simplified layout tests 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 unified diff | Download patch
OLDNEW
(Empty)
1 <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 var childFrame = document.createElement('iframe');
12 document.body.appendChild(childFrame);
13
14 var childConnection = childFrame.contentWindow.navigator.connection;
15
16 if (connection.type != childConnection.type)
17 testFailed("Connection type not the same between main frame and child.");
18
19 var hasMainFrameEventFired = false;
20 var hasChildFrameEventFired = false;
21
22 function mainFrameListener() {
23 hasMainFrameEventFired = true;
24 if (connection.type != newConnectionType)
25 testFailed("Event fired event but type not yet changed.");
26 if (!hasChildFrameEventFired && childConnection.type != initialType)
27 testFailed("Child frame connection type changed before firing its event. ");
28 maybeFinishTest();
29 }
30
31 function childFrameListener() {
32 hasChildFrameEventFired = true;
33 if (childConnection.type != newConnectionType)
34 testFailed("Child frame fired event but type not yet changed.");
35 if (!hasMainFrameEventFired && connection.type != initialType)
36 testFailed("Main frame connection type changed before firing its event." );
37 maybeFinishTest();
38 }
39
40 function maybeFinishTest() {
41 if (hasMainFrameEventFired && hasChildFrameEventFired) {
42 if (connection.type != newConnectionType && childConnection.type == newC onnectionType)
43 testFailed("Connection types did not change in both frames.");
44 finishJSTest();
45 }
46 }
47
48 connection.addEventListener('typechange', mainFrameListener);
49 childConnection.addEventListener('typechange', childFrameListener);
50
51 internals.setNetworkConnectionInfo(newConnectionType);
52 </script>
53 </body>
54 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698