Bug 1588256 - Port bug 1578624, part 11: add aSkipLoad paremeter to getContentWindowOrOpenURI(). r=mattwoodrow a=jorgk
authorJorg K <jorgk@jorgk.com>
Thu, 31 Oct 2019 12:12:57 +0100
changeset 36381 29842ec3bacabba2a72aa3795c86b428369f0210
parent 36380 4820421dbf43d8325038dab2f5070cc60268533f
child 36382 a67b00fab3979f9442ff788d2c4c531499beb57d
push id2521
push usermozilla@jorgk.com
push dateWed, 06 Nov 2019 09:31:04 +0000
treeherdercomm-beta@308f336efa3e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow, jorgk
bugs1588256, 1578624, 1544863
Bug 1588256 - Port bug 1578624, part 11: add aSkipLoad paremeter to getContentWindowOrOpenURI(). r=mattwoodrow a=jorgk Also ports bug 1544863 by adding a csp to createContentWindow().
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
@@ -725,47 +725,61 @@ nsBrowserAccess.prototype = {
 
   // The following function may be called during account creation, it is called by
   // the Mozmill test test-newmailaccount.js::test_window_open_link_opening_behaviour.
   createContentWindow(
     aURI,
     aOpener,
     aWhere,
     aFlags,
-    aTriggeringPrincipal = null
+    aTriggeringPrincipal = null,
+    aCsp = null
   ) {
     return this.getContentWindowOrOpenURI(
       null,
       aOpener,
       aWhere,
       aFlags,
-      aTriggeringPrincipal
+      aTriggeringPrincipal,
+      aCsp,
+      true
     );
   },
 
-  openURI(aURI, aOpener, aWhere, aFlags, aTriggeringPrincipal = null) {
+  openURI(
+    aURI,
+    aOpener,
+    aWhere,
+    aFlags,
+    aTriggeringPrincipal = null,
+    aCsp = null
+  ) {
     if (!aURI) {
       Cu.reportError("openURI should only be called with a valid URI");
       throw Cr.NS_ERROR_FAILURE;
     }
     return this.getContentWindowOrOpenURI(
       aURI,
       aOpener,
       aWhere,
       aFlags,
-      aTriggeringPrincipal
+      aTriggeringPrincipal,
+      aCsp,
+      false
     );
   },
 
   getContentWindowOrOpenURI(
     aURI,
     aOpener,
     aWhere,
     aFlags,
-    aTriggeringPrincipal
+    aTriggeringPrincipal,
+    aCsp,
+    aSkipLoad
   ) {
     const nsIBrowserDOMWindow = Ci.nsIBrowserDOMWindow;
     let isExternal = !!(aFlags & nsIBrowserDOMWindow.OPEN_EXTERNAL);
     if (isExternal && aURI && aURI.schemeIs("chrome")) {
       Services.console.logStringMessage(
         "use -chrome command-line option to load external chrome urls\n"
       );
       return null;
@@ -807,16 +821,17 @@ nsBrowserAccess.prototype = {
       clickHandler = browser.clickHandler;
     }
 
     let newTab = tabmail.openTab("contentTab", {
       contentPage: "about:blank",
       background: loadInBackground,
       opener: aOpener,
       clickHandler,
+      skipLoad: aSkipLoad,
     });
 
     let docShell = newTab.browser.docShell;
     let newWindow = docShell.domWindow;
     let browsingContext = docShell.browsingContext;
     try {
       if (aURI) {
         let referrer = null;
--- a/mail/base/content/specialTabs.js
+++ b/mail/base/content/specialTabs.js
@@ -849,16 +849,19 @@ var specialTabs = {
 
       let toolbox = clone.firstElementChild;
       toolbox.setAttribute("id", "contentTabToolbox" + this.lastBrowserId);
       toolbox.firstElementChild.setAttribute(
         "id",
         "contentTabToolbar" + this.lastBrowserId
       );
 
+      if (aArgs.skipLoad) {
+        clone.querySelector("browser").setAttribute("nodefaultsrc", "true");
+      }
       aTab.panel.setAttribute("id", "contentTabWrapper" + this.lastBrowserId);
       aTab.panel.appendChild(clone);
       aTab.root = clone;
 
       // Start setting up the browser.
       aTab.browser = aTab.panel.querySelector("browser");
       aTab.toolbar = aTab.panel.querySelector(".contentTabToolbar");
       aTab.security = aTab.panel.querySelector(".contentTabSecurity");
@@ -944,20 +947,22 @@ var specialTabs = {
 
       // Initialize our unit testing variables.
       aTab.pageLoading = false;
       aTab.pageLoaded = false;
 
       // Now start loading the content.
       aTab.title = this.loadingTabString;
 
-      let params = {
-        triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
-      };
-      aTab.browser.loadURI(aArgs.contentPage, params);
+      if (!aArgs.skipLoad) {
+        let params = {
+          triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
+        };
+        aTab.browser.loadURI(aArgs.contentPage, params);
+      }
 
       this.lastBrowserId++;
     },
     tryCloseTab(aTab) {
       let docShell = aTab.browser.docShell;
       // If we have a docshell, a contentViewer, and it forbids us from closing
       // the tab, then we return false, which means, we can't close the tab. All
       // other cases return true.
--- a/mail/test/mozmill/newmailaccount/test-newmailaccount.js
+++ b/mail/test/mozmill/newmailaccount/test-newmailaccount.js
@@ -1080,17 +1080,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; // See bug 1588256.
 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.