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

Side by Side Diff: third_party/WebKit/LayoutTests/netinfo/web-worker.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
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <head> 2 <head>
3 <script src="../resources/js-test.js"></script> 3 <script src="../resources/js-test.js"></script>
4 <script src="resources/netinfo_common.js"></script> 4 <script src="resources/netinfo_common.js"></script>
5 </head> 5 </head>
6 <body> 6 <body>
7 <script> 7 <script>
8 8
9 description('Tests that web-workers have access to NetInfo.'); 9 description('Tests that web-workers have access to NetInfo.');
10 10
11 shouldBe('typeof window.internals.observeGC', '"function"', 11 shouldBe('typeof window.internals.observeGC', '"function"',
12 'this test requires window.internals'); 12 'this test requires window.internals');
13 13
14 var worker = new Worker("resources/web-worker.js"); 14 var worker = new Worker("resources/web-worker.js");
15 15
16 var msg_count = 0; 16 var msg_count = 0;
17 17
18 worker.addEventListener('message', function(e) { 18 worker.addEventListener('message', function(e) {
19 if (msg_count == 0) { 19 if (msg_count == 0) {
20 if (e.data != connection.type + ',' + connection.downlinkMax) { 20 if (e.data != connection.type + ',' + connection.downlinkMax + ',' + con nection.effectiveType + ',' + connection.rtt + ',' + connection.downlink) {
21 testFailed("Worker type disagrees with main frame."); 21 testFailed("Worker type disagrees with main frame.");
22 } 22 }
23 internals.setNetworkConnectionInfoOverride(isTypeOnline(newConnectionType ), newConnectionType, newDownlinkMax); 23 internals.setNetworkConnectionInfoOverride(isTypeOnline(newConnectionType ), newConnectionType, newDownlinkMax);
24 } else if (msg_count == 1) { 24 } else if (msg_count == 1) {
25 if (e.data != newConnectionType + ',' + newDownlinkMax) 25 if (e.data != newConnectionType + ',' + newDownlinkMax + ',' + connectio n.effectiveType + ',' + connection.rtt + ',' + connection.downlink) {
26 testFailed("Worker switched to wrong connection type."); 26 testFailed("Worker switched to wrong connection type.");
27 }
27 internals.setNetworkConnectionInfoOverride(isTypeOnline(initialType), in itialType, initialDownlinkMax); 28 internals.setNetworkConnectionInfoOverride(isTypeOnline(initialType), in itialType, initialDownlinkMax);
28 } else if (msg_count == 2) { 29 } else if (msg_count == 2) {
29 if (e.data != initialType + ',' + initialDownlinkMax) 30 if (e.data != initialType + ',' + initialDownlinkMax + ',' + connection .effectiveType + ',' + connection.rtt + ',' + connection.downlink) {
30 testFailed("Worker did not revert back to initial type."); 31 testFailed("Worker did not revert back to initial type.");
32 }
31 finishJSTest(); 33 finishJSTest();
32 } 34 }
33 msg_count += 1; 35 msg_count += 1;
34 }); 36 });
35 37
36 worker.postMessage('kickoff'); 38 worker.postMessage('kickoff');
37 </script> 39 </script>
38 </body> 40 </body>
39 </html> 41 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698