Bug 1483148 - Add allowInheritPrincipal to current tab bookmarklets. r=Gijs
authorJonathan Kingston <jkt@mozilla.com>
Tue, 21 Aug 2018 13:24:49 +0000
changeset 487754 8d88272387d127eaf0abd274bdba7dd5787c07bc
parent 487753 ed07516ab49e79cdfaf85785bc8f572aee1de55a
child 487755 34520af4d56552c7beb2547be1cbd58dfebf9a27
push id9719
push userffxbld-merge
push dateFri, 24 Aug 2018 17:49:46 +0000
treeherdermozilla-beta@719ec98fba77 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs
bugs1483148
milestone63.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 1483148 - Add allowInheritPrincipal to current tab bookmarklets. r=Gijs Differential Revision: https://phabricator.services.mozilla.com/D3313
browser/components/places/PlacesUIUtils.jsm
browser/components/places/tests/browser/browser_click_bookmarks_on_toolbar.js
--- a/browser/components/places/PlacesUIUtils.jsm
+++ b/browser/components/places/PlacesUIUtils.jsm
@@ -737,19 +737,21 @@ var PlacesUIUtils = {
 
       if (!PrivateBrowsingUtils.isWindowPrivate(aWindow)) {
         if (isBookmark)
           this.markPageAsFollowedBookmark(aNode.uri);
         else
           this.markPageAsTyped(aNode.uri);
       }
 
+      const isJavaScriptURL = aNode.uri.startsWith("javascript:");
       aWindow.openTrustedLinkIn(aNode.uri, aWhere, {
-        allowPopups: aNode.uri.startsWith("javascript:"),
+        allowPopups: isJavaScriptURL,
         inBackground: this.loadBookmarksInBackground,
+        allowInheritPrincipal: isJavaScriptURL && aWhere == "current",
         private: aPrivate,
       });
     }
   },
 
   /**
    * Helper for guessing scheme from an url string.
    * Used to avoid nsIURI overhead in frequently called UI functions.
--- a/browser/components/places/tests/browser/browser_click_bookmarks_on_toolbar.js
+++ b/browser/components/places/tests/browser/browser_click_bookmarks_on_toolbar.js
@@ -1,14 +1,15 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 const PREF_LOAD_BOOKMARKS_IN_TABS = "browser.tabs.loadBookmarksInTabs";
-const TEST_PAGES = ["about:mozilla", "about:robots"];
+const EXAMPLE_PAGE = "http://example.com/";
+const TEST_PAGES = ["about:mozilla", "about:robots", "javascript:window.location=%22" + EXAMPLE_PAGE + "%22"];
 
 var gBookmarkElements = [];
 
 function getToolbarNodeForItemGuid(aItemGuid) {
   var children = document.getElementById("PlacesToolbarItems").children;
   for (let child of children) {
     if (aItemGuid == child._placesNode.bookmarkGuid) {
       return child;
@@ -79,16 +80,20 @@ add_task(async function click() {
   });
   await promise;
 
   promise = waitForNewTab(TEST_PAGES[1], false);
   EventUtils.synthesizeMouseAtCenter(gBookmarkElements[1], {
     button: 0, accelKey: true
   });
   await promise;
+
+  promise = waitForLoad(gBrowser.selectedBrowser, EXAMPLE_PAGE);
+  EventUtils.synthesizeMouseAtCenter(gBookmarkElements[2], {});
+  await promise;
 });
 
 add_task(async function middleclick() {
   let promise = waitForNewTab(TEST_PAGES[0], true);
   EventUtils.synthesizeMouseAtCenter(gBookmarkElements[0], {
     button: 1, shiftKey: true
   });
   await promise;