| OLD | NEW |
| 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 description('Tests the basic operation of NetInfo.'); | 8 description('Tests the basic operation of NetInfo.'); |
| 9 | 9 |
| 10 shouldBe('typeof window.internals.observeGC', '"function"', | 10 shouldBe('typeof window.internals.observeGC', '"function"', |
| 11 'this test requires window.internals'); | 11 'this test requires window.internals'); |
| 12 | 12 |
| 13 shouldBeDefined("navigator.connection"); | 13 shouldBeDefined("navigator.connection"); |
| 14 shouldBeDefined("navigator.connection.type"); | 14 shouldBeDefined("navigator.connection.type"); |
| 15 shouldBeDefined("navigator.connection.downlinkMax"); | 15 shouldBeDefined("navigator.connection.downlinkMax"); |
| 16 shouldBeDefined("navigator.connection.rtt"); |
| 17 shouldBeDefined("navigator.connection.downlink"); |
| 16 | 18 |
| 17 var typeChangeListener = function(e) { | 19 var typeChangeListener = function(e) { |
| 18 shouldBe("typeof connection.type", '"string"'); | 20 shouldBe("typeof connection.type", '"string"'); |
| 19 shouldBe('connection.type', 'initialType'); | 21 shouldBe('connection.type', 'initialType'); |
| 20 shouldBe('connection.downlinkMax', 'initialDownlinkMax'); | 22 shouldBe('connection.downlinkMax', 'initialDownlinkMax'); |
| 21 finishJSTest(); | 23 finishJSTest(); |
| 22 } | 24 } |
| 23 | 25 |
| 24 var changeListener = function(e) { | 26 var changeListener = function(e) { |
| 25 shouldBe("typeof connection.type", '"string"'); | 27 shouldBe("typeof connection.type", '"string"'); |
| 26 shouldBe('connection.type', 'newConnectionType'); | 28 shouldBe('connection.type', 'newConnectionType'); |
| 27 shouldBe('connection.downlinkMax', 'newDownlinkMax'); | 29 shouldBe('connection.downlinkMax', 'newDownlinkMax'); |
| 28 connection.removeEventListener('change', changeListener); | 30 connection.removeEventListener('change', changeListener); |
| 29 connection.addEventListener('typechange', typeChangeListener); | 31 connection.addEventListener('typechange', typeChangeListener); |
| 30 internals.setNetworkConnectionInfoOverride(isTypeOnline(initialType), in
itialType, initialDownlinkMax); | 32 internals.setNetworkConnectionInfoOverride(isTypeOnline(initialType), in
itialType, initialDownlinkMax); |
| 31 } | 33 } |
| 32 | 34 |
| 33 connection.addEventListener('change', changeListener); | 35 connection.addEventListener('change', changeListener); |
| 34 internals.setNetworkConnectionInfoOverride(isTypeOnline(newConnectionType), newC
onnectionType, newDownlinkMax); | 36 internals.setNetworkConnectionInfoOverride(isTypeOnline(newConnectionType), newC
onnectionType, newDownlinkMax); |
| 35 | 37 |
| 36 </script> | 38 </script> |
| 37 </body> | 39 </body> |
| 38 </html> | 40 </html> |
| OLD | NEW |