Bug 1220304 - Part 4b - Make dom/base/test/test_websocket.html use SpecialPowers.createFiles(). r=baku

This commit is contained in:
Andrew McCreight 2015-11-13 09:23:00 +01:00
parent f231f8852a
commit 878792ace5
2 changed files with 10 additions and 25 deletions

View File

@ -795,7 +795,7 @@ skip-if = toolkit == 'android' || e10s #RANDOM
[test_w3element_traversal.xhtml]
[test_w3element_traversal_svg.html]
[test_websocket.html]
skip-if = buildapp == 'b2g' || toolkit == 'android' || e10s # TC: Bug 1144079 - Re-enable Mulet mochitests and reftests taskcluster-specific disables.
skip-if = buildapp == 'b2g' || toolkit == 'android' # TC: Bug 1144079 - Re-enable Mulet mochitests and reftests taskcluster-specific disables.
[test_websocket_basic.html]
skip-if = buildapp == 'b2g' || toolkit == 'android'
[test_websocket_hello.html]

View File

@ -9,7 +9,6 @@
<body onload="testWebSocket()">
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=472529">Mozilla Bug </a>
<p id="display">
<input id="fileList" type="file"></input>
</p>
<div id="content">
</div>
@ -1328,35 +1327,21 @@ function test44()
{
ok(ws.readyState == 3, "onclose bad readyState in test-44!");
shouldCloseCleanly(e);
SpecialPowers.createFiles([{name: "testBlobFile", data: "flob"}], function (files) {
blobFile = files[0];
doTest(45);
},
function (msg) {
testFailed("Failed to create file for test45: " + msg);
doTest(46);
});
}
}
function createDOMFile(fileName, fileData)
{
// create File in profile dir
var dirSvc = SpecialPowers.Cc["@mozilla.org/file/directory_service;1"]
.getService(SpecialPowers.Ci.nsIProperties);
var testFile = dirSvc.get("ProfD", SpecialPowers.Ci.nsIFile);
testFile.append(fileName);
var outStream = SpecialPowers.Cc["@mozilla.org/network/file-output-stream;1"]
.createInstance(SpecialPowers.Ci.nsIFileOutputStream);
outStream.init(testFile, 0x02 | 0x08 | 0x20, 0666, 0);
outStream.write(fileData, fileData.length);
outStream.close();
// Set filename into DOM <input> field, as if selected by user
var fileList = document.getElementById('fileList');
SpecialPowers.wrap(fileList).value = testFile.path;
// return JS File object, aka Blob
return fileList.files[0];
}
var blobFile;
function test45()
{
var blobFile = createDOMFile("testBlobFile", "flob");
var ws = CreateTestWS("ws://mochi.test:8888/tests/dom/base/test/file_websocket", "test-45");
ok(ws.readyState == 0, "bad readyState in test-45!");