Last active
November 26, 2015 06:08
-
-
Save nolanlawson/f71571e8770ba7174566 to your computer and use it in GitHub Desktop.
Test location.origin in a web worker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<body> | |
<h1>Test location.origin in a web worker</h1> | |
<pre id="output"></pre> | |
<script> | |
(function () { | |
var output = document.getElementById('output'); | |
output.innerHTML += 'location.origin in main thread: ' + location.origin + '\n'; | |
var worker = new Worker('worker.js'); | |
worker.addEventListener('message', function (e) { | |
output.innerHTML += e.data; | |
}); | |
worker.postMessage({}); | |
})(); | |
</script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
self.addEventListener('message', function () { | |
self.postMessage("location.origin in worker: " + location.origin); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment