Bug 1034143: Step 1: Fix tests for bug 945152 and bug 1008126. r=smaug
authorJed Davis <jld@mozilla.com>
Tue, 10 Mar 2015 17:00:01 -0700
changeset 232897 ddf4960cda9a877bc38ff05edb8a1969f26729c5
parent 232896 9e3bb49db815e8e5211c1c9f970a0ba9a8c9dfb5
child 232898 879c78ef29ec7b0b7c06ea3e76e8f5faecbaf21b
push id56676
push userjedavis@mozilla.com
push dateWed, 11 Mar 2015 00:00:13 +0000
treeherdermozilla-inbound@3c316731c170 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1034143, 945152, 1008126
milestone39.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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.
dom/base/test/chrome.ini
dom/base/test/file_bug1008126_worker.js
dom/base/test/file_bug945152_worker.js
dom/base/test/mochitest.ini
dom/base/test/test_bug1008126.html
dom/base/test/test_bug945152.html
--- a/dom/base/test/chrome.ini
+++ b/dom/base/test/chrome.ini
@@ -1,20 +1,27 @@
 [DEFAULT]
 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]
 [test_bug715041_removal.xul]
 [test_domrequesthelper.xul]
 [test_url.xul]
 [test_console.xul]
 [test_messageChannel.xul]
 [test_navigator_resolve_identity_xrays.xul]
 [test_sendQueryContentAndSelectionSetEvent.html]
 [test_bug1016960.html]
 [test_bug357450.js]
 [test_copypaste.xul]
 [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'
--- a/dom/base/test/file_bug1008126_worker.js
+++ b/dom/base/test/file_bug1008126_worker.js
@@ -1,16 +1,16 @@
 /**
  * Any copyright is dedicated to the Public Domain.
  * 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 = "";
 for (var i = 0; i < gPaddingSize; i++) {
   gPadding += gPaddingChar;
 }
 var gData1 = "TEST_DATA_1:ABCDEFGHIJKLMNOPQRSTUVWXYZ" + gPadding;
 var gData2 = "TEST_DATA_2:1234567890" + gPadding;
@@ -32,16 +32,21 @@ function checkData(xhr, data, mapped, cb
   }
   ok(xhr.response, "Data is non-null");
   var str = String.fromCharCode.apply(null, new Uint8Array(xhr.response));
   ok(str == data, "Data is correct");
   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});
 
   function reset_event_hander() {
     xhr.onerror = function(e) {
       ok(false, "Error: " + e.error + "\n");
     };
     xhr.onprogress = null;
@@ -66,17 +71,17 @@ self.onmessage = function onmessage(even
           }
           lastIndex++;
         }
         ok(allMatched, "Data chunk is correct.  Loaded " +
                         event.loaded + "/" + event.total + " bytes.");
       }
     };
     xhr.onload = runTests;
-    xhr.open("GET", gJar3, true);
+    xhr.open("GET", makeJarURL(gEntry3), true);
     xhr.responseType = "moz-chunked-arraybuffer";
     xhr.send();
   }
 
   var readystatechangeCount = 0;
   var loadCount = 0;
   var loadendCount = 0;
 
@@ -99,54 +104,54 @@ self.onmessage = function onmessage(even
     xhr.onload = function() {
       loadCount++;
       checkData(xhr, gData2, false, function() {} );
     };
     xhr.onloadend = function() {
       loadendCount++;
       checkData(xhr, gData2, false, function() {} );
     };
-    xhr.open("GET", gJar2, false);
+    xhr.open("GET", makeJarURL(gEntry2), false);
     xhr.responseType = "arraybuffer";
     xhr.send();
     checkEventCount(runTests);
   }
 
   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);
   }
 
   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);
   }
 
   function test_async_xhr_data1() {
     ok(true, "Test async XHR with data1");
     xhr.onload = function() {
       checkData(xhr, gData1, true, runTests);
     };
-    xhr.open("GET", gJar1, true);
+    xhr.open("GET", makeJarURL(gEntry1), true);
     xhr.responseType = "arraybuffer";
     xhr.send();
   }
 
   function test_async_xhr_data2() {
     ok(true, "Test async XHR with data2");
     xhr.onload = function() {
       checkData(xhr, gData2, false, runTests);
     };
-    xhr.open("GET", gJar2, true);
+    xhr.open("GET", makeJarURL(gEntry2), true);
     xhr.responseType = "arraybuffer";
     xhr.send();
   }
 
   var tests = [
     test_chunked_arraybuffer,
     test_multiple_events,
     test_sync_xhr_data1,
--- a/dom/base/test/file_bug945152_worker.js
+++ b/dom/base/test/file_bug945152_worker.js
@@ -21,33 +21,38 @@ function checkData(response, data_head, 
   var str = String.fromCharCode.apply(null, new Uint8Array(response));
   ok(str.length == data_head.length + gPaddingSize, "Data size is correct");
   ok(str.slice(0, data_head.length) == data_head, "Data head is correct");
   ok(str.slice(data_head.length) == gPadding, "Data padding is correct");
   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) {
       ok(xhr.status == 200, "Status is 200");
       var ct = xhr.getResponseHeader("Content-Type");
       ok(ct.indexOf("mem-mapped") != -1, "Data is memory-mapped");
       checkData(xhr.response, gData1, runTests);
     }
   }
 
   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) {
         return;
       }
       if (xhr.status) {
         ok(xhr.status == 200, "Status is 200");
         var ct = xhr.getResponseHeader("Content-Type");
@@ -57,17 +62,17 @@ self.onmessage = function onmessage(even
     }
     xhr.send();
   }
 
   // Make sure array buffer retrieved from compressed file in package is
   // 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) {
         return;
       }
       if (xhr.status) {
         ok(xhr.status == 200, "Status is 200");
         var ct = xhr.getResponseHeader("Content-Type");
--- a/dom/base/test/mochitest.ini
+++ b/dom/base/test/mochitest.ini
@@ -157,18 +157,16 @@ support-files =
   file_bug787778.sjs
   file_bug804395.jar
   file_bug869432.eventsource
   file_bug869432.eventsource^headers^
   file_bug902350.html
   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
   file_html_in_xhr2.html
   file_html_in_xhr3.html
   file_htmlserializer_1.html
   file_htmlserializer_1_bodyonly.html
   file_htmlserializer_1_format.html
@@ -654,21 +652,17 @@ skip-if = buildapp == 'mulet' || buildap
 [test_bug891952.html]
 [test_bug894874.html]
 [test_bug895239.html]
 [test_bug895974.html]
 [test_bug902847.html]
 [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]
 [test_bug1101364.html]
 skip-if = buildapp == 'mulet' || buildapp == 'b2g' || toolkit == 'android'
 [test_caretPositionFromPoint.html]
 [test_classList.html]
 # This test fails on the Mac for some reason
--- a/dom/base/test/test_bug1008126.html
+++ b/dom/base/test/test_bug1008126.html
@@ -5,47 +5,53 @@ 4 -->
 <!DOCTYPE HTML>
 <html>
 <!--
 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>
 <p id="display"></p>
 <div id="content" style="display: none">
 
 </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) {
     if (event.data.type == 'finish') {
       SimpleTest.finish();
     } else if (event.data.type == 'status') {
       ok(event.data.status, event.data.msg);
     }
   };
 
   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();
 
 addLoadEvent(function() {
    SpecialPowers.pushPrefEnv({"set": [["dom.mapped_arraybuffer.enabled", true]]}, function() {
      SpecialPowers.pushPermissions([{'type': 'systemXHR', 'allow': true, 'context': document}], runTest);
    });
--- a/dom/base/test/test_bug945152.html
+++ b/dom/base/test/test_bug945152.html
@@ -1,46 +1,53 @@
 <!DOCTYPE HTML>
 <html>
 <!--
 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>
 <p id="display"></p>
 <div id="content" style="display: none">
 
 </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");
 
   worker.onmessage = function(event) {
     if (event.data.type == 'finish') {
       SimpleTest.finish();
     } else if (event.data.type == 'status') {
       ok(event.data.status, event.data.msg);
     }
   };
 
   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();
 
 addLoadEvent(function() {
    SpecialPowers.pushPrefEnv({"set": [["dom.mapped_arraybuffer.enabled", true]]}, function() {
      SpecialPowers.pushPermissions([{'type': 'systemXHR', 'allow': true, 'context': document}], runTest);
    });