blob: bcab5fcbe022d1f3d34bfb0f12175faf41db1d73 [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 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, initialEffectiveType, initialRtt, initialDownlinkMax);
};
connection.addEventListener('change', handler);
internals.setNetworkConnectionInfoOverride(isTypeOnline(newConnectionType), newConnectionType, initialEffectiveType, initialRtt, newDownlinkMax);
</script>
</body>
</html>