mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-11-09 04:39:03 +02:00
This is split from the previous changeset since if we include dom/ the file size is too large for phabricator to handle. This is an autogenerated commit to handle scripts loading mochitest harness files, in the simple case where the script src is on the same line as the tag. This was generated with https://bug1544322.bmoattachments.org/attachment.cgi?id=9058170 using the `--part 2` argument. Differential Revision: https://phabricator.services.mozilla.com/D27457 --HG-- extra : moz-landing-system : lando
72 lines
1.5 KiB
HTML
72 lines
1.5 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<script 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/websocket/tests/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>
|