Bug 1034143: Step 1: Fix tests for bug 945152 and bug 1008126. r=smaug

This bug will make jar:http:// no longer eligible for the memory-mapping
optimization tested in these test cases, so this patch changes them
to use local files, which is the case that that optimization is meant
for.  Specifically, it changes them to chrome tests and pre-resolves
the chrome: URL of the jar file so that nsJARChannel recognizes it as a
local file.

Note that the bug 945152 test jar file remains in the file list for
plain mochitests as well as being added to chrome.ini; there is a test
in another directory that uses it, and a later patch in this series will
add another.
This commit is contained in:
Jed Davis 2015-03-10 17:00:01 -07:00
parent d129effca3
commit 1fb2cb6088
6 changed files with 53 additions and 29 deletions

View File

@ -2,6 +2,9 @@
support-files =
file_url.jsm
file_empty.html
file_bug945152.jar
file_bug945152_worker.js
file_bug1008126_worker.js
[test_anonymousContent_xul_window.xul]
[test_bug715041.xul]
@ -18,3 +21,7 @@ support-files =
[test_messagemanager_principal.html]
[test_messagemanager_send_principal.html]
skip-if = buildapp == 'mulet'
[test_bug945152.html]
run-if = os == 'linux'
[test_bug1008126.html]
run-if = os == 'linux'

View File

@ -3,9 +3,9 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
var gJar1 = "jar:http://example.org/tests/dom/base/test/file_bug945152.jar!/data_1.txt";
var gJar2 = "jar:http://example.org/tests/dom/base/test/file_bug945152.jar!/data_2.txt";
var gJar3 = "jar:http://example.org/tests/dom/base/test/file_bug945152.jar!/data_big.txt";
var gEntry1 = "data_1.txt";
var gEntry2 = "data_2.txt";
var gEntry3 = "data_big.txt";
var gPaddingChar = ".";
var gPaddingSize = 10000;
var gPadding = "";
@ -37,6 +37,11 @@ function checkData(xhr, data, mapped, cb) {
}
self.onmessage = function onmessage(event) {
var jar = event.data;
function makeJarURL(entry) {
return "jar:" + jar + "!/" + entry;
}
var xhr = new XMLHttpRequest({mozAnon: true, mozSystem: true});
@ -71,7 +76,7 @@ self.onmessage = function onmessage(event) {
}
};
xhr.onload = runTests;
xhr.open("GET", gJar3, true);
xhr.open("GET", makeJarURL(gEntry3), true);
xhr.responseType = "moz-chunked-arraybuffer";
xhr.send();
}
@ -104,7 +109,7 @@ self.onmessage = function onmessage(event) {
loadendCount++;
checkData(xhr, gData2, false, function() {} );
};
xhr.open("GET", gJar2, false);
xhr.open("GET", makeJarURL(gEntry2), false);
xhr.responseType = "arraybuffer";
xhr.send();
checkEventCount(runTests);
@ -112,7 +117,7 @@ self.onmessage = function onmessage(event) {
function test_sync_xhr_data1() {
ok(true, "Test sync XHR with data1");
xhr.open("GET", gJar1, false);
xhr.open("GET", makeJarURL(gEntry1), false);
xhr.responseType = "arraybuffer";
xhr.send();
checkData(xhr, gData1, true, runTests);
@ -120,7 +125,7 @@ self.onmessage = function onmessage(event) {
function test_sync_xhr_data2() {
ok(true, "Test sync XHR with data2");
xhr.open("GET", gJar2, false);
xhr.open("GET", makeJarURL(gEntry2), false);
xhr.responseType = "arraybuffer";
xhr.send();
checkData(xhr, gData2, false, runTests);
@ -131,7 +136,7 @@ self.onmessage = function onmessage(event) {
xhr.onload = function() {
checkData(xhr, gData1, true, runTests);
};
xhr.open("GET", gJar1, true);
xhr.open("GET", makeJarURL(gEntry1), true);
xhr.responseType = "arraybuffer";
xhr.send();
}
@ -141,7 +146,7 @@ self.onmessage = function onmessage(event) {
xhr.onload = function() {
checkData(xhr, gData2, false, runTests);
};
xhr.open("GET", gJar2, true);
xhr.open("GET", makeJarURL(gEntry2), true);
xhr.responseType = "arraybuffer";
xhr.send();
}

View File

@ -26,10 +26,15 @@ function checkData(response, data_head, cb) {
}
self.onmessage = function onmessage(event) {
var jar = event.data;
function makeJarURL(entry) {
return "jar:" + jar + "!/" + entry;
}
function test_mapped_sync() {
var xhr = new XMLHttpRequest({mozAnon: true, mozSystem: true});
xhr.open('GET', 'jar:http://example.org/tests/dom/base/test/file_bug945152.jar!/data_1.txt', false);
xhr.open('GET', makeJarURL('data_1.txt'), false);
xhr.responseType = 'arraybuffer';
xhr.send();
if (xhr.status) {
@ -42,7 +47,7 @@ self.onmessage = function onmessage(event) {
function test_mapped_async() {
var xhr = new XMLHttpRequest({mozAnon: true, mozSystem: true});
xhr.open('GET', 'jar:http://example.org/tests/dom/base/test/file_bug945152.jar!/data_1.txt');
xhr.open('GET', makeJarURL('data_1.txt'));
xhr.responseType = 'arraybuffer';
xhr.onreadystatechange = function() {
if (xhr.readyState !== xhr.DONE) {
@ -62,7 +67,7 @@ self.onmessage = function onmessage(event) {
// handled by memory allocation instead of memory mapping.
function test_non_mapped() {
var xhr = new XMLHttpRequest({mozAnon: true, mozSystem: true});
xhr.open('GET', 'jar:http://example.org/tests/dom/base/test/file_bug945152.jar!/data_2.txt');
xhr.open('GET', makeJarURL('data_2.txt'));
xhr.responseType = 'arraybuffer';
xhr.onreadystatechange = function() {
if (xhr.readyState !== xhr.DONE) {

View File

@ -162,8 +162,6 @@ support-files =
file_bug902350_frame.html
file_bug907892.html
file_bug945152.jar
file_bug945152_worker.js
file_bug1008126_worker.js
file_general_document.html
file_html_in_xhr.html
file_html_in_xhr.sjs
@ -659,11 +657,7 @@ skip-if = buildapp == 'mulet' || buildapp == 'b2g' || toolkit == 'android' || e1
[test_bug907892.html]
[test_bug922681.html]
[test_bug927196.html]
[test_bug945152.html]
skip-if = os != 'linux'
[test_bug982153.html]
[test_bug1008126.html]
skip-if = os != 'linux'
[test_bug1057176.html]
[test_bug1070015.html]
[test_bug1075702.html]

View File

@ -10,8 +10,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1008126
<head>
<meta charset="utf-8">
<title>Test for Bug 1008126</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1008126">Mozilla Bug 1008126</a>
@ -20,10 +20,16 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1008126
</div>
<pre id="test">
<script type="application/javascript">
<script type="application/javascript;version=1.7">
function translateChrome(uriStr) {
const { Cc, Ci } = SpecialPowers;
let ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
let chromeReg = Cc["@mozilla.org/chrome/chrome-registry;1"].getService(Ci.nsIChromeRegistry);
let uri = ios.newURI(uriStr, null, ios.newURI(document.baseURI, null, null));
return chromeReg.convertChromeURL(uri).spec;
}
function runTest() {
var worker = new Worker("file_bug1008126_worker.js");
worker.onmessage = function(event) {
@ -36,11 +42,11 @@ function runTest() {
worker.onerror = function(event) {
is(event.target, worker);
ok(false, "Worker had an error: " + event.message);
ok(false, "Worker had an error: " + event.filename + ":" + event.lineno + ":" + event.colno + ": " + event.message);
SimpleTest.finish();
};
worker.postMessage(true);
worker.postMessage(translateChrome("file_bug945152.jar"));
}
SimpleTest.waitForExplicitFinish();

View File

@ -6,8 +6,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=945152
<head>
<meta charset="utf-8">
<title>Test for Bug 945152</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=945152">Mozilla Bug 945152</a>
@ -16,7 +16,14 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=945152
</div>
<pre id="test">
<script type="application/javascript">
<script type="application/javascript;version=1.7">
function translateChrome(uriStr) {
const { Cc, Ci } = SpecialPowers;
let ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
let chromeReg = Cc["@mozilla.org/chrome/chrome-registry;1"].getService(Ci.nsIChromeRegistry);
let uri = ios.newURI(uriStr, null, ios.newURI(document.baseURI, null, null));
return chromeReg.convertChromeURL(uri).spec;
}
function runTest() {
var worker = new Worker("file_bug945152_worker.js");
@ -31,11 +38,11 @@ function runTest() {
worker.onerror = function(event) {
is(event.target, worker);
ok(false, "Worker had an error: " + event.data);
ok(false, "Worker had an error: " + event.filename + ":" + event.lineno + ":" + event.colno + ": " + event.message);
SimpleTest.finish();
};
worker.postMessage(true);
worker.postMessage(translateChrome("file_bug945152.jar"));
}
SimpleTest.waitForExplicitFinish();