mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
Add test for websockets being used from a worker
This commit is contained in:
parent
4f878b2244
commit
853d4c0e39
3 changed files with 51 additions and 1 deletions
|
@ -33717,7 +33717,16 @@
|
||||||
},
|
},
|
||||||
"local_changes": {
|
"local_changes": {
|
||||||
"deleted": [],
|
"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": {}
|
||||||
},
|
},
|
||||||
"reftest_nodes": {
|
"reftest_nodes": {
|
||||||
|
|
28
tests/wpt/web-platform-tests/websockets/Send-data-worker.htm
Normal file
28
tests/wpt/web-platform-tests/websockets/Send-data-worker.htm
Normal file
|
@ -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>
|
13
tests/wpt/web-platform-tests/websockets/Send-data-worker.js
Normal file
13
tests/wpt/web-platform-tests/websockets/Send-data-worker.js
Normal file
|
@ -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);
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue