| 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.effectiveType"); |
| 16 shouldBeDefined("navigator.connection.rtt"); | 17 shouldBeDefined("navigator.connection.rtt"); |
| 17 shouldBeDefined("navigator.connection.downlink"); | 18 shouldBeDefined("navigator.connection.downlink"); |
| 18 | 19 |
| 19 var typeChangeListener = function(e) { | 20 var typeChangeListener = function(e) { |
| 20 shouldBe("typeof connection.type", '"string"'); | 21 shouldBe("typeof connection.type", '"string"'); |
| 21 shouldBe('connection.type', 'initialType'); | 22 shouldBe('connection.type', 'initialType'); |
| 22 shouldBe('connection.downlinkMax', 'initialDownlinkMax'); | 23 shouldBe('connection.downlinkMax', 'initialDownlinkMax'); |
| 23 finishJSTest(); | 24 finishJSTest(); |
| 24 } | 25 } |
| 25 | 26 |
| 26 var changeListener = function(e) { | 27 var changeListener = function(e) { |
| 27 shouldBe("typeof connection.type", '"string"'); | 28 shouldBe("typeof connection.type", '"string"'); |
| 28 shouldBe('connection.type', 'newConnectionType'); | 29 shouldBe('connection.type', 'newConnectionType'); |
| 29 shouldBe('connection.downlinkMax', 'newDownlinkMax'); | 30 shouldBe('connection.downlinkMax', 'newDownlinkMax'); |
| 30 connection.removeEventListener('change', changeListener); | 31 connection.removeEventListener('change', changeListener); |
| 31 connection.addEventListener('typechange', typeChangeListener); | 32 connection.addEventListener('typechange', typeChangeListener); |
| 32 internals.setNetworkConnectionInfoOverride(isTypeOnline(initialType), in
itialType, initialDownlinkMax); | 33 internals.setNetworkConnectionInfoOverride(isTypeOnline(initialType), in
itialType, initialDownlinkMax); |
| 33 } | 34 } |
| 34 | 35 |
| 35 connection.addEventListener('change', changeListener); | 36 connection.addEventListener('change', changeListener); |
| 36 internals.setNetworkConnectionInfoOverride(isTypeOnline(newConnectionType), newC
onnectionType, newDownlinkMax); | 37 internals.setNetworkConnectionInfoOverride(isTypeOnline(newConnectionType), newC
onnectionType, newDownlinkMax); |
| 37 | 38 |
| 38 </script> | 39 </script> |
| 39 </body> | 40 </body> |
| 40 </html> | 41 </html> |
| OLD | NEW |