blob: b25d1120627de6aa2d8a2669dca1bdd9e8cbd58c [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.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.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.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>