diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /dom/base/test/websocket_hybi/test_send-blob.html | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/base/test/websocket_hybi/test_send-blob.html')
-rw-r--r-- | dom/base/test/websocket_hybi/test_send-blob.html | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/dom/base/test/websocket_hybi/test_send-blob.html b/dom/base/test/websocket_hybi/test_send-blob.html new file mode 100644 index 000000000..291883cd7 --- /dev/null +++ b/dom/base/test/websocket_hybi/test_send-blob.html @@ -0,0 +1,72 @@ +<!DOCTYPE html> +<html> +<head> + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> +</head> +<body> + +<p id="display"> +</p> +<div id="content" style="display: none"> +</div> +<pre id="test"> + +<script class="testbody" type="text/javascript"> + +function startsWith(target, prefix) +{ + return target.indexOf(prefix) === 0; +} + +function distinctBytes() +{ + var array = new Array(); + for (var i = 0; i < 256; ++i) + array[i] = i; + // Concatenates chars into a single binary string + return String.fromCharCode.apply(null, array); +} + +var filesToCreate = [ + {name: "hellofile", data: "Hello, world!"}, + {name: "emptyfile"}, + {name: "allchars", data: distinctBytes()}, +]; + +SpecialPowers.createFiles(filesToCreate, function (files) { + var ws = new WebSocket("ws://mochi.test:8888/tests/dom/base/test/websocket_hybi/file_check-binary-messages"); + var closeEvent; + + ws.onopen = function() + { + ws.send(files[0]); + ws.send(files[1]); + ws.send(files[2]); + }; + + ws.onmessage = function(event) + { + var message = event.data; + if (startsWith(message, "PASS")) + ok(true, message); + else + ok(false, message); + }; + + ws.onclose = function(event) + { + ok(event.wasClean, "should have closed cleanly"); + SimpleTest.finish(); + }; +}, +function (msg) { + ok(false, "Failed to create files: " + msg); + SimpleTest.finish(); +}); + +SimpleTest.waitForExplicitFinish(); + +</script> +</body> +</html> |