Bug 1374741 - Within browser/ tests make openUILinkIn() provide the correct triggeringPrincipal. r?gijs draft
authorJonathan Kingston <jkt@mozilla.com>
Wed, 21 Feb 2018 14:49:24 +0000
changeset 759753 8c4a987d6d8d3b8639ef53d36bfa92060f65de8a
parent 759752 e2463048aa8d56ff47dc1285448919fefcac797d
child 759754 d4d4f1aea0d49bf9c64c6380ac0849bd20697f70
push id100453
push userbmo:jkt@mozilla.com
push dateMon, 26 Feb 2018 15:22:58 +0000
reviewersgijs
bugs1374741
milestone60.0a1
Bug 1374741 - Within browser/ tests make openUILinkIn() provide the correct triggeringPrincipal. r?gijs MozReview-Commit-ID: 9tJ0b056yNE
browser/base/content/test/general/browser_bug579872.js
browser/base/content/test/general/browser_bug594131.js
browser/base/content/test/general/browser_contentSearchUI.js
browser/base/content/test/general/browser_remoteWebNavigation_postdata.js
browser/base/content/test/general/browser_utilityOverlay.js
browser/base/content/test/tabs/browser_abandonment_telemetry.js
--- a/browser/base/content/test/general/browser_bug579872.js
+++ b/browser/base/content/test/general/browser_bug579872.js
@@ -6,23 +6,23 @@ function test() {
   let newTab = BrowserTestUtils.addTab(gBrowser);
   waitForExplicitFinish();
   BrowserTestUtils.browserLoaded(newTab.linkedBrowser).then(mainPart);
 
   function mainPart() {
     gBrowser.pinTab(newTab);
     gBrowser.selectedTab = newTab;
 
-    openUILinkIn("javascript:var x=0;", "current");
+    openTrustedLinkIn("javascript:var x=0;", "current");
     is(gBrowser.tabs.length, 2, "Should open in current tab");
 
-    openUILinkIn("http://example.com/1", "current");
+    openTrustedLinkIn("http://example.com/1", "current");
     is(gBrowser.tabs.length, 2, "Should open in current tab");
 
-    openUILinkIn("http://example.org/", "current");
+    openTrustedLinkIn("http://example.org/", "current");
     is(gBrowser.tabs.length, 3, "Should open in new tab");
 
     gBrowser.removeTab(newTab);
     gBrowser.removeTab(gBrowser.tabs[1]); // example.org tab
     finish();
   }
   newTab.linkedBrowser.loadURI("http://example.com");
 }
--- a/browser/base/content/test/general/browser_bug594131.js
+++ b/browser/base/content/test/general/browser_bug594131.js
@@ -6,16 +6,18 @@ function test() {
   let newTab = BrowserTestUtils.addTab(gBrowser, "http://example.com");
   waitForExplicitFinish();
   BrowserTestUtils.browserLoaded(newTab.linkedBrowser).then(mainPart);
 
   function mainPart() {
     gBrowser.pinTab(newTab);
     gBrowser.selectedTab = newTab;
 
-    openUILinkIn("http://example.org/", "current", { inBackground: true });
+    openTrustedLinkIn("http://example.org/", "current", {
+      inBackground: true,
+    });
     isnot(gBrowser.selectedTab, newTab, "shouldn't load in background");
 
     gBrowser.removeTab(newTab);
     gBrowser.removeTab(gBrowser.tabs[1]); // example.org tab
     finish();
   }
 }
--- a/browser/base/content/test/general/browser_contentSearchUI.js
+++ b/browser/base/content/test/general/browser_contentSearchUI.js
@@ -711,17 +711,17 @@ async function promiseTab() {
       data: [pageURL],
     });
     promiseMsg("ContentSearch", "AddToWhitelistAck", gMsgMan).then(() => {
       let jsURL = getRootDirectory(gTestPath) + TEST_CONTENT_SCRIPT_BASENAME;
       gMsgMan.loadFrameScript(jsURL, false);
       deferred.resolve(msg("init"));
     });
   }, true, true);
-  openUILinkIn(pageURL, "current");
+  openTrustedLinkIn(pageURL, "current");
   return deferred.promise;
 }
 
 function promiseMsg(name, type, msgMan) {
   return new Promise(resolve => {
     info("Waiting for " + name + " message " + type + "...");
     msgMan.addMessageListener(name, function onMsg(msgObj) {
       info("Received " + name + " message " + msgObj.data.type + "\n");
--- a/browser/base/content/test/general/browser_remoteWebNavigation_postdata.js
+++ b/browser/base/content/test/general/browser_remoteWebNavigation_postdata.js
@@ -33,17 +33,19 @@ add_task(async function test_remoteWebNa
     let path = i.primaryScheme + "://" + i.primaryHost + ":" + i.primaryPort + "/test";
 
     let postdata =
       "Content-Length: 7\r\n" +
       "Content-Type: application/x-www-form-urlencoded\r\n" +
       "\r\n" +
       "success";
 
-    openUILinkIn(path, "tab", null, makeInputStream(postdata));
-
+    openTrustedLinkIn(path, "tab", {
+       allowThirdPartyFixup: null,
+       postData: makeInputStream(postdata),
+     });
   });
   await BrowserTestUtils.removeTab(gBrowser.selectedTab);
 
   await new Promise(resolve => {
     server.stop(function() { resolve(); });
   });
 });
--- a/browser/base/content/test/general/browser_utilityOverlay.js
+++ b/browser/base/content/test/general/browser_utilityOverlay.js
@@ -102,10 +102,12 @@ function test_openNewTabWith() {
 function test_openUILink() {
   let tab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, "about:blank");
   BrowserTestUtils.browserLoaded(tab.linkedBrowser).then(() => {
     is(tab.linkedBrowser.currentURI.spec, "http://example.org/", "example.org loaded");
     gBrowser.removeCurrentTab();
     runNextTest();
   });
 
-  openUILink("http://example.org/"); // defaults to "current"
+  openUILink("http://example.org/", undefined, {
+    triggeringPrincipal: Services.scriptSecurityManager.createNullPrincipal({})
+  }); // defaults to "current"
 }
--- a/browser/base/content/test/tabs/browser_abandonment_telemetry.js
+++ b/browser/base/content/test/tabs/browser_abandonment_telemetry.js
@@ -181,17 +181,17 @@ const PROBE_TESTS = [
   {
     name: "Browsing to a new URL",
 
     category: "newURI",
 
     prepare(browser) {},
 
     async doAction(browser) {
-      openUILinkIn(PAGE_2, "current");
+      openTrustedLinkIn(PAGE_2, "current");
       await BrowserTestUtils.browserLoaded(browser);
     },
   },
 ];
 
 /**
  * Takes a Telemetry histogram snapshot and makes sure
  * that the index for that value (as defined by CATEGORIES)