Bug 1510382 - Pass opener to specialTabs.openTab(). r=jorgk
authorAndreas Farre <afarre@mozilla.com>
Fri, 14 Dec 2018 17:33:41 +0100
changeset 33141 f5c4404b29d2
parent 33140 948685252daa
child 33142 1403c0fa3d1a
push id2368
push userclokep@gmail.com
push dateMon, 28 Jan 2019 21:12:50 +0000
treeherdercomm-beta@56d23c07d815 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorgk
bugs1510382
Bug 1510382 - Pass opener to specialTabs.openTab(). r=jorgk Bug 1510382 - Backed out changeset 48522dae2fd4 to re-enable test. a=backout
mail/base/content/mailWindow.js
mail/base/content/specialTabs.js
mail/test/mozmill/newmailaccount/test-newmailaccount.js
--- a/mail/base/content/mailWindow.js
+++ b/mail/base/content/mailWindow.js
@@ -675,16 +675,17 @@ nsBrowserAccess.prototype = {
     let tabmail = win.document.getElementById("tabmail");
     let clickHandler = null;
     let browser = tabmail.getBrowserForDocument(window.content);
     if (browser)
       clickHandler = browser.clickHandler;
 
     let newTab = tabmail.openTab("contentTab", {contentPage: "about:blank",
                                                 background: loadInBackground,
+                                                opener: aOpener,
                                                 clickHandler});
 
     newWindow = newTab.browser.docShell.domWindow;
     try {
       if (aURI) {
         let referrer = null;
         if (aOpener) {
           let location = aOpener.location;
--- a/mail/base/content/specialTabs.js
+++ b/mail/base/content/specialTabs.js
@@ -686,31 +686,35 @@ var specialTabs = {
     },
 
     /**
      * This is the internal function used by content tabs to open a new tab. To
      * open a contentTab, use specialTabs.openTab("contentTab", aArgs)
      *
      * @param aArgs The options that content tabs accept.
      * @param aArgs.contentPage A string that holds the URL that is to be opened
+     * @param aArgs.opener The opener window
      * @param aArgs.clickHandler The click handler for that content tab. See the
      *  "Content Tabs" article on MDC.
      * @param aArgs.onLoad A function that takes an Event and a DOMNode. It is
      *  called when the content page is done loading. The first argument is the
      *  load event, and the second argument is the xul:browser that holds the
      *  contentPage. You can access the inner tab's window object by accessing
      *  the second parameter's contentWindow property.
      */
     openTab(aTab, aArgs) {
       if (!("contentPage" in aArgs))
         throw new Error("contentPage must be specified");
 
       // First clone the page and set up the basics.
       let clone = document.getElementById("contentTab").firstChild.cloneNode(true);
 
+      if ("opener" in aArgs && aArgs.opener)
+        clone.querySelector("browser").presetOpenerWindow(aArgs.opener);
+
       const findbar = document.createElement("findbar");
       // Adding browserid to findbar so that browser property can be set
       // in findbar custom element.
       findbar.setAttribute("browserid", "dummycontentbrowser");
       clone.appendChild(findbar);
 
       clone.setAttribute("id", "contentTab" + this.lastBrowserId);
       clone.setAttribute("collapsed", false);
--- a/mail/test/mozmill/newmailaccount/test-newmailaccount.js
+++ b/mail/test/mozmill/newmailaccount/test-newmailaccount.js
@@ -940,17 +940,16 @@ function test_internal_link_opening_beha
   });
   // Now close the tab.
   mc.tabmail.closeTab(tab);
 }
 
 /**
  * Test that window.open in the order form opens in new content tabs.
  */
-test_window_open_link_opening_behaviour.__force_skip__ = true;
 function test_window_open_link_opening_behaviour() {
   get_to_order_form();
 
   let tab = mc.tabmail.currentTabInfo;
   let doc = tab.browser.contentWindow.document;
 
   // First, click on the Javascript link - this should open in a new content
   // tab and be focused.