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 that all connection types of NetInfo are supported.'); | 8 description('Tests that all connection types of NetInfo are supported.'); |
9 | 9 |
10 if (!window.internals) | 10 if (!window.internals) |
11 log("This test requires window.internals"); | 11 log("This test requires window.internals"); |
12 | 12 |
13 var types = [ | 13 var types = [ |
14 'cellular', | 14 ['cellular', 1.0], |
15 'bluetooth', | 15 ['bluetooth', 2.0], |
16 'ethernet', | 16 ['ethernet', 3.0], |
17 'wifi', | 17 ['wifi', 4.0], |
18 'other', | 18 ['wimax', 5.0], |
19 'none', | 19 ['other', 6.0], |
20 'unknown' | 20 ['none', 7.0], |
| 21 ['unknown', 8.0] |
21 ]; | 22 ]; |
22 | 23 |
| 24 // ontypechange is deprecated but this test is here to |
| 25 // verify that it still works until it is removed. |
| 26 connection.addEventListener('typechange', function(e) { |
| 27 shouldBe('connection.type', 'types[count][0]'); |
| 28 shouldBe('connection.downlinkMax', 'types[count][1]'); |
| 29 }); |
| 30 |
23 var count = 0; | 31 var count = 0; |
24 connection.addEventListener('typechange', function(e) { | 32 connection.addEventListener('change', function(e) { |
25 shouldBe('connection.type', 'types[count]'); | 33 shouldBe('connection.type', 'types[count][0]'); |
| 34 shouldBe('connection.downlinkMax', 'types[count][1]'); |
| 35 |
26 if (++count === types.length) | 36 if (++count === types.length) |
27 finishJSTest(); | 37 finishJSTest(); |
28 }); | 38 }); |
29 | 39 |
30 for(var i = 0; i < types.length; i++) | 40 for(var i = 0; i < types.length; i++) |
31 internals.setNetworkConnectionInfo(types[i]); | 41 internals.setNetworkConnectionInfo(types[i][0], types[i][1]); |
32 | 42 |
33 </script> | 43 </script> |
34 </body> | 44 </body> |
35 </html> | 45 </html> |
OLD | NEW |