Bug 1362993 - Add BrowserTestUtils.addTab() which provides triggeringPrincipal for params object. r=florian
authorChristoph Kerschbaumer <ckerschb@christophkerschbaumer.com>
Wed, 10 May 2017 09:31:59 +0200
changeset 406651 08e52e63564d5fae25227c2c14555198758f345b
parent 406650 2e27f56d21b48c52075cac851b24d8948b95517b
child 406652 a2b7eaff126829fff66d9d84499a3a81e9a46f6a
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)
reviewersflorian
bugs1362993
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 1362993 - Add BrowserTestUtils.addTab() which provides triggeringPrincipal for params object. r=florian
testing/mochitest/BrowserTestUtils/BrowserTestUtils.jsm
--- a/testing/mochitest/BrowserTestUtils/BrowserTestUtils.jsm
+++ b/testing/mochitest/BrowserTestUtils/BrowserTestUtils.jsm
@@ -1359,9 +1359,21 @@ this.BrowserTestUtils = {
   },
 
   *_removeAboutPageRegistrations() {
     for (let aboutModule of this._knownAboutPages) {
       yield this.unregisterAboutPage(aboutModule);
     }
     Services.ppmm.removeDelayedProcessScript(kAboutPageRegistrationContentScript);
   },
+
+  /**
+   * Opens a tab with a given uri and params object. If the params object is not set
+   * or the params parameter does not include a triggeringPricnipal then this function
+   * provides a params object using the systemPrincipal as the default triggeringPrincipal.
+   */
+  addTab(browser, uri, params = {}) {
+    if (!params.triggeringPrincipal) {
+      params.triggeringPrincipal = Services.scriptSecurityManager.getSystemPrincipal();
+    }
+    return browser.addTab(uri, params);
+  }
 };