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