3 <script src=
"../resources/js-test.js"></script>
4 <script src=
"resources/netinfo_common.js"></script>
8 description('Tests the basic operation of NetInfo.');
10 shouldBe('typeof window.internals.observeGC', '"function"',
11 'this test requires window.internals');
13 shouldBeDefined("navigator.connection");
14 shouldBeDefined("navigator.connection.type");
15 shouldBeDefined("navigator.connection.downlinkMax");
17 var typeChangeListener = function(e
) {
18 shouldBe("typeof connection.type", '"string"');
19 shouldBe('connection.type', 'initialType');
20 shouldBe('connection.downlinkMax', 'initialDownlinkMax');
24 var changeListener = function(e
) {
25 shouldBe("typeof connection.type", '"string"');
26 shouldBe('connection.type', 'newConnectionType');
27 shouldBe('connection.downlinkMax', 'newDownlinkMax');
28 connection
.removeEventListener('change', changeListener
);
29 connection
.addEventListener('typechange', typeChangeListener
);
30 internals
.setNetworkConnectionInfo(initialType
, initialDownlinkMax
);
33 connection
.addEventListener('change', changeListener
);
34 internals
.setNetworkConnectionInfo(newConnectionType
, newDownlinkMax
);