Bug 1359545 - Update tests to pass triggeringPrincipal to loadURI. r=bz, r=gijs
authorChristoph Kerschbaumer <ckerschb@christophkerschbaumer.com>
Wed, 26 Apr 2017 21:45:30 +0200
changeset 403222 c9210201f671ae0ca61e517aff6c0dcdc7419f7b
parent 403221 3c182ffc4e7655e529541d06c4b6b598c3373d6a
child 403223 dd5867630919080399268cee22bf4900994b2aca
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz, gijs
bugs1359545
milestone55.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 1359545 - Update tests to pass triggeringPrincipal to loadURI. r=bz, r=gijs
browser/base/content/test/general/browser_e10s_switchbrowser.js
browser/components/sessionstore/test/browser_async_remove_tab.js
dom/xslt/tests/buster/buster-view.js
dom/xslt/tests/buster/result-view.js
toolkit/components/remotebrowserutils/tests/browser/browser_RemoteWebNavigation.js
--- a/browser/base/content/test/general/browser_e10s_switchbrowser.js
+++ b/browser/base/content/test/general/browser_e10s_switchbrowser.js
@@ -57,17 +57,19 @@ function clear_history() {
   gExpectedHistory.index = -1;
   gExpectedHistory.entries = [];
 }
 
 // Waits for a load and updates the known history
 var waitForLoad = Task.async(function*(uri) {
   info("Loading " + uri);
   // Longwinded but this ensures we don't just shortcut to LoadInNewProcess
-  gBrowser.selectedBrowser.webNavigation.loadURI(uri, Ci.nsIWebNavigation.LOAD_FLAGS_NONE, null, null, null);
+  gBrowser.selectedBrowser.webNavigation.loadURI(uri, Ci.nsIWebNavigation.LOAD_FLAGS_NONE,
+                                                 null, null, null,
+                                                 Services.scriptSecurityManager.getSystemPrincipal());
 
   yield waitForDocLoadComplete();
   gExpectedHistory.index++;
   gExpectedHistory.entries.push({
     uri: gBrowser.currentURI.spec,
     title: gBrowser.contentTitle
   });
 });
--- a/browser/components/sessionstore/test/browser_async_remove_tab.js
+++ b/browser/components/sessionstore/test/browser_async_remove_tab.js
@@ -134,17 +134,19 @@ add_task(function* save_worthy_tabs_nonr
 });
 
 add_task(function* save_worthy_tabs_remote_final() {
   let {tab, r} = yield createTabWithRandomValue("about:blank");
   let browser = tab.linkedBrowser;
   ok(browser.isRemoteBrowser, "browser is remote");
 
   // Replace about:blank with a new remote page.
-  let snippet = 'webNavigation.loadURI("https://example.com/", null, null, null, null)';
+  let snippet = 'webNavigation.loadURI("https://example.com/",\
+                                       null, null, null, null,\
+                                       Services.scriptSecurityManager.getSystemPrincipal())';
   yield promiseNewLocationAndHistoryEntryReplaced(browser, snippet);
 
   // Remotness shouldn't have changed.
   ok(browser.isRemoteBrowser, "browser is still remote");
 
   // Remove the tab before the update arrives.
   let promise = promiseRemoveTab(tab);
 
--- a/dom/xslt/tests/buster/buster-view.js
+++ b/dom/xslt/tests/buster/buster-view.js
@@ -1,13 +1,15 @@
 /* -*- indent-tabs-mode: nil; js-indent-level: 4 -*- */
 /* 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/. */
 
+Components.utils.import("resource://gre/modules/Services.jsm");
+
 var view = 
 {
     onRun : function()
     {
         runQueue.mArray = new Array();
         var sels = this.boxObject.view.selection,a=new Object(),b=new Object(),k;
         var rowResource, name, path;
         for (k=0;k<sels.getRangeCount();k++){
@@ -96,17 +98,18 @@ var view =
     },
     loadHtml : function(aUrl, aListener)
     {
         const nsIIRequestor = Components.interfaces.nsIInterfaceRequestor;
         const nsIWebProgress = Components.interfaces.nsIWebProgress;
         var req = this.mIframe.webNavigation.QueryInterface(nsIIRequestor);
         var prog = req.getInterface(nsIWebProgress);
         prog.addProgressListener(aListener, nsIWebProgress.NOTIFY_ALL);
-        this.mIframe.webNavigation.loadURI(aUrl, 0,null,null,null);
+        this.mIframe.webNavigation.loadURI(aUrl, 0,null,null,null,
+                                           Services.scriptSecurityManager.getSystemPrincipal());
     },
     fillItemContext : function()
     {
         var index = view.boxObject.view.selection.currentIndex;
         var res = view.builder.getResourceAtIndex(index);
         var purp = view.mXalanDS.GetTarget(res, krTypePurp, true);
         return (purp != null);
     }
--- a/dom/xslt/tests/buster/result-view.js
+++ b/dom/xslt/tests/buster/result-view.js
@@ -1,13 +1,16 @@
 /* -*- indent-tabs-mode: nil; js-indent-level: 4 -*- */
 /* 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/. */
 
+Components.utils.import("resource://gre/modules/Services.jsm");
+const SYSTEMPRINCIPAL = Services.scriptSecurityManager.getSystemPrincipal();
+
 function onNewResultView(event)
 {
     dump("onNewResultView\n");
     const db = runItem.prototype.kDatabase;
     const kXalan = runItem.prototype.kXalan;
     var index = view.boxObject.view.selection.currentIndex;
     var res = view.builder.getResourceAtIndex(index);
     var name = db.GetTarget(res, krTypeName, true);
@@ -37,31 +40,34 @@ var resInspector;
 
 function onResultViewLoad(event)
 {
     dump("onResultViewLoad\n");
     aResultItem = window.arguments[0];
     aRunItem = window.arguments[1];
     var loadFlags = Components.interfaces.nsIWebNavigation.LOAD_FLAGS_NONE;
     document.getElementById('src').webNavigation.loadURI('view-source:'+
-        aResultItem.testpath+'.xml', loadFlags, null, null, null);
+        aResultItem.testpath+'.xml', loadFlags, null, null, null,
+        SYSTEMPRINCIPAL);
     document.getElementById('style').webNavigation.loadURI('view-source:'+
-        aResultItem.testpath+'.xsl', loadFlags, null, null, null);
+        aResultItem.testpath+'.xsl', loadFlags, null, null, null,
+        SYSTEMPRINCIPAL);
 
     if (aRunItem && aRunItem.mRefDoc && aRunItem.mResDoc) {
         document.getElementById("refSourceBox").setAttribute("class", "hidden");
         refInspector = new ObjectApp();
         refInspector.initialize("refInsp", aRunItem.mRefDoc);
         resInspector = new ObjectApp();
         resInspector.initialize("resInsp", aRunItem.mResDoc);
     }
     else {
         document.getElementById("inspectorBox").setAttribute("class", "hidden");
         document.getElementById('ref').webNavigation.loadURI('view-source:'+
-            aResultItem.refpath+'.out', loadFlags, null, null, null);
+            aResultItem.refpath+'.out', loadFlags, null, null, null,
+            SYSTEMPRINCIPAL);
     }
     return true;
 }
 
 function onResultViewUnload(event)
 {
     dump("onResultUnload\n");
 }
--- a/toolkit/components/remotebrowserutils/tests/browser/browser_RemoteWebNavigation.js
+++ b/toolkit/components/remotebrowserutils/tests/browser/browser_RemoteWebNavigation.js
@@ -1,8 +1,10 @@
+Cu.import("resource://gre/modules/Services.jsm");
+const SYSTEMPRINCIPAL = Services.scriptSecurityManager.getSystemPrincipal();
 const DUMMY1 = "http://example.com/browser/toolkit/modules/tests/browser/dummy_page.html";
 const DUMMY2 = "http://example.org/browser/toolkit/modules/tests/browser/dummy_page.html"
 
 function waitForLoad(uri) {
   return BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser, false, uri);
 }
 
 function waitForPageShow(browser = gBrowser.selectedBrowser) {
@@ -17,18 +19,18 @@ function makeURI(url) {
 
 // Tests that loadURI accepts a referrer and it is included in the load.
 add_task(function* test_referrer() {
   gBrowser.selectedTab = gBrowser.addTab();
   let browser = gBrowser.selectedBrowser;
 
   browser.webNavigation.loadURI(DUMMY1,
                                 Ci.nsIWebNavigation.LOAD_FLAGS_NONE,
-                                makeURI(DUMMY2),
-                                null, null);
+                                makeURI(DUMMY2), null, null,
+                                SYSTEMPRINCIPAL);
   yield waitForLoad(DUMMY1);
 
   yield ContentTask.spawn(browser, [ DUMMY1, DUMMY2 ], function([dummy1, dummy2]) {
     is(content.location.href, dummy1, "Should have loaded the right URL");
     is(content.document.referrer, dummy2, "Should have the right referrer");
   });
 
   gBrowser.removeCurrentTab();
@@ -43,22 +45,24 @@ add_task(function* test_history() {
       is(history.index, n, "Should be at the right place in history");
     });
   }
   gBrowser.selectedTab = gBrowser.addTab();
   let browser = gBrowser.selectedBrowser;
 
   browser.webNavigation.loadURI(DUMMY1,
                                 Ci.nsIWebNavigation.LOAD_FLAGS_NONE,
-                                null, null, null);
+                                null, null, null,
+                                SYSTEMPRINCIPAL);
   yield waitForLoad(DUMMY1);
 
   browser.webNavigation.loadURI(DUMMY2,
                                 Ci.nsIWebNavigation.LOAD_FLAGS_NONE,
-                                null, null, null);
+                                null, null, null,
+                                SYSTEMPRINCIPAL);
   yield waitForLoad(DUMMY2);
 
   yield ContentTask.spawn(browser, [DUMMY1, DUMMY2], function([dummy1, dummy2]) {
     let history = docShell.QueryInterface(Ci.nsIInterfaceRequestor)
                           .getInterface(Ci.nsISHistory);
     is(history.count, 2, "Should be two history items");
     is(history.index, 1, "Should be at the right place in history");
     let entry = history.getEntryAtIndex(0, false);
@@ -99,28 +103,31 @@ add_task(function* test_flags() {
       });
   }
 
   gBrowser.selectedTab = gBrowser.addTab();
   let browser = gBrowser.selectedBrowser;
 
   browser.webNavigation.loadURI(DUMMY1,
                                 Ci.nsIWebNavigation.LOAD_FLAGS_NONE,
-                                null, null, null);
+                                null, null, null,
+                                SYSTEMPRINCIPAL);
   yield waitForLoad(DUMMY1);
 
   browser.webNavigation.loadURI(DUMMY2,
                                 Ci.nsIWebNavigation.LOAD_FLAGS_REPLACE_HISTORY,
-                                null, null, null);
+                                null, null, null,
+                                SYSTEMPRINCIPAL);
   yield waitForLoad(DUMMY2);
   yield checkHistory(browser, { count: 1, index: 0 });
 
   browser.webNavigation.loadURI(DUMMY1,
                                 Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_HISTORY,
-                                null, null, null);
+                                null, null, null,
+                                SYSTEMPRINCIPAL);
   yield waitForLoad(DUMMY1);
   yield checkHistory(browser, { count: 1, index: 0 });
 
   gBrowser.removeCurrentTab();
 });
 
 // Tests that attempts to use unsupported arguments throw an exception.
 add_task(function* test_badarguments() {
@@ -128,25 +135,27 @@ add_task(function* test_badarguments() {
     return;
 
   gBrowser.selectedTab = gBrowser.addTab();
   let browser = gBrowser.selectedBrowser;
 
   try {
     browser.webNavigation.loadURI(DUMMY1,
                                   Ci.nsIWebNavigation.LOAD_FLAGS_NONE,
-                                  null, {}, null);
+                                  null, {}, null,
+                                  SYSTEMPRINCIPAL);
     ok(false, "Should have seen an exception from trying to pass some postdata");
   } catch (e) {
     ok(true, "Should have seen an exception from trying to pass some postdata");
   }
 
   try {
     browser.webNavigation.loadURI(DUMMY1,
                                   Ci.nsIWebNavigation.LOAD_FLAGS_NONE,
-                                  null, null, {});
+                                  null, null, {},
+                                  SYSTEMPRINCIPAL);
     ok(false, "Should have seen an exception from trying to pass some headers");
   } catch (e) {
     ok(true, "Should have seen an exception from trying to pass some headers");
   }
 
   gBrowser.removeCurrentTab();
 });