Bug 1374741 - Within devtools/ tests make openUILinkIn() provide the correct triggeringPrincipal. r=jryans
authorJonathan Kingston <jkt@mozilla.com>
Wed, 21 Feb 2018 23:21:03 +0000
changeset 466114 8e73dd281210a8ee08ea6f0bb565b76259417258
parent 466113 d0d9ef19a7fcc5df50ba9886dc5297ca25d09d5f
child 466115 1a13549c696a08ac5a37c2a6b1dc73b9c0ad77d8
push id9165
push userasasaki@mozilla.com
push dateThu, 26 Apr 2018 21:04:54 +0000
treeherdermozilla-beta@064c3804de2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjryans
bugs1374741
milestone61.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 1374741 - Within devtools/ tests make openUILinkIn() provide the correct triggeringPrincipal. r=jryans MozReview-Commit-ID: GNEe8H0sc4L
devtools/client/aboutdebugging/test/browser_page_not_found.js
devtools/client/webconsole/old/test/browser_webconsole_open-links-without-callback.js
devtools/client/webconsole/old/test/head.js
devtools/client/webconsole/test/mochitest/head.js
--- a/devtools/client/aboutdebugging/test/browser_page_not_found.js
+++ b/devtools/client/aboutdebugging/test/browser_page_not_found.js
@@ -15,17 +15,17 @@ add_task(async function() {
   document.querySelector("[aria-controls='addons-panel']").click();
   await waitUntilElement("#addons-panel", document);
 
   await waitForInitialAddonList(document);
   element = document.querySelector(".header-name");
   is(element.textContent, "Add-ons", "Show Addons");
 
   info("Opening about:debugging#invalid-hash");
-  window.openUILinkIn("about:debugging#invalid-hash", "current");
+  window.openTrustedLinkIn("about:debugging#invalid-hash", "current");
   await waitUntilElement(".error-page", document);
 
   element = document.querySelector(".header-name");
   is(element.textContent, "Page not found", "Show error page");
 
   gBrowser.goBack();
   await waitUntilElement("#addons-panel", document);
   await waitForInitialAddonList(document);
--- a/devtools/client/webconsole/old/test/browser_webconsole_open-links-without-callback.js
+++ b/devtools/client/webconsole/old/test/browser_webconsole_open-links-without-callback.js
@@ -32,23 +32,23 @@ function test() {
     let messageNode = messages[0].matched.values().next().value;
 
     // The correct anchor is second in the message node; the first anchor has
     // class .cm-variable. Ignore the first one by not matching anchors that
     // have the class .cm-variable.
     let urlNode = messageNode.querySelector("a:not(.cm-variable)");
 
     let linkOpened = false;
-    let oldOpenUILinkIn = window.openUILinkIn;
-    window.openUILinkIn = function (aLink) {
+    let oldOpenWebLinkIn = window.openWebLinkIn;
+    window.openWebLinkIn = function (aLink) {
       if (aLink == TEST_PAGE_URI) {
         linkOpened = true;
       }
     };
 
     EventUtils.synthesizeMouseAtCenter(urlNode, {}, hud.iframeWindow);
 
     ok(linkOpened, "Clicking the URL opens the desired page");
-    window.openUILinkIn = oldOpenUILinkIn;
+    window.openWebLinkIn = oldOpenWebLinkIn;
   }
 
   Task.spawn(runner).then(finishTest);
 }
--- a/devtools/client/webconsole/old/test/head.js
+++ b/devtools/client/webconsole/old/test/head.js
@@ -1799,21 +1799,23 @@ function getSourceActor(sources, URL) {
  * Verify that clicking on a link from a popup notification message tries to
  * open the expected URL.
  */
 function simulateMessageLinkClick(element, expectedLink) {
   let deferred = defer();
 
   // Invoke the click event and check if a new tab would
   // open to the correct page.
-  let oldOpenUILinkIn = window.openUILinkIn;
-  window.openUILinkIn = function (link) {
+  let oldOpenWebLinkIn = window.openWebLinkIn;
+  let oldOpenTrustedLinkIn = window.openTrustedLinkIn;
+  window.openTrustedLinkIn = window.openWebLinkIn = function (link) {
     if (link == expectedLink) {
       ok(true, "Clicking the message link opens the desired page");
-      window.openUILinkIn = oldOpenUILinkIn;
+      window.openWebLinkIn = oldOpenWebLinkIn;
+      window.openTrustedLinkIn = oldOpenTrustedLinkIn;
       deferred.resolve();
     }
   };
 
   let event = new MouseEvent("click", {
     detail: 1,
     button: 0,
     bubbles: true,
--- a/devtools/client/webconsole/test/mochitest/head.js
+++ b/devtools/client/webconsole/test/mochitest/head.js
@@ -492,39 +492,42 @@ async function closeConsole(tab = gBrows
  *          A Promise that is resolved when the link click simulation occured or
  *          when the click is not dispatched.
  *          The promise resolves with an object that holds the following properties
  *          - link: url of the link or null(if event not fired)
  *          - where: "tab" if tab is active or "tabshifted" if tab is inactive
  *            or null(if event not fired)
  */
 function simulateLinkClick(element, clickEventProps) {
-  // Override openUILinkIn to prevent navigating.
-  let oldOpenUILinkIn = window.openUILinkIn;
+  // Override LinkIn methods to prevent navigating.
+  let oldOpenTrustedLinkIn = window.openTrustedLinkIn;
+  let oldOpenWebLinkIn = window.openWebLinkIn;
 
   const onOpenLink = new Promise((resolve) => {
-    window.openUILinkIn = function(link, where) {
-      window.openUILinkIn = oldOpenUILinkIn;
+    window.openWebLinkIn = window.openTrustedLinkIn = function(link, where) {
+      window.openTrustedLinkIn = oldOpenTrustedLinkIn;
+      window.openWebLinkIn = oldOpenWebLinkIn;
       resolve({link: link, where});
     };
-
     if (clickEventProps) {
       // Click on the link using the event properties.
       element.dispatchEvent(clickEventProps);
     } else {
       // Click on the link.
       element.click();
     }
   });
 
-  // Declare a timeout Promise that we can use to make sure openUILinkIn was not called.
+  // Declare a timeout Promise that we can use to make sure openTrustedLinkIn or
+  // openWebLinkIn was not called.
   let timeoutId;
   const onTimeout = new Promise(function(resolve) {
     timeoutId = setTimeout(() => {
-      window.openUILinkIn = oldOpenUILinkIn;
+      window.openTrustedLinkIn = oldOpenTrustedLinkIn;
+      window.openWebLinkIn = oldOpenWebLinkIn;
       timeoutId = null;
       resolve({link: null, where: null});
     }, 1000);
   });
 
   onOpenLink.then(() => {
     if (timeoutId) {
       clearTimeout(timeoutId);