Bug 1184387 - Stop using the hidden DOM window in browser_parsable_css. r=Gijs
authorBobby Holley <bobbyholley@gmail.com>
Tue, 04 Aug 2015 15:20:50 -0700
changeset 288368 d52716b6cdf0b72efe28a3f2f657e1cd50ba1fbe
parent 288367 fc5272ac152e8d0fea38ad2e4bd38e6d8aafb744
child 288369 6d3e153efe5bff3b3cc4f3690924491aec6856b2
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs
bugs1184387
milestone42.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 1184387 - Stop using the hidden DOM window in browser_parsable_css. r=Gijs The hidden DOM window has a chrome:// URI on mac and a resource:// URI elsewhere, which makes it really terrible for stuff like this.
browser/base/content/test/general/browser_parsable_css.js
--- a/browser/base/content/test/general/browser_parsable_css.js
+++ b/browser/base/content/test/general/browser_parsable_css.js
@@ -50,30 +50,48 @@ function ignoredError(aErrorObject) {
     }
     if (matches) {
       return true;
     }
   }
   return false;
 }
 
+function once(target, name) {
+  return new Promise((resolve, reject) => {
+    let cb = () => {
+      target.removeEventListener(name, cb);
+      resolve();
+    };
+    target.addEventListener(name, cb);
+  });
+}
+
 add_task(function checkAllTheCSS() {
   let appDir = Services.dirsvc.get("XCurProcD", Ci.nsIFile);
   // This asynchronously produces a list of URLs (sadly, mostly sync on our
   // test infrastructure because it runs against jarfiles there, and
   // our zipreader APIs are all sync)
   let uris = yield generateURIsFromDirTree(appDir, ".css");
 
-  // Create a clean iframe to load all the files into:
-  let hiddenWin = Services.appShell.hiddenDOMWindow;
-  let iframe = hiddenWin.document.createElementNS("http://www.w3.org/1999/xhtml", "html:iframe");
-  hiddenWin.document.documentElement.appendChild(iframe);
+  // Create a clean iframe to load all the files into. This needs to live at a
+  // file or jar URI (depending on whether we're using a packaged build or not)
+  // so that it's allowed to load other same-scheme URIs (i.e. the browser css).
+  let resHandler = Services.io.getProtocolHandler("resource")
+                           .QueryInterface(Ci.nsISubstitutingProtocolHandler);
+  let resURI = Services.io.newURI('resource://testing-common/resource_test_file.html', null, null);
+  let testFile = resHandler.resolveURI(resURI);
+  let windowless = Services.appShell.createWindowlessBrowser();
+  let iframe = windowless.document.createElementNS("http://www.w3.org/1999/xhtml", "html:iframe");
+  windowless.document.documentElement.appendChild(iframe);
+  let iframeLoaded = once(iframe, 'load');
+  iframe.contentWindow.location = testFile;
+  yield iframeLoaded;
   let doc = iframe.contentWindow.document;
 
-
   // Listen for errors caused by the CSS:
   let errorListener = {
     observe: function(aMessage) {
       if (!aMessage || !(aMessage instanceof Ci.nsIScriptError)) {
         return;
       }
       // Only care about CSS errors generated by our iframe:
       if (aMessage.category.includes("CSS") && aMessage.innerWindowID === 0 && aMessage.outerWindowID === 0) {