Bug 1145472 - Use HiddenFrame in browser_no_tabs.js test to fix security errors. r=MattN
authorAlessio Placitelli <alessio.placitelli@gmail.com>
Fri, 20 Mar 2015 09:22:00 -0400
changeset 265710 94fd0d06da835ad2ae26514c44883861f2f62be3
parent 265709 283eb8bbb9629ef6b0aeb349323883b200a7b568
child 265711 db88094d97b236e7407ec3b652e38ab183b42786
push id830
push userraliiev@mozilla.com
push dateFri, 19 Jun 2015 19:24:37 +0000
treeherdermozilla-release@932614382a68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMattN
bugs1145472
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 1145472 - Use HiddenFrame in browser_no_tabs.js test to fix security errors. r=MattN
browser/components/uitour/test/browser_no_tabs.js
--- a/browser/components/uitour/test/browser_no_tabs.js
+++ b/browser/components/uitour/test/browser_no_tabs.js
@@ -1,62 +1,54 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 "use strict";
 
+let HiddenFrame = Cu.import("resource:///modules/HiddenFrame.jsm", {}).HiddenFrame;
+
 const HTML_NS = "http://www.w3.org/1999/xhtml";
 const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
 
 /**
  * Create a frame in the |hiddenDOMWindow| to host a |browser|, then load the URL in the
  * latter.
  *
  * @param aURL
  *        The URL to open in the browser.
  **/
 function createHiddenBrowser(aURL) {
-  let deferred = Promise.defer();
-  let hiddenDoc = Services.appShell.hiddenDOMWindow.document;
-
-  // Create a HTML iframe with a chrome URL, then this can host the browser.
-  let iframe = hiddenDoc.createElementNS(HTML_NS, "iframe");
-  iframe.setAttribute("src", "chrome://global/content/mozilla.xhtml");
-  iframe.addEventListener("load", function onLoad() {
-    iframe.removeEventListener("load", onLoad, true);
+  let frame = new HiddenFrame();
+  return new Promise(resolve =>
+    frame.get().then(aFrame => {
+      let doc = aFrame.document;
+      let browser = doc.createElementNS(XUL_NS, "browser");
+      browser.setAttribute("type", "content");
+      browser.setAttribute("disableglobalhistory", "true");
+      browser.setAttribute("src", aURL);
 
-    let browser = iframe.contentDocument.createElementNS(XUL_NS, "browser");
-    browser.setAttribute("type", "content");
-    browser.setAttribute("disableglobalhistory", "true");
-    browser.setAttribute("src", aURL);
-
-    iframe.contentDocument.documentElement.appendChild(browser);
-    deferred.resolve({frame: iframe, browser: browser});
-  }, true);
-
-  hiddenDoc.documentElement.appendChild(iframe);
-  return deferred.promise;
-};
+      doc.documentElement.appendChild(browser);
+      resolve({frame: frame, browser: browser});
+    }));
+}
 
 /**
- * Remove the browser and the iframe.
+ * Remove the browser and the HiddenFrame.
  *
  * @param aFrame
- *        The iframe to dismiss.
+ *        The HiddenFrame to dismiss.
  * @param aBrowser
  *        The browser to dismiss.
  */
 function destroyHiddenBrowser(aFrame, aBrowser) {
   // Dispose of the hidden browser.
   aBrowser.remove();
 
   // Take care of the frame holding our invisible browser.
-  if (!Cu.isDeadWrapper(aFrame)) {
-    aFrame.remove();
-  }
+  aFrame.destroy();
 };
 
 /**
  * Test that UITour works when called when no tabs are available (e.g., when using windowless
  * browsers).
  */
 add_task(function* test_windowless_UITour(){
   // Get the URL for the test page.