blob: cdb0c1d6325cc6da4eb6bc99c0f9ec91370aa23d [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 window.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) {
if (e.data != connection.type + ',' + connection.downlinkMax) {
testFailed("Worker type disagrees with main frame.");
}
internals.setNetworkConnectionInfoOverride(isTypeOnline(newConnectionType), newConnectionType, newDownlinkMax);
} else if (msg_count == 1) {
if (e.data != newConnectionType + ',' + newDownlinkMax)
testFailed("Worker switched to wrong connection type.");
internals.setNetworkConnectionInfoOverride(isTypeOnline(initialType), initialType, initialDownlinkMax);
} else if (msg_count == 2) {
if (e.data != initialType + ',' + initialDownlinkMax)
testFailed("Worker did not revert back to initial type.");
finishJSTest();
}
msg_count += 1;
});
worker.postMessage('kickoff');
</script>
</body>
</html>