fune/testing/web-platform/tests/websockets/Send-binary-blob.any.js
Philip Jägenstedt 334f567d95 Bug 1498467 [wpt PR 13478] - Remove the "W3C WebSocket API" prefix from websockets/ tests, a=testonly
Automatic update from web-platform-testsRemove the "W3C WebSocket API" prefix from websockets/ tests (#13478)

This prefix doesn't add any useful information, and isn't used in all
tests in this directory. Noticed because of the screen real estate it
takes up in a view like this:
https://wpt.fyi/results/websockets/Send-binary-65K-arraybuffer.any.html

In the directory, this command was run, on macOS:
git grep -lF 'W3C WebSocket API - ' | xargs sed -i '' 's/W3C WebSocket API - //g'
--

wpt-commits: 1e747acc90ecdbd23ef3348a144b77696cced55b
wpt-pr: 13478
2018-11-14 13:37:51 +00:00

34 lines
1.1 KiB
JavaScript

// META: script=websocket.sub.js
var testOpen = async_test("Send binary data on a WebSocket - Blob - Connection should be opened");
var testMessage = async_test("Send binary data on a WebSocket - Blob - Message should be received");
var testClose = async_test("Send binary data on a WebSocket - Blob - Connection should be closed");
var data = "";
var datasize = 65000;
var isOpenCalled = false;
var wsocket = CreateWebSocket(false, false, false);
wsocket.addEventListener('open', testOpen.step_func(function(evt) {
wsocket.binaryType = "blob";
for (var i = 0; i < datasize; i++)
data += String.fromCharCode(0);
data = new Blob([data]);
isOpenCalled = true;
wsocket.send(data);
testOpen.done();
}), true);
wsocket.addEventListener('message', testMessage.step_func(function(evt) {
assert_true(evt.data instanceof Blob);
assert_equals(evt.data.size, datasize);
wsocket.close();
testMessage.done();
}), true);
wsocket.addEventListener('close', testClose.step_func(function(evt) {
assert_true(isOpenCalled, "WebSocket connection should be open");
assert_true(evt.wasClean, "wasClean should be true");
testClose.done();
}), true);