mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 733553 - Tests for multipart streams via mochitest-plain using httpd.js. r=joe
This commit is contained in:
parent
7f04cb4204
commit
014d9b0dd3
@ -86,6 +86,10 @@ _TEST_FILES = imgutils.js \
|
|||||||
bug671906-iframe.html \
|
bug671906-iframe.html \
|
||||||
bug671906.sjs \
|
bug671906.sjs \
|
||||||
test_bug671906.html \
|
test_bug671906.html \
|
||||||
|
test_bug733553.html \
|
||||||
|
bug733553-iframe.html \
|
||||||
|
bug733553.sjs \
|
||||||
|
animated-gif2.gif \
|
||||||
test_error_events.html \
|
test_error_events.html \
|
||||||
error-early.png \
|
error-early.png \
|
||||||
test_drawDiscardedImage.html \
|
test_drawDiscardedImage.html \
|
||||||
|
7
image/test/mochitest/bug733553-iframe.html
Normal file
7
image/test/mochitest/bug733553-iframe.html
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Bug 733553 iframe</title>
|
||||||
|
<body>
|
||||||
|
<img src="bug733553.sjs" id="image1" />
|
||||||
|
</body>
|
||||||
|
</html>
|
77
image/test/mochitest/bug733553.sjs
Normal file
77
image/test/mochitest/bug733553.sjs
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
/* Any copyright is dedicated to the Public Domain.
|
||||||
|
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||||
|
*/
|
||||||
|
|
||||||
|
var bodyPartIndex = 0;
|
||||||
|
var bodyParts = [
|
||||||
|
["red.png", "image/png"],
|
||||||
|
["red.png", "image/png"], // Tests actually begin here
|
||||||
|
["animated-gif2.gif", "image/gif"],
|
||||||
|
["red.png", "image/png"],
|
||||||
|
["lime100x100.svg", "image/svg+xml"],
|
||||||
|
["big.png", "image/png"],
|
||||||
|
["animated-gif2.gif", "image/gif"],
|
||||||
|
["red.png", "image/png"],
|
||||||
|
["lime100x100.svg", "image/svg+xml"]
|
||||||
|
];
|
||||||
|
var timer = Components.classes["@mozilla.org/timer;1"];
|
||||||
|
var partTimer = timer.createInstance(Components.interfaces.nsITimer);
|
||||||
|
|
||||||
|
function getFileAsInputStream(aFilename) {
|
||||||
|
var file = Components.classes["@mozilla.org/file/directory_service;1"]
|
||||||
|
.getService(Components.interfaces.nsIProperties)
|
||||||
|
.get("CurWorkD", Components.interfaces.nsIFile);
|
||||||
|
|
||||||
|
file.append("tests");
|
||||||
|
file.append("image");
|
||||||
|
file.append("test");
|
||||||
|
file.append("mochitest");
|
||||||
|
file.append(aFilename);
|
||||||
|
|
||||||
|
var fileStream = Components.classes['@mozilla.org/network/file-input-stream;1']
|
||||||
|
.createInstance(Components.interfaces.nsIFileInputStream);
|
||||||
|
fileStream.init(file, 1, 0, false);
|
||||||
|
return fileStream;
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleRequest(request, response)
|
||||||
|
{
|
||||||
|
response.setHeader("Content-Type",
|
||||||
|
"multipart/x-mixed-replace;boundary=BOUNDARYOMG", false);
|
||||||
|
response.setHeader("Cache-Control", "no-cache", false);
|
||||||
|
response.setStatusLine(request.httpVersion, 200, "OK");
|
||||||
|
// We're sending parts off in a delayed fashion, to let the tests occur.
|
||||||
|
response.processAsync();
|
||||||
|
response.write("--BOUNDARYOMG\r\n");
|
||||||
|
sendParts(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
function sendParts(response) {
|
||||||
|
if (bodyParts.length > bodyPartIndex) {
|
||||||
|
partTimer.initWithCallback(getSendNextPart(response), 1000,
|
||||||
|
Components.interfaces.nsITimer.TYPE_ONE_SHOT);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sendClose(response);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function sendClose(response) {
|
||||||
|
response.write("--BOUNDARYOMG--\r\n");
|
||||||
|
response.finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
function getSendNextPart(response) {
|
||||||
|
var part = bodyParts[bodyPartIndex++];
|
||||||
|
var nextPartHead = "Content-Type: " + part[1] + "\r\n\r\n";
|
||||||
|
var inputStream = getFileAsInputStream(part[0]);
|
||||||
|
return function () {
|
||||||
|
response.bodyOutputStream.write(nextPartHead, nextPartHead.length);
|
||||||
|
response.bodyOutputStream.writeFrom(inputStream, inputStream.available());
|
||||||
|
inputStream.close();
|
||||||
|
// Toss in the boundary, so the browser can know this part is complete
|
||||||
|
response.write("--BOUNDARYOMG\r\n");
|
||||||
|
sendParts(response);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
55
image/test/mochitest/test_bug733553.html
Normal file
55
image/test/mochitest/test_bug733553.html
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html>
|
||||||
|
<!--
|
||||||
|
https://bugzilla.mozilla.org/show_bug.cgi?id=733553
|
||||||
|
-->
|
||||||
|
<head>
|
||||||
|
<title>Test for Bug 733553</title>
|
||||||
|
<script type="application/javascript" src="/MochiKit/MochiKit.js"></script>
|
||||||
|
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||||
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=733553">Mozilla Bug 733553</a>
|
||||||
|
<p id="display"></p>
|
||||||
|
<pre id="test">
|
||||||
|
<script type="application/javascript">
|
||||||
|
|
||||||
|
SimpleTest.waitForExplicitFinish();
|
||||||
|
|
||||||
|
var testIndex = 0;
|
||||||
|
var testParts = [
|
||||||
|
[1, "red.png"],
|
||||||
|
[40, "animated-gif2.gif"],
|
||||||
|
[1, "red.png"],
|
||||||
|
[100, "lime100x100.svg"],
|
||||||
|
[3000, "big.png"],
|
||||||
|
[40, "animated-gif2.gif"],
|
||||||
|
[1, "red.png"]
|
||||||
|
];
|
||||||
|
|
||||||
|
function initializeOnload() {
|
||||||
|
var iframeelem = document.getElementById('test-iframe');
|
||||||
|
var firstimg = iframeelem.contentDocument.getElementById('image1');
|
||||||
|
firstimg.addEventListener("load", imageLoad, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
function imageLoad(aEvent) {
|
||||||
|
if (testParts.length > testIndex) {
|
||||||
|
var [width, fileName] = testParts[testIndex++];
|
||||||
|
is(aEvent.target.width, width,
|
||||||
|
"Test " + (testIndex - 1) + " " + fileName + " width not correct");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
aEvent.target.removeEventListener("load", arguments.callee, false);
|
||||||
|
SimpleTest.finish();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
</pre>
|
||||||
|
<div id="content"> <!-- style="display: none" -->
|
||||||
|
<iframe id="test-iframe" src="http://mochi.test:8888/tests/image/test/mochitest/bug733553-iframe.html" onload="initializeOnload()"></iframe>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Reference in New Issue
Block a user