Bug 1485305 - layout/ Ensure loadURI always passes a triggeringPrincipal() r=Gijs
☠☠ backed out by 64c64fc5e163 ☠ ☠
authorJonathan Kingston <jkt@mozilla.com>
Wed, 29 Aug 2018 15:48:05 +0100
changeset 437032 e9da73786c5f60f23082a2b6bea7733d6e721342
parent 437031 e02038177b6b6c8560bebd9d00e22777da1d46a8
child 437033 721871bb64f11836169a3eb2e06d1c61bda3aa07
push id34668
push useraiakab@mozilla.com
push dateWed, 19 Sep 2018 02:19:16 +0000
treeherdermozilla-central@a9e339b3e5d8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs
bugs1485305
milestone64.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 1485305 - layout/ Ensure loadURI always passes a triggeringPrincipal() r=Gijs Differential Revision: https://phabricator.services.mozilla.com/D4558
layout/forms/test/test_bug536567_perwindowpb.html
layout/tools/layout-debug/ui/content/layoutdebug.js
layout/tools/layout-debug/ui/content/layoutdebug.xul
layout/tools/recording/recording.js
--- a/layout/forms/test/test_bug536567_perwindowpb.html
+++ b/layout/forms/test/test_bug536567_perwindowpb.html
@@ -141,26 +141,32 @@ function whenDelayedStartupFinished(aWin
   }, "browser-delayed-startup-finished");
 }
 
 function testOnWindow(aIsPrivate, aCallback) {
   var win = mainWindow.OpenBrowserWindow({private: aIsPrivate});
   whenDelayedStartupFinished(win, function() {
     win.addEventListener("DOMContentLoaded", function onInnerLoad() {
       if (win.content.location.href != contentPage) {
-        win.gBrowser.loadURI(contentPage);
+        win.gBrowser.loadURI(contentPage, {
+          triggeringPrincipal: Services.scriptSecurityManager.createNullPrincipal({}),
+        });
         return;
       }
       win.removeEventListener("DOMContentLoaded", onInnerLoad, true);
       win.gBrowser.selectedBrowser.focus();
       SimpleTest.info("DOMContentLoaded's window: " + win.location + " vs. " + window.location);
       win.setTimeout(function() { aCallback(win); }, 0);
     }, true);
     SimpleTest.info("load's window: " + win.location + " vs. " + window.location);
-    win.setTimeout(function() { win.gBrowser.loadURI(contentPage); }, 0);
+    win.setTimeout(function() {
+      win.gBrowser.loadURI(contentPage, {
+        triggeringPrincipal: Services.scriptSecurityManager.createNullPrincipal({}),
+      });
+    }, 0);
   });
 }
 
 MockFilePicker.showCallback = function(filepicker) {
   var test = tests[testIndex];
   var returned = -1;
   for (var i = 0; i < dirs.length; i++) {
      var dir = MockFilePicker.displayDirectory
--- a/layout/tools/layout-debug/ui/content/layoutdebug.js
+++ b/layout/tools/layout-debug/ui/content/layoutdebug.js
@@ -105,20 +105,25 @@ function OnLDBLoad()
   gBrowser = document.getElementById("browser");
 
   gProgressListener = new nsLDBBrowserContentListener();
   gBrowser.addProgressListener(gProgressListener);
 
   gDebugger = Cc[NS_LAYOUT_DEBUGGINGTOOLS_CONTRACTID].
                   createInstance(nsILayoutDebuggingTools);
 
-  if (window.arguments && window.arguments[0])
-    gBrowser.loadURI(window.arguments[0]);
-  else
-    gBrowser.loadURI("about:blank");
+  if (window.arguments && window.arguments[0]) {
+    gBrowser.loadURI(window.arguments[0], {
+      triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
+    });
+  } else {
+    gBrowser.loadURI("about:blank", {
+      triggeringPrincipal: Services.scriptSecurityManager.createNullPrincipal({}),
+    });
+  }
 
   gDebugger.init(gBrowser.contentWindow);
 
   checkPersistentMenus();
 }
 
 function checkPersistentMenu(item)
 {
@@ -156,12 +161,14 @@ function openFile()
   var nsIFilePicker = Ci.nsIFilePicker;
   var fp = Cc["@mozilla.org/filepicker;1"]
         .createInstance(nsIFilePicker);
   fp.init(window, "Select a File", nsIFilePicker.modeOpen);
   fp.appendFilters(nsIFilePicker.filterHTML | nsIFilePicker.filterAll);
   fp.open(rv => {
     if (rv == nsIFilePicker.returnOK && fp.fileURL.spec &&
         fp.fileURL.spec.length > 0) {
-      gBrowser.loadURI(fp.fileURL.spec);
+      gBrowser.loadURI(fp.fileURL.spec, {
+        triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
+      });
     }
   });
 }
--- a/layout/tools/layout-debug/ui/content/layoutdebug.xul
+++ b/layout/tools/layout-debug/ui/content/layoutdebug.xul
@@ -105,17 +105,19 @@
                        label="&ldb.ReloadButton.label;"
                        oncommand="gBrowser.reload();" />
         <toolbarbutton id="stop-button" class="toolbarbutton-1"
                        label="&ldb.StopButton.label;"
                        oncommand="gBrowser.stop();" />
 
         <textbox id="urlbar" flex="1"
                  onkeypress="if (event.keyCode == 13)
-                               gBrowser.loadURI(this.value);" />
+                               gBrowser.loadURI(this.value, {
+                                 triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
+                               });" />
       </toolbar>
     </toolbox>
 
     <browser flex="1" id="browser" type="content" primary="true"/>
 
     <hbox>
       <description id="status-text" value="" />
     </hbox>
--- a/layout/tools/recording/recording.js
+++ b/layout/tools/recording/recording.js
@@ -35,10 +35,12 @@ this.OnRecordingLoad = function OnRecord
         gContainingWindow.close();
         return;
     }
 
     gBrowser.addEventListener("load", OnDocumentLoad, true);
 
     var args = window.arguments[0].wrappedJSObject;
 
-    gBrowser.loadURI(args.uri);
+    gBrowser.loadURI(args.uri, {
+      triggeringPrincipal: Services.scriptSecurityManager.createNullPrincipal({}),
+    });
 };