Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make websockets work in a worker scope #9521

Merged
merged 4 commits into from Feb 5, 2016
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Add test for websockets being used from a worker

  • Loading branch information
Manishearth committed Feb 3, 2016
commit 853d4c0e39fff396f19f4cfad31720ec6ad1d09f
},
"local_changes": {
"deleted": [],
"items": {},
"items": {
"testharness": {
"websockets/Send-data-worker.htm": [
{
"path": "websockets/Send-data-worker.htm",

This comment has been minimized.

@Ms2ger

Ms2ger Feb 4, 2016

Contributor

I don't think this should be here.

r+ assuming you file a followup about checking the Origin header in workers.

"url": "/websockets/Send-data-worker.htm"
}
]
}
},
"reftest_nodes": {}
},
"reftest_nodes": {
@@ -0,0 +1,28 @@
<!DOCTYPE html>
<html>
<head>
<title>W3C WebSocket API - Send data - WebSocket from Worker</title>
<script type="text/javascript" src="/resources/testharness.js"></script>
<script type="text/javascript" src="/resources/testharnessreport.js"></script>
<script type="text/javascript" src="websocket.js?pipe=sub"></script>
</head>
<body>
<div id="log"></div>
<script type="text/javascript">

async_test(function(t) {
var worker = new Worker("Send-data-worker.js");

var data = "test data";

worker.onmessage = t.step_func_done(function(e) {
assert_equals(e.data, data);
});

worker.postMessage(data);

}, "W3C WebSocket API - Send data on a WebSocket in a Worker")

</script>
</body>
</html>
@@ -0,0 +1,13 @@
onmessage = function (evt) {
importScripts('websocket.js?pipe=sub')
var wsocket = CreateWebSocket(false, false, false);

wsocket.addEventListener('open', function (e) {
wsocket.send(evt.data)
}, true)

wsocket.addEventListener('message', function (e) {
postMessage(e.data);
}, true);
}

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.