OLD | NEW |
(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 that web-workers have access to NetInfo.'); |
| 10 |
| 11 shouldBe('typeof window.internals.observeGC', '"function"', |
| 12 'this test requires window.internals'); |
| 13 |
| 14 var worker = new Worker("resources/web-worker.js"); |
| 15 |
| 16 var msg_count = 0; |
| 17 |
| 18 worker.addEventListener('message', function(e) { |
| 19 if (msg_count == 0) { |
| 20 if (e.data != connection.type) { |
| 21 testFailed("Worker type disagrees with main frame."); |
| 22 } |
| 23 internals.setNetworkConnectionInfo(newConnectionType); |
| 24 } else if (msg_count == 1) { |
| 25 if (e.data != newConnectionType) |
| 26 testFailed("Worker switched to wrong connection type."); |
| 27 internals.setNetworkConnectionInfo(initialType); |
| 28 } else if (msg_count == 2) { |
| 29 if (e.data != initialType) |
| 30 testFailed("Worker did not revert back to initial type."); |
| 31 finishJSTest(); |
| 32 } |
| 33 msg_count += 1; |
| 34 }); |
| 35 |
| 36 worker.postMessage('kickoff'); |
| 37 </script> |
| 38 </body> |
| 39 </html> |
OLD | NEW |