blob: 98cf79782193a84a2397593dd82050655a2b9ffc [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 web-workers have access to NetInfo.');
shouldBe('typeof internals.observeGC', '"function"',
'this test requires window.internals');
var worker = new Worker("resources/web-worker.js");
var msg_count = 0;
worker.addEventListener('message', function(e) {
if (msg_count == 0) {
verifyOnChangeMessage(e.data, connection.type, connection.downlinkMax,
connection.effectiveType, connection.rtt, connection.downlink);
internals.setNetworkConnectionInfoOverride(isTypeOnline(initialType), initialType, newEffectiveType, newRtt, newDownlinkMax);
} else if (msg_count == 1) {
verifyOnChangeMessage(e.data, connection.type, connection.downlinkMax,
newEffectiveType, connection.rtt, connection.downlink);
internals.setNetworkConnectionInfoOverride(isTypeOnline(initialType), initialType, initialEffectiveType, initialRtt, initialDownlink);
} else if (msg_count == 2) {
verifyOnChangeMessage(e.data, connection.type, connection.downlinkMax,
initialEffectiveType, connection.rtt, connection.downlink);
finishJSTest();
}
msg_count += 1;
});
worker.postMessage('kickoff');
</script>
</body>
</html>