blob: 5475ce92b9355c1383e8f00ad538523868563371 [file] [log] [blame]
<!DOCTYPE html>
<head>
<script src="../resources/js-test.js"></script>
<script src="resources/netinfo_common.js"></script>
</head>
<body>
<script>
description('Tests the basic operation of NetInfo.');
shouldBe('typeof internals.observeGC', '"function"',
'this test requires window.internals');
shouldBeDefined("navigator.connection");
shouldBeDefined("navigator.connection.type");
shouldBeDefined("navigator.connection.saveData");
shouldBeDefined("navigator.connection.downlinkMax");
shouldBeDefined("navigator.connection.effectiveType");
shouldBeDefined("navigator.connection.rtt");
shouldBeDefined("navigator.connection.downlink");
var typeChangeListener = function(e) {
shouldBe("typeof connection.type", '"string"');
shouldBe('connection.type', 'initialType');
shouldBe('connection.saveData', 'false');
shouldBe('connection.downlinkMax', 'initialDownlinkMax');
shouldBe('connection.effectiveType', 'initialEffectiveType');
shouldBe('connection.rtt', 'initialRtt', false, initialRttMaxNoise);
shouldBe('connection.downlink', 'initialDownlink', false, initialDownlinkMaxNoise);
finishJSTest();
}
var changeListener = function(e) {
shouldBe("typeof connection.type", '"string"');
shouldBe('connection.type', 'newConnectionType');
shouldBe('connection.saveData', 'false');
shouldBe('connection.downlinkMax', 'newDownlinkMax');
shouldBe('connection.effectiveType', 'initialEffectiveType');
shouldBe('connection.rtt', 'initialRtt', false, initialRttMaxNoise);
shouldBe('connection.downlink', 'initialDownlink', false, initialDownlinkMaxNoise);
connection.removeEventListener('change', changeListener);
connection.addEventListener('typechange', typeChangeListener);
internals.setNetworkConnectionInfoOverride(isTypeOnline(initialType), initialType, initialEffectiveType, initialRtt, initialDownlinkMax);
}
connection.addEventListener('change', changeListener);
internals.setNetworkConnectionInfoOverride(isTypeOnline(newConnectionType), newConnectionType, initialEffectiveType, initialRtt, newDownlinkMax);
</script>
</body>
</html>