Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 1 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /websockets/stream/tentative/read.any.html?default - WPT Dashboard Interop Dashboard
- /websockets/stream/tentative/read.any.html?wpt_flags=h2 - WPT Dashboard Interop Dashboard
- /websockets/stream/tentative/read.any.html?wss - WPT Dashboard Interop Dashboard
- /websockets/stream/tentative/read.any.serviceworker.html?default - WPT Dashboard Interop Dashboard
- /websockets/stream/tentative/read.any.serviceworker.html?wpt_flags=h2 - WPT Dashboard Interop Dashboard
- /websockets/stream/tentative/read.any.serviceworker.html?wss - WPT Dashboard Interop Dashboard
- /websockets/stream/tentative/read.any.sharedworker.html?default - WPT Dashboard Interop Dashboard
- /websockets/stream/tentative/read.any.sharedworker.html?wpt_flags=h2 - WPT Dashboard Interop Dashboard
- /websockets/stream/tentative/read.any.sharedworker.html?wss - WPT Dashboard Interop Dashboard
- /websockets/stream/tentative/read.any.worker.html?default - WPT Dashboard Interop Dashboard
- /websockets/stream/tentative/read.any.worker.html?wpt_flags=h2 - WPT Dashboard Interop Dashboard
- /websockets/stream/tentative/read.any.worker.html?wss - WPT Dashboard Interop Dashboard
// META: script=../../constants.sub.js
// META: script=resources/url-constants.js
// META: script=/common/gc.js
// META: global=window,worker
// META: variant=?default
// META: variant=?wss
// META: variant=?wpt_flags=h2
'use strict';
promise_test(async t => {
const wss = new WebSocketStream(ECHOURL);
const { readable, writable } = await wss.opened;
const writer = writable.getWriter();
const MESSAGE_SIZE = 16;
writer.write(new Uint8Array(MESSAGE_SIZE));
const reader = readable.getReader();
const { value, done } = await reader.read();
assert_false(done, 'done should be false');
assert_true(value instanceof Uint8Array,
'instanceof should give Uint8Array');
assert_equals(value.constructor, Uint8Array,
'value should be a Uint8Array');
assert_true(ArrayBuffer.isView(value),
'value should be a view');
assert_equals(value.length, MESSAGE_SIZE, 'length should match');
assert_equals(value.byteLength, MESSAGE_SIZE,
'binary_length should match');
}, 'read type for binary messages is Uint8Array');