mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-16 23:05:42 +00:00
Bug 1220304 - Part 1 - Make test_XHRSendData.html use SpecialPowers.createFiles(). r=baku
This commit is contained in:
parent
1dc3cd94f1
commit
4dd642748a
@ -374,7 +374,6 @@ skip-if = toolkit != 'gonk'
|
||||
[test_XHRDocURI.html]
|
||||
[test_XHRResponseURL.html]
|
||||
[test_XHRSendData.html]
|
||||
skip-if = buildapp == 'b2g' || e10s # b2g(seems to stall) b2g-debug(seems to stall) b2g-desktop(seems to stall) e10s(Bug 1220304 - Creates a file)
|
||||
[test_XHR_anon.html]
|
||||
[test_XHR_header.html]
|
||||
[test_XHR_onuploadprogress.html]
|
||||
|
@ -5,27 +5,48 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=464848
|
||||
-->
|
||||
<head>
|
||||
<title>XMLHttpRequest send data and headers</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body onload="gen.next();">
|
||||
<body onload="createFiles();">
|
||||
<a target="_blank"
|
||||
href="https://bugzilla.mozilla.org/show_bug.cgi?id=464848">Mozilla Bug 464848</a>
|
||||
<p id="display">
|
||||
<input id="fileList" type="file"></input>
|
||||
</p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="application/javascript;version=1.8">
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
var testData = "blahblahblahblahblahblahblaaaaaaaah. blah.";
|
||||
var extensions = [".txt",".png",".jpg",".gif",".xml", "noext"];
|
||||
var fileTypes = ["text/plain", "image/png", "image/jpeg", "image/gif", "text/xml", null];
|
||||
var gen = runTests();
|
||||
var testDOMFiles;
|
||||
|
||||
function createFiles() {
|
||||
var filesToCreate = new Array();
|
||||
extensions.forEach(function (extension) {
|
||||
filesToCreate.push({name: "testfile" + extension, data: testData});
|
||||
});
|
||||
SpecialPowers.createFiles(filesToCreate,
|
||||
function (files) {
|
||||
testDOMFiles = files;
|
||||
gen.next();
|
||||
},
|
||||
function (msg) {
|
||||
testDOMFiles = new Array;
|
||||
ok(false, "File creation error: " + msg);
|
||||
gen.next();
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
function continueTest() { gen.next(); }
|
||||
|
||||
function runTests() {
|
||||
|
||||
xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", "file_XHRSendData_doc.xml", false);
|
||||
xhr.send();
|
||||
@ -38,12 +59,6 @@ testDoc2.appendChild(testDoc2.createElement("res"));
|
||||
testDoc2.documentElement.appendChild(testDoc2.createTextNode("text"));
|
||||
is(testDoc2.inputEncoding, "UTF-8", "wrong encoding");
|
||||
|
||||
var testData = "blahblahblahblahblahblahblaaaaaaaah. blah.";
|
||||
var extensions = [".txt",".png",".jpg",".gif",".xml", "noext"];
|
||||
var fileTypes = ["text/plain", "image/png", "image/jpeg", "image/gif", "text/xml", null];
|
||||
var testFiles = new Array;
|
||||
var testDOMFiles = new Array;
|
||||
|
||||
// arraybuffer test objects
|
||||
var shortArray = new ArrayBuffer(1);
|
||||
var shortInt8View = new Uint8Array(shortArray);
|
||||
@ -64,28 +79,6 @@ var longInt16View2 = new Uint16Array(longArray, 256, 64)
|
||||
var longInt8View1 = new Int8Array(longArraySlice)
|
||||
var longInt8View2 = new Int8Array(longArray, 256, 128)
|
||||
|
||||
extensions.forEach(
|
||||
function (extension) {
|
||||
var testFile = createFileWithDataExt(testData, extension);
|
||||
testFiles.push(testFile);
|
||||
|
||||
var fileList = document.getElementById('fileList');
|
||||
SpecialPowers.wrap(fileList).value = testFile.path;
|
||||
testDOMFiles.push(fileList.files[0]);
|
||||
}
|
||||
);
|
||||
|
||||
function createFileWithDataExt(fileData, extension) {
|
||||
var testFile = SpecialPowers.Services.dirsvc.get("ProfD", SpecialPowers.Ci.nsIFile);
|
||||
testFile.append("testfile" + extension);
|
||||
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();
|
||||
|
||||
return testFile;
|
||||
}
|
||||
|
||||
tests = [{ body: null,
|
||||
resBody: "",
|
||||
},
|
||||
@ -253,19 +246,7 @@ try {
|
||||
"Wrong page for redirect");
|
||||
}
|
||||
}
|
||||
}
|
||||
finally {
|
||||
cleanUpData();
|
||||
}
|
||||
|
||||
function cleanUpData() {
|
||||
testFiles.forEach(
|
||||
function (testFile) {
|
||||
try {
|
||||
testFile.remove(false);
|
||||
} catch (e) {}
|
||||
}
|
||||
);
|
||||
} catch (e) {
|
||||
}
|
||||
|
||||
function is_identical_arraybuffer(ab1, ab2) {
|
||||
|
Loading…
Reference in New Issue
Block a user