mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1226052, part 3 - Create File objects in test_mozfiledataurl.html using a frame script. r=baku
This makes it so the test works in e10s as well.
This commit is contained in:
parent
0d853a407e
commit
9fdd626831
10
dom/base/test/create_file_objects.js
Normal file
10
dom/base/test/create_file_objects.js
Normal file
@ -0,0 +1,10 @@
|
||||
Components.utils.importGlobalProperties(['File']);
|
||||
|
||||
addMessageListener("create-file-objects", function(message) {
|
||||
let files = []
|
||||
for (fileName of message.fileNames) {
|
||||
files.push(new File(fileName));
|
||||
}
|
||||
|
||||
sendAsyncMessage("created-file-objects", files);
|
||||
});
|
@ -54,6 +54,7 @@ support-files =
|
||||
bug819051.sjs
|
||||
chrome/bug418986-1.js
|
||||
copypaste.js
|
||||
create_file_objects.js
|
||||
delayedServerEvents.sjs
|
||||
echo.sjs
|
||||
eventsource.resource
|
||||
@ -782,7 +783,7 @@ skip-if = (os != 'b2g' && os != 'android') # meta-viewport tag support is mob
|
||||
[test_meta_viewport7.html]
|
||||
skip-if = (os != 'b2g' && os != 'android') # meta-viewport tag support is mobile-only
|
||||
[test_mozfiledataurl.html]
|
||||
skip-if = buildapp == 'mulet' || buildapp == 'b2g' || toolkit == 'android' || e10s #TIMED_OUT
|
||||
skip-if = buildapp == 'mulet' || buildapp == 'b2g' || toolkit == 'android' #TIMED_OUT
|
||||
[test_mozMatchesSelector.html]
|
||||
[test_mutationobservers.html]
|
||||
skip-if = buildapp == 'b2g' # b2g(bug 901385, showmodaldialog) b2g-debug(bug 901385, showmodaldialog) b2g-desktop(bug 901385, showmodaldialog)
|
||||
|
@ -6,13 +6,12 @@
|
||||
<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="start()">
|
||||
<p id="display">
|
||||
<iframe id=inner></iframe>
|
||||
<iframe id=iframe></iframe>
|
||||
<img id=img onload="gen.send(event);">
|
||||
<audio id=audio onloadeddata="gen.send(event);">
|
||||
<input type=file id=fileList>
|
||||
</p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
@ -31,10 +30,36 @@ window.addEventListener("message", function(e) {
|
||||
const innerSameSiteURI = "file_mozfiledataurl_inner.html";
|
||||
const innerCrossSiteURI = "http://example.com/tests/dom/base/test/file_mozfiledataurl_inner.html"
|
||||
|
||||
gen = runTest();
|
||||
var fileNames = ["file_mozfiledataurl_img.jpg",
|
||||
"file_mozfiledataurl_audio.ogg",
|
||||
"file_mozfiledataurl_doc.html",
|
||||
"file_mozfiledataurl_text.txt"];
|
||||
|
||||
function start() {
|
||||
let xhr = new XMLHttpRequest;
|
||||
xhr.open("GET", "/dynamic/getMyDirectory.sjs", false);
|
||||
xhr.send();
|
||||
let basePath = xhr.responseText;
|
||||
|
||||
let fullFileNames = [];
|
||||
for (let name of fileNames) {
|
||||
fullFileNames.push(basePath + name);
|
||||
}
|
||||
|
||||
var script = SpecialPowers.loadChromeScript(SimpleTest.getTestFileURL("create_file_objects.js"));
|
||||
|
||||
script.addMessageListener("created-file-objects", function handler(files) {
|
||||
script.removeMessageListener("created-file-objects", handler);
|
||||
gen = runTest(files);
|
||||
gen.next();
|
||||
});
|
||||
|
||||
script.sendAsyncMessage("create-file-objects", {fileNames: fullFileNames});
|
||||
};
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function runTest() {
|
||||
function runTest([imgFile, audioFile, docFile, xhrFile]) {
|
||||
inner = document.getElementById('inner');
|
||||
img = document.getElementById('img');
|
||||
audio = document.getElementById('audio');
|
||||
@ -42,7 +67,6 @@ function runTest() {
|
||||
inner.onload = function() { gen.send("inner loaded"); };
|
||||
|
||||
// Attempt to load a image in this document
|
||||
var imgFile = getFile("file_mozfiledataurl_img.jpg");
|
||||
var fileurl = URL.createObjectURL(imgFile);
|
||||
img.src = fileurl;
|
||||
var e = (yield);
|
||||
@ -85,7 +109,6 @@ function runTest() {
|
||||
isnot(res.height, 90, "correct error height");
|
||||
|
||||
// Attempt to load an audio in this document
|
||||
var audioFile = getFile("file_mozfiledataurl_audio.ogg");
|
||||
fileurl = URL.createObjectURL(audioFile);
|
||||
audio.src = fileurl;
|
||||
var e = (yield);
|
||||
@ -134,7 +157,6 @@ function runTest() {
|
||||
"image in iframe height");
|
||||
|
||||
// Attempt to load a HTML document in an iframe in this document, using file url
|
||||
var docFile = getFile("file_mozfiledataurl_doc.html");
|
||||
fileurl = URL.createObjectURL(docFile);
|
||||
iframe.src = fileurl;
|
||||
yield undefined;
|
||||
@ -170,7 +192,6 @@ function runTest() {
|
||||
is(res.type, "error", "load failed successfully");
|
||||
|
||||
// Attempt to load file url using XHR
|
||||
var xhrFile = getFile("file_mozfiledataurl_text.txt");
|
||||
fileurl = URL.createObjectURL(xhrFile);
|
||||
xhr = new XMLHttpRequest;
|
||||
xhr.onload = function() { gen.send("XHR finished"); };
|
||||
@ -198,23 +219,6 @@ function runTest() {
|
||||
|
||||
yield undefined;
|
||||
}
|
||||
|
||||
|
||||
var basePath = "";
|
||||
function getFile(name) {
|
||||
if (!basePath) {
|
||||
let xhr = new XMLHttpRequest;
|
||||
xhr.open("GET", "/dynamic/getMyDirectory.sjs", false);
|
||||
xhr.send();
|
||||
basePath = xhr.responseText;
|
||||
}
|
||||
|
||||
var fileList = document.getElementById('fileList');
|
||||
SpecialPowers.wrap(fileList).value = basePath + name;
|
||||
|
||||
return fileList.files[0];
|
||||
}
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
|
Loading…
Reference in New Issue
Block a user