blob: db9e3056ffac76b3f7526038ed99cc05fdf3112c [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 that it's okay to unregister the event listener while handling the event.");
shouldBe('typeof window.internals.observeGC', '"function"',
'this test requires window.internals');
var otherHandler = function(e) {
shouldBe('connection.type', 'initialType');
shouldBe('connection.downlinkMax', 'initialDownlinkMax');
shouldBe('connection.effectiveType', 'initialEffectiveType');
shouldBe('connection.rtt', 'initialRtt', false, initialRttMaxNoise);
shouldBe('connection.downlink', 'initialDownlink', false, initialDownlinkMaxNoise);
finishJSTest();
};
var handler = function(e) {
shouldBe('connection.type', 'newConnectionType');
shouldBe('connection.downlinkMax', 'newDownlinkMax');
shouldBe('connection.effectiveType', 'initialEffectiveType');
shouldBe('connection.rtt', 'initialRtt', false, initialRttMaxNoise);
shouldBe('connection.downlink', 'initialDownlink', false, initialDownlinkMaxNoise);
connection.removeEventListener('change', handler);
connection.addEventListener('change', otherHandler);
internals.setNetworkConnectionInfoOverride(isTypeOnline(initialType), initialType, initialDownlinkMax);
};
connection.addEventListener('change', handler);
internals.setNetworkConnectionInfoOverride(isTypeOnline(newConnectionType), newConnectionType, newDownlinkMax);
</script>
</body>
</html>