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
+34
−4
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.
Loading status checks…
Add test for websockets being used from a worker
- Loading branch information
commit 853d4c0e39fff396f19f4cfad31720ec6ad1d09f
| }, | ||
| "local_changes": { | ||
| "deleted": [], | ||
| "items": {}, | ||
| "items": { | ||
| "testharness": { | ||
| "websockets/Send-data-worker.htm": [ | ||
| { | ||
| "path": "websockets/Send-data-worker.htm", | ||
|
||
| "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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
I don't think this should be here.
r+ assuming you file a followup about checking the Origin header in workers.