blob: f82a3b36b423fd06dd1cacaca3a8d43172557cf6 [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 window.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', 'newConnectionType');
shouldBe('connection.saveData', 'false');
shouldBe('connection.downlinkMax', 'newDownlinkMax');
shouldBe('connection.effectiveType', 'newEffectiveType');
shouldBe('connection.rtt', 'newRtt', false, newRttMaxNoise);
shouldBe('connection.downlink', 'newDownlink', false, newDownlinkMaxNoise);
finishJSTest();
}
var changeListener = function(e) {
shouldBe("typeof connection.type", '"string"');
shouldBe('connection.type', 'initialType');
shouldBe('connection.saveData', 'false');
shouldBe('connection.downlinkMax', 'initialDownlinkMax');
shouldBe('connection.effectiveType', 'newEffectiveType');
shouldBe('connection.rtt', 'newRtt', false, newRttMaxNoise);
shouldBe('connection.downlink', 'newDownlink', false, newDownlinkMaxNoise);
connection.removeEventListener('change', changeListener);
connection.addEventListener('typechange', typeChangeListener);
internals.setNetworkConnectionInfoOverride(isTypeOnline(newConnectionType), newConnectionType, newDownlinkMax);
}
connection.addEventListener('change', changeListener);
internals.setNetworkQualityInfoOverride(newEffectiveType, newRtt, newDownlink);
</script>
</body>
</html>