Backed out 2 changesets (bug 1362034) for failing damp | inspector/cold-open.js on a CLOSED TREE

Backed out changeset 8c8925b75aa2 (bug 1362034)
Backed out changeset ff6b05c96094 (bug 1362034)
This commit is contained in:
Andreea Pavel
2018-08-06 20:42:44 +03:00
parent c7bb2480d8
commit 31fb9c007c
95 changed files with 216 additions and 342 deletions

View File

@@ -32,7 +32,7 @@
this.invoke = function addTab_invoke()
{
tabBrowser().addTrustedTab(aURL);
tabBrowser().addTab(aURL);
}
this.getID = function addTab_getID()

View File

@@ -247,12 +247,7 @@ var CaptivePortalWatcher = {
// If the tab is gone or going, we need to open a new one.
if (!tab || tab.closing || !tab.parentNode) {
tab = gBrowser.addWebTab(this.canonicalURL, {
ownerTab: gBrowser.selectedTab,
triggeringPrincipal: Services.scriptSecurityManager.createNullPrincipal({
userContextId: gBrowser.contentPrincipal.userContextId,
}),
});
tab = gBrowser.addTab(this.canonicalURL, { ownerTab: gBrowser.selectedTab });
this._captivePortalTab = Cu.getWeakReference(tab);
}

View File

@@ -308,7 +308,7 @@
accesskey="&keywordfield.accesskey;"
oncommand="AddKeywordForSearchField();"/>
<menuitem id="context-searchselect"
oncommand="BrowserSearch.loadSearchFromContext(this.searchTerms, this.principal);"/>
oncommand="BrowserSearch.loadSearchFromContext(this.searchTerms);"/>
<menuseparator id="context-sep-sendlinktodevice" class="sync-ui-item"
hidden="true"/>
<menu id="context-sendlinktodevice"

View File

@@ -538,8 +538,7 @@ const gStoragePressureObserver = {
accessKey: prefStrBundle.getString("spaceAlert.learnMoreButton.accesskey"),
callback(notificationBar, button) {
let learnMoreURL = Services.urlFormatter.formatURLPref("app.support.baseURL") + "storage-permissions";
// This is a content URL, loaded from trusted UX.
gBrowser.selectedTab = gBrowser.addTrustedTab(learnMoreURL);
gBrowser.selectedTab = gBrowser.addTab(learnMoreURL);
}
});
if (usage < USAGE_THRESHOLD_BYTES) {
@@ -3972,11 +3971,8 @@ const BrowserSearch = {
* @return engine The search engine used to perform a search, or null if no
* search was performed.
*/
_loadSearch(searchText, useNewTab, purpose, triggeringPrincipal) {
_loadSearch(searchText, useNewTab, purpose) {
let engine;
if (!triggeringPrincipal) {
throw new Error("Required argument triggeringPrincipal missing within _loadSearch");
}
// If the search bar is visible, use the current engine, otherwise, fall
// back to the default engine.
@@ -4000,20 +3996,33 @@ const BrowserSearch = {
useNewTab ? "tab" : "current",
{ postData: submission.postData,
inBackground,
relatedToCurrent: true,
triggeringPrincipal });
relatedToCurrent: true });
return engine;
},
/**
* Just like _loadSearch, but preserving an old API.
*
* @return string Name of the search engine used to perform a search or null
* if a search was not performed.
*/
loadSearch: function BrowserSearch_search(searchText, useNewTab, purpose) {
let engine = BrowserSearch._loadSearch(searchText, useNewTab, purpose);
if (!engine) {
return null;
}
return engine.name;
},
/**
* Perform a search initiated from the context menu.
*
* This should only be called from the context menu. See
* BrowserSearch.loadSearch for the preferred API.
*/
loadSearchFromContext(terms, triggeringPrincipal) {
let engine = BrowserSearch._loadSearch(terms, true, "contextmenu", triggeringPrincipal);
loadSearchFromContext(terms) {
let engine = BrowserSearch._loadSearch(terms, true, "contextmenu");
if (engine) {
BrowserSearch.recordSearchInTelemetry(engine, "contextmenu");
}
@@ -7380,8 +7389,7 @@ const gAccessibilityServiceIndicator = {
type === "click") {
let a11yServicesSupportURL =
Services.urlFormatter.formatURLPref("accessibility.support.url");
// This is a known URL coming from trusted UI
gBrowser.selectedTab = gBrowser.addTrustedTab(a11yServicesSupportURL);
gBrowser.selectedTab = gBrowser.addTab(a11yServicesSupportURL);
Services.telemetry.scalarSet("a11y.indicator_acted_on", true);
}
},

View File

@@ -1502,7 +1502,6 @@ nsContextMenu.prototype = {
// Store searchTerms in context menu item so we know what to search onclick
menuItem.searchTerms = selectedText;
menuItem.principal = this.principal;
// Copied to alert.js' prefillAlertInfo().
// If the JS character after our truncation point is a trail surrogate,

View File

@@ -1373,11 +1373,6 @@ window._gBrowser = {
aName = params.name;
}
// all callers of loadOneTab need to pass a valid triggeringPrincipal.
if (!aTriggeringPrincipal) {
throw new Error("Required argument triggeringPrincipal missing within loadOneTab");
}
var bgLoad = (aLoadInBackground != null) ? aLoadInBackground :
Services.prefs.getBoolPref("browser.tabs.loadInBackground");
var owner = bgLoad ? null : this.selectedTab;
@@ -2139,30 +2134,6 @@ window._gBrowser = {
tab.dispatchEvent(evt);
},
/**
* Loads a tab with a default null principal unless specified
*/
addWebTab(aURI, params = {}) {
if (!params.triggeringPrincipal) {
params.triggeringPrincipal = Services.scriptSecurityManager.createNullPrincipal({
userContextId: params.userContextId,
});
}
if (Services.scriptSecurityManager.isSystemPrincipal(params.triggeringPrincipal)) {
throw new Error("System principal should never be passed into addWebTab()");
}
return this.addTab(aURI, params);
},
/**
* Must only be used sparingly for content that came from Chrome context
* If in doubt use addWebTab
*/
addTrustedTab(aURI, params = {}) {
params.triggeringPrincipal = Services.scriptSecurityManager.getSystemPrincipal();
return this.addTab(aURI, params);
},
// eslint-disable-next-line complexity
addTab(aURI, {
allowMixedContent,
@@ -2198,13 +2169,6 @@ window._gBrowser = {
recordExecution,
replayExecution,
} = {}) {
// all callers of addTab that pass a params object need to pass
// a valid triggeringPrincipal.
if (!triggeringPrincipal) {
throw new Error("Required argument triggeringPrincipal missing within addTab");
}
// if we're adding tabs, we're past interrupt mode, ditch the owner
if (this.selectedTab.owner) {
this.selectedTab.owner = null;
@@ -2860,9 +2824,7 @@ window._gBrowser = {
aTab._mouseleave();
if (newTab)
this.addTrustedTab(BROWSER_NEW_TAB_URL, {
skipAnimation: true,
});
this.addTab(BROWSER_NEW_TAB_URL, { skipAnimation: true });
else
TabBarVisibility.update();
@@ -3637,7 +3599,7 @@ window._gBrowser = {
// new tab must have the same usercontextid as the old one
params.userContextId = aTab.getAttribute("usercontextid");
}
let newTab = this.addWebTab("about:blank", params);
let newTab = this.addTab("about:blank", params);
let newBrowser = this.getBrowserForTab(newTab);
// Stop the about:blank load.
@@ -5314,22 +5276,10 @@ var TabContextMenu = {
});
},
reopenInContainer(event) {
let userContextId = parseInt(event.target.getAttribute("data-usercontextid"));
/* Create a triggering principal that is able to load the new tab
For codebase principals that are about: chrome: or resource: we need system to load them.
Anything other than system principal needs to have the new userContextId.
*/
let triggeringPrincipal = this.contextTab.linkedBrowser.contentPrincipal;
if (triggeringPrincipal.isNullPrincipal) {
triggeringPrincipal = Services.scriptSecurityManager.createNullPrincipal({ userContextId });
} else if (triggeringPrincipal.isCodebasePrincipal) {
triggeringPrincipal = Services.scriptSecurityManager.createCodebasePrincipal(triggeringPrincipal.URI, { userContextId });
}
let newTab = gBrowser.addTab(this.contextTab.linkedBrowser.currentURI.spec, {
userContextId,
userContextId: parseInt(event.target.getAttribute("data-usercontextid")),
pinned: this.contextTab.pinned,
index: this.contextTab._tPos + 1,
triggeringPrincipal,
});
if (gBrowser.selectedTab == this.contextTab) {

View File

@@ -45,7 +45,7 @@ add_task(async function closeWindowWithMultipleTabsIncludingOneBeforeUnload() {
let newWin = await promiseOpenAndLoadWindow({}, true);
let firstTab = newWin.gBrowser.selectedTab;
await promiseTabLoadEvent(firstTab, TEST_PAGE);
await promiseTabLoadEvent(BrowserTestUtils.addTab(newWin.gBrowser), "http://example.com/");
await promiseTabLoadEvent(newWin.gBrowser.addTab(), "http://example.com/");
let windowClosedPromise = BrowserTestUtils.domWindowClosed(newWin);
expectingDialog = true;
newWin.BrowserTryToCloseWindow();

View File

@@ -20,7 +20,7 @@ add_task(async function() {
let tab = win.gBrowser.tabContainer.firstChild;
await promiseTabLoadEvent(tab, getRootDirectory(gTestPath) + "test_bug462673.html");
var newTab = BrowserTestUtils.addTab(win.gBrowser);
var newTab = win.gBrowser.addTab();
var newBrowser = newTab.linkedBrowser;
win.gBrowser.removeTab(tab);
ok(!win.closed, "Window stays open");

View File

@@ -10,7 +10,7 @@
add_task(async function test() {
let win = await BrowserTestUtils.openNewBrowserWindow({private: true});
let tab = win.gBrowser.selectedTab = BrowserTestUtils.addTab(win.gBrowser, "about:addons");
let tab = win.gBrowser.selectedTab = win.gBrowser.addTab("about:addons");
await BrowserTestUtils.browserLoaded(tab.linkedBrowser);
await promiseWaitForFocus(win);

View File

@@ -17,7 +17,7 @@ add_task(async function() {
ok(true, "tests succeeded");
// Create a second tab so that we can move the original one out.
BrowserTestUtils.addTab(win.gBrowser, "about:blank", {skipAnimation: true});
win.gBrowser.addTab("about:blank", {skipAnimation: true});
// Tear off the original tab.
let browser = win.gBrowser.selectedBrowser;

View File

@@ -97,7 +97,7 @@ add_task(async function testExceptionAddition() {
testTrackingPageUnblocked();
info("Test that the exception is remembered across tabs in the same private window");
tab = browser.selectedTab = BrowserTestUtils.addTab(browser);
tab = browser.selectedTab = browser.addTab();
info("Load a test page containing tracking elements");
await promiseTabLoadEvent(tab, TRACKING_PAGE);

View File

@@ -90,7 +90,7 @@ function test_getBoolPref() {
}
function test_openNewTabWith() {
openNewTabWith("http://example.com/", null, {triggeringPrincipal: Services.scriptSecurityManager.createNullPrincipal({})});
openNewTabWith("http://example.com/");
let tab = gBrowser.selectedTab = gBrowser.tabs[1];
BrowserTestUtils.browserLoaded(tab.linkedBrowser).then(() => {
is(tab.linkedBrowser.currentURI.spec, "http://example.com/", "example.com loaded");

View File

@@ -32,7 +32,7 @@ add_task(async function multiple_tabs() {
// Add a background tab to cause another page to load *without* putting the
// desired URL in a background tab, which results in its timers being throttled.
BrowserTestUtils.addTab(gBrowser);
gBrowser.addTab();
// Wait until places has stored the page info
const pageInfo = await waitForPageInfo(TEST_PATH);

View File

@@ -303,10 +303,7 @@ async function createTabs(howMany) {
uris.push("about:blank");
}
gBrowser.loadTabs(uris, {
inBackground: true,
triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
});
gBrowser.loadTabs(uris, { inBackground: true });
await BrowserTestUtils.waitForCondition(() => {
return Array.from(gBrowser.tabs).every(tab => tab._fullyOpen);

View File

@@ -210,7 +210,7 @@ function referrerTestCaseLoaded(aTestNumber, aParams) {
"&cross=" + escape(test.cross || "");
let browser = gTestWindow.gBrowser;
return BrowserTestUtils.openNewForegroundTab(browser, () => {
browser.selectedTab = BrowserTestUtils.addTab(browser, url, aParams);
browser.selectedTab = browser.addTab(url, aParams);
}, false, true);
}

View File

@@ -154,10 +154,7 @@ async function doTest(aInsertRelatedAfterCurrent, aInsertAfterCurrent) {
// loadTabs will insertAfterCurrent
let nextTab = aInsertAfterCurrent ? gBrowser.selectedTab._tPos + 1 : gBrowser.tabs.length;
gBrowser.loadTabs(bulkLoad, {
inBackground: true,
triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
});
gBrowser.loadTabs(bulkLoad, { inBackground: true });
await loadPromises;
for (let i = nextTab, j = 0; j < bulkLoad.length; i++, j++) {
is(gBrowser.tabs[i].linkedBrowser.currentURI.spec, bulkLoad[j], `bulkLoad tab pos ${i} matched`);

View File

@@ -21,7 +21,7 @@ function test() {
testState(false);
let pinnedTab = BrowserTestUtils.addTab(gBrowser);
let pinnedTab = gBrowser.addTab();
gBrowser.pinTab(pinnedTab);
// Just pinning the tab shouldn't change the key state.
@@ -45,7 +45,7 @@ function test() {
testState(true);
// Test that accel+w in a pinned tab selects the next tab.
let pinnedTab2 = BrowserTestUtils.addTab(gBrowser);
let pinnedTab2 = gBrowser.addTab();
gBrowser.pinTab(pinnedTab2);
gBrowser.selectedTab = pinnedTab;

View File

@@ -4,10 +4,8 @@
var tabs = [];
function addTab(aURL, done) {
tabs.push(BrowserTestUtils.addTab(gBrowser, aURL, {
skipAnimation: true,
}, done));
function addTab(aURL) {
tabs.push(gBrowser.addTab(aURL, {skipAnimation: true}));
}
function switchTab(index) {
@@ -22,13 +20,10 @@ function testAttrib(tabIndex, attrib, expected) {
add_task(async function setup() {
is(gBrowser.tabs.length, 1, "one tab is open initially");
await new Promise(r => addTab("http://mochi.test:8888/#0", r));
await new Promise(r => addTab("http://mochi.test:8888/#1", r));
await new Promise(r => addTab("http://mochi.test:8888/#2", r));
await new Promise(r => addTab("http://mochi.test:8888/#3", r));
is(gBrowser.tabs.length, 5, "five tabs are open after setup");
EventUtils.synthesizeMouse(tabs[1], 1, 1, {type: "mouseover"});
addTab("http://mochi.test:8888/#0");
addTab("http://mochi.test:8888/#1");
addTab("http://mochi.test:8888/#2");
addTab("http://mochi.test:8888/#3");
});
// Add several new tabs in sequence, hiding some, to ensure that the

View File

@@ -14,7 +14,7 @@ add_task(async function testShieldAnimation() {
await UrlClassifierTestUtils.addTestTrackers();
Services.prefs.setBoolPref(TP_PREF, true);
let tab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
let tab = gBrowser.selectedTab = gBrowser.addTab();
let animationIcon = document.getElementById("tracking-protection-icon-animatable-image");
let noAnimationIcon = document.getElementById("tracking-protection-icon");

View File

@@ -231,7 +231,7 @@ add_task(async function testNormalBrowsing() {
await UrlClassifierTestUtils.addTestTrackers();
tabbrowser = gBrowser;
let tab = tabbrowser.selectedTab = BrowserTestUtils.addTab(tabbrowser);
let tab = tabbrowser.selectedTab = tabbrowser.addTab();
TrackingProtection = gBrowser.ownerGlobal.TrackingProtection;
ok(TrackingProtection, "TP is attached to the browser window");
@@ -252,7 +252,7 @@ add_task(async function testNormalBrowsing() {
add_task(async function testPrivateBrowsing() {
let privateWin = await BrowserTestUtils.openNewBrowserWindow({private: true});
tabbrowser = privateWin.gBrowser;
let tab = tabbrowser.selectedTab = BrowserTestUtils.addTab(tabbrowser);
let tab = tabbrowser.selectedTab = tabbrowser.addTab();
TrackingProtection = tabbrowser.ownerGlobal.TrackingProtection;
ok(TrackingProtection, "TP is attached to the private window");

View File

@@ -67,7 +67,7 @@ var tests = [
function loadTabInWindow(win, callback) {
info("Loading tab");
let url = "http://user:pass@example.com/";
let tab = win.gBrowser.selectedTab = BrowserTestUtils.addTab(win.gBrowser, url);
let tab = win.gBrowser.selectedTab = win.gBrowser.addTab(url);
BrowserTestUtils.browserLoaded(tab.linkedBrowser, false, url).then(() => {
info("Tab loaded");
is(win.gURLBar.textValue, "example.com", "URL bar had user/pass stripped initially");

View File

@@ -162,7 +162,7 @@ function get_test_function_for_localhost_with_hostname(hostName, isPrivate) {
browser.removeTab(tab);
// Now try again with the pref set.
tab = browser.selectedTab = BrowserTestUtils.addTab(browser, "about:blank");
tab = browser.selectedTab = browser.addTab("about:blank");
await BrowserTestUtils.browserLoaded(tab.linkedBrowser);
// In a private window, the notification should appear again.
await runURLBarSearchTest({

View File

@@ -212,9 +212,6 @@ function openWebLinkIn(url, where, params) {
if (!params.triggeringPrincipal) {
params.triggeringPrincipal = Services.scriptSecurityManager.createNullPrincipal({});
}
if (Services.scriptSecurityManager.isSystemPrincipal(params.triggeringPrincipal)) {
throw new Error("System principal should never be passed into openWebLinkIn()");
}
openUILinkIn(url, where, params);
}
@@ -259,8 +256,7 @@ function openUILinkIn(url, where, aAllowThirdPartyFixup, aPostData, aReferrerURI
if (arguments.length == 3 && typeof arguments[2] == "object") {
params = aAllowThirdPartyFixup;
}
if (!params || !params.triggeringPrincipal) {
} else {
throw new Error("Required argument triggeringPrincipal missing within openUILinkIn");
}

View File

@@ -54,11 +54,7 @@ global.tabGetSender = getSender;
extensions.on("uninstalling", (msg, extension) => {
if (extension.uninstallURL) {
let browser = windowTracker.topWindow.gBrowser;
browser.addTab(extension.uninstallURL, {
disallowInheritPrincipal: true,
relatedToCurrent: true,
triggeringPrincipal: extension.principal,
});
browser.addTab(extension.uninstallURL, {relatedToCurrent: true});
}
});

View File

@@ -527,8 +527,18 @@ this.tabs = class extends ExtensionAPI {
}
}).then(window => {
let url;
let principal = context.principal;
if (createProperties.url !== null) {
url = context.uri.resolve(createProperties.url);
if (!context.checkLoadURL(url, {dontReportErrors: true})) {
return Promise.reject({message: `Illegal URL: ${url}`});
}
if (createProperties.openInReaderMode) {
url = `about:reader?url=${encodeURIComponent(url)}`;
}
}
if (createProperties.cookieStoreId && !extension.hasPermission("cookies")) {
return Promise.reject({message: `No permission for cookieStoreId: ${createProperties.cookieStoreId}`});
@@ -559,19 +569,6 @@ this.tabs = class extends ExtensionAPI {
}
}
if (createProperties.url !== null) {
url = context.uri.resolve(createProperties.url);
if (!context.checkLoadURL(url, {dontReportErrors: true})) {
return Promise.reject({message: `Illegal URL: ${url}`});
}
if (createProperties.openInReaderMode) {
url = `about:reader?url=${encodeURIComponent(url)}`;
}
} else {
url = window.BROWSER_NEW_TAB_URL;
}
// Only set disallowInheritPrincipal on non-discardable urls as it
// will override creating a lazy browser. Setting triggeringPrincipal
// will ensure other cases are handled, but setting it may prevent
@@ -581,11 +578,8 @@ this.tabs = class extends ExtensionAPI {
// Make sure things like about:blank and data: URIs never inherit,
// and instead always get a NullPrincipal.
options.disallowInheritPrincipal = true;
// Falling back to codebase here as about: requires it, however is safe.
principal = Services.scriptSecurityManager.createCodebasePrincipal(Services.io.newURI(url), {
userContextId: options.userContextId,
privateBrowsingId: PrivateBrowsingUtils.isBrowserPrivate(window.gBrowser) ? 1 : 0,
});
} else {
options.triggeringPrincipal = context.principal;
}
tabListener.initTabReady();
@@ -624,14 +618,13 @@ this.tabs = class extends ExtensionAPI {
return Promise.reject({message: `Title may only be set for discarded tabs.`});
}
options.triggeringPrincipal = principal;
let nativeTab = window.gBrowser.addTab(url, options);
let nativeTab = window.gBrowser.addTab(url || window.BROWSER_NEW_TAB_URL, options);
if (createProperties.discarded) {
SessionStore.setTabState(nativeTab, {
entries: [{
url: url,
title: options.title,
triggeringPrincipal_base64: Utils.serializePrincipal(principal),
triggeringPrincipal_base64: Utils.serializePrincipal(context.principal),
}],
});
}

View File

@@ -166,7 +166,6 @@ skip-if = !e10s || debug || asan
[browser_ext_tabs_captureVisibleTab.js]
[browser_ext_tabs_create.js]
skip-if = os == "linux" && debug && bits == 32 # Bug 1350189
[browser_ext_tabs_create_url.js]
[browser_ext_tabs_create_invalid_url.js]
[browser_ext_tabs_detectLanguage.js]
[browser_ext_tabs_discard.js]

View File

@@ -175,6 +175,57 @@ add_task(async function test_create_options() {
BrowserTestUtils.removeTab(tab);
});
add_task(async function test_urlbar_focus() {
const extension = ExtensionTestUtils.loadExtension({
background() {
browser.tabs.onUpdated.addListener(function onUpdated(_, info) {
if (info.status === "complete") {
browser.test.sendMessage("complete");
browser.tabs.onUpdated.removeListener(onUpdated);
}
});
browser.test.onMessage.addListener(async (cmd, ...args) => {
const result = await browser.tabs[cmd](...args);
browser.test.sendMessage("result", result);
});
},
});
await extension.startup();
// Test content is focused after opening a regular url
extension.sendMessage("create", {url: "https://example.com"});
const [tab1] = await Promise.all([
extension.awaitMessage("result"),
extension.awaitMessage("complete"),
]);
is(document.activeElement.tagName, "browser", "Content focused after opening a web page");
extension.sendMessage("remove", tab1.id);
await extension.awaitMessage("result");
// Test urlbar is focused after opening an empty tab
extension.sendMessage("create", {});
const tab2 = await extension.awaitMessage("result");
const active = document.activeElement;
info(`Active element: ${active.tagName}, id: ${active.id}, class: ${active.className}`);
const parent = active.parentNode;
info(`Parent element: ${parent.tagName}, id: ${parent.id}, class: ${parent.className}`);
info(`After opening an empty tab, gURLBar.focused: ${gURLBar.focused}`);
is(active.tagName, "html:input", "Input element focused");
ok(active.classList.contains("urlbar-input"), "Urlbar focused");
extension.sendMessage("remove", tab2.id);
await extension.awaitMessage("result");
await extension.unload();
});
add_task(async function test_create_with_popup() {
const extension = ExtensionTestUtils.loadExtension({
async background() {

View File

@@ -1,55 +0,0 @@
/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim: set sts=2 sw=2 et tw=80: */
"use strict";
add_task(async function test_urlbar_focus() {
const extension = ExtensionTestUtils.loadExtension({
background() {
browser.tabs.onUpdated.addListener(function onUpdated(_, info) {
if (info.status === "complete") {
browser.test.sendMessage("complete");
browser.tabs.onUpdated.removeListener(onUpdated);
}
});
browser.test.onMessage.addListener(async (cmd, ...args) => {
const result = await browser.tabs[cmd](...args);
browser.test.sendMessage("result", result);
});
},
});
await extension.startup();
// Test content is focused after opening a regular url
extension.sendMessage("create", {url: "https://example.com"});
const [tab1] = await Promise.all([
extension.awaitMessage("result"),
extension.awaitMessage("complete"),
]);
is(document.activeElement.tagName, "browser", "Content focused after opening a web page");
extension.sendMessage("remove", tab1.id);
await extension.awaitMessage("result");
// Test urlbar is focused after opening an empty tab
extension.sendMessage("create", {});
const tab2 = await extension.awaitMessage("result");
const active = document.activeElement;
info(`Active element: ${active.tagName}, id: ${active.id}, class: ${active.className}`);
const parent = active.parentNode;
info(`Parent element: ${parent.tagName}, id: ${parent.id}, class: ${parent.className}`);
info(`After opening an empty tab, gURLBar.focused: ${gURLBar.focused}`);
is(active.tagName, "html:input", "Input element focused");
ok(active.classList.contains("urlbar-input"), "Urlbar focused");
extension.sendMessage("remove", tab2.id);
await extension.awaitMessage("result");
await extension.unload();
});

View File

@@ -171,9 +171,7 @@ class TestFirefoxRefresh(MarionetteTestCase):
});
let expectedTabs = new Set();
for (let url of expectedURLs) {
expectedTabs.add(gBrowser.addTab(url, {
triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
}));
expectedTabs.add(gBrowser.addTab(url));
}
// Close any other tabs that might be open:
let allTabs = Array.from(gBrowser.tabs);

View File

@@ -2344,7 +2344,7 @@ BrowserGlue.prototype = {
let tabs = win.gBrowser.tabs;
tab = tabs[tabs.length - 1];
} else {
tab = win.gBrowser.addWebTab(URI.uri);
tab = win.gBrowser.addTab(URI.uri);
}
tab.setAttribute("attention", true);
return tab;
@@ -2424,7 +2424,7 @@ BrowserGlue.prototype = {
let tabs = win.gBrowser.tabs;
tab = tabs[tabs.length - 1];
} else {
tab = win.gBrowser.addWebTab(url);
tab = win.gBrowser.addTab(url);
}
tab.setAttribute("attention", true);
let clickCallback = (subject, topic, data) => {
@@ -2457,7 +2457,7 @@ BrowserGlue.prototype = {
if (!win) {
this._openURLInNewWindow(url);
} else {
win.gBrowser.addWebTab(url);
win.gBrowser.addTab(url);
}
};

View File

@@ -9,7 +9,7 @@ add_task(async function testNoSessionRestoreButton() {
(await BrowserTestUtils.openNewBrowserWindow({private: true})).close();
let win = await BrowserTestUtils.openNewBrowserWindow({private: true});
let tab = BrowserTestUtils.addTab(win.gBrowser, "about:sessionrestore");
let tab = win.gBrowser.addTab("about:sessionrestore");
let browser = tab.linkedBrowser;
await BrowserTestUtils.browserLoaded(browser);

View File

@@ -61,7 +61,7 @@ function get_cache_for_private_window() {
ok(true, "The private window got loaded");
let tab = BrowserTestUtils.addTab(win.gBrowser, "http://example.org");
let tab = win.gBrowser.addTab("http://example.org");
win.gBrowser.selectedTab = tab;
let newTabBrowser = win.gBrowser.getBrowserForTab(tab);

View File

@@ -159,7 +159,7 @@ async function assignCookies(aBrowser, aURL, aCookieValue) {
}
async function openTab(aBrowser, aURL) {
let tab = BrowserTestUtils.addTab(aBrowser, aURL);
let tab = aBrowser.addTab(aURL);
// Select tab and make sure its browser is focused.
aBrowser.selectedTab = tab;

View File

@@ -11,7 +11,7 @@ add_task(async function test() {
function checkGeolocation(aPrivateMode, aWindow) {
return (async function() {
aWindow.gBrowser.selectedTab = BrowserTestUtils.addTab(aWindow.gBrowser, testPageURL);
aWindow.gBrowser.selectedTab = aWindow.gBrowser.addTab(testPageURL);
await BrowserTestUtils.browserLoaded(aWindow.gBrowser.selectedBrowser);
let notification = aWindow.PopupNotifications.getNotification("geolocation");

View File

@@ -9,7 +9,7 @@
let win = await BrowserTestUtils.openNewBrowserWindow({private: true});
win.gBrowser.selectedTab = BrowserTestUtils.addTab(win.gBrowser, page1);
win.gBrowser.selectedTab = win.gBrowser.addTab(page1);
let browser = win.gBrowser.selectedBrowser;
await BrowserTestUtils.browserLoaded(browser);

View File

@@ -15,7 +15,7 @@ add_task(async function test() {
// Step 1.
let privateWin = await BrowserTestUtils.openNewBrowserWindow({private: true});
let privateBrowser = BrowserTestUtils.addTab(privateWin.gBrowser,
let privateBrowser = privateWin.gBrowser.addTab(
prefix + "browser_privatebrowsing_localStorage_before_after_page.html").linkedBrowser;
await BrowserTestUtils.browserLoaded(privateBrowser);
@@ -23,7 +23,7 @@ add_task(async function test() {
// Step 2.
let win = await BrowserTestUtils.openNewBrowserWindow();
let browser = BrowserTestUtils.addTab(win.gBrowser,
let browser = win.gBrowser.addTab(
prefix + "browser_privatebrowsing_localStorage_before_after_page2.html").linkedBrowser;
await BrowserTestUtils.browserLoaded(browser);

View File

@@ -8,7 +8,7 @@
add_task(async function test_no_session_restore_menu_option() {
let win = await BrowserTestUtils.openNewBrowserWindow({ private: true });
ok(true, "The first private window got loaded");
BrowserTestUtils.addTab(win.gBrowser, "about:mozilla");
win.gBrowser.addTab("about:mozilla");
await BrowserTestUtils.closeWindow(win);
win = await BrowserTestUtils.openNewBrowserWindow({ private: true });

View File

@@ -12,7 +12,7 @@ add_task(async function test() {
"browser/components/privatebrowsing/test/browser/browser_privatebrowsing_protocolhandler_page.html";
let doTest = async function(aIsPrivateMode, aWindow) {
let tab = aWindow.gBrowser.selectedTab = BrowserTestUtils.addTab(aWindow.gBrowser, testURI);
let tab = aWindow.gBrowser.selectedTab = aWindow.gBrowser.addTab(testURI);
await BrowserTestUtils.browserLoaded(tab.linkedBrowser);
let promiseFinished = PromiseUtils.defer();

View File

@@ -27,7 +27,7 @@ function testWhitelistedPage(window) {
add_task(async function testNormalBrowsing() {
tabbrowser = gBrowser;
let tab = tabbrowser.selectedTab = BrowserTestUtils.addTab(tabbrowser);
let tab = tabbrowser.selectedTab = tabbrowser.addTab();
info("Load a test page that's whitelisted");
Services.prefs.setCharPref(PREF_WHITELISTED_HOSTNAMES, "example.com,www.ItIsaTrap.org,example.net");

View File

@@ -33,8 +33,8 @@ add_task(async function test() {
container.addEventListener("TabOpen", tabAdded);
BrowserTestUtils.addTab(gBrowser, "about:blank");
BrowserSearch.loadSearchFromContext("mozilla", Services.scriptSecurityManager.getSystemPrincipal());
BrowserSearch.loadSearchFromContext("firefox", Services.scriptSecurityManager.getSystemPrincipal());
BrowserSearch.loadSearchFromContext("mozilla");
BrowserSearch.loadSearchFromContext("firefox");
// Wait for all the tabs to open.
await tabsLoadedDeferred.promise;

View File

@@ -93,7 +93,7 @@ async function testSearchEngine(engineDetails) {
run() {
// Simulate a contextmenu search
// FIXME: This is a bit "low-level"...
BrowserSearch._loadSearch("foo", false, "contextmenu", Services.scriptSecurityManager.getSystemPrincipal());
BrowserSearch.loadSearch("foo", false, "contextmenu");
}
},
{

View File

@@ -111,7 +111,7 @@ async function testSearchEngine(engineDetails) {
run() {
// Simulate a contextmenu search
// FIXME: This is a bit "low-level"...
BrowserSearch._loadSearch("foo", false, "contextmenu", Services.scriptSecurityManager.getSystemPrincipal());
BrowserSearch.loadSearch("foo", false, "contextmenu");
}
},
{

View File

@@ -2431,12 +2431,9 @@ var SessionStoreInternal = {
// Create a new tab.
let userContextId = aTab.getAttribute("usercontextid");
let tabOptions = {
userContextId,
...(aTab == aWindow.gBrowser.selectedTab ? {relatedToCurrent: true, ownerTab: aTab} : {})
};
let newTab = aWindow.gBrowser.addTrustedTab(null, tabOptions);
let newTab = aTab == aWindow.gBrowser.selectedTab ?
aWindow.gBrowser.addTab(null, {relatedToCurrent: true, ownerTab: aTab, userContextId}) :
aWindow.gBrowser.addTab(null, {userContextId});
// Start the throbber to pretend we're doing something while actually
// waiting for data from the frame script.
@@ -2525,7 +2522,7 @@ var SessionStoreInternal = {
// create a new tab
let tabbrowser = aWindow.gBrowser;
let tab = tabbrowser.selectedTab =
tabbrowser.addTrustedTab(null, {
tabbrowser.addTab(null, {
index: pos,
pinned: state.pinned,
userContextId: state.userContextId,
@@ -3495,7 +3492,7 @@ var SessionStoreInternal = {
// Setting noInitialLabel is a perf optimization. Rendering tab labels
// would make resizing the tabs more expensive as we're adding them.
// Each tab will get its initial label set in restoreTab.
tab = tabbrowser.addTrustedTab(url,
tab = tabbrowser.addTab(url,
{ createLazyBrowser,
skipAnimation: true,
noInitialLabel: true,

View File

@@ -264,7 +264,7 @@ function toggleRowChecked(aIx) {
function restoreSingleTab(aIx, aShifted) {
var tabbrowser = getBrowserWindow().gBrowser;
var newTab = tabbrowser.addWebTab();
var newTab = tabbrowser.addTab();
var item = gTreeData[aIx];
var tabState = gStateObject.windows[item.parent.ix]

View File

@@ -163,7 +163,7 @@ let setupTest = async function(options, testFunction) {
* The browser window to load the tabs in
*/
function injectTestTabs(win) {
let promises = TEST_URLS.map(url => BrowserTestUtils.addTab(win.gBrowser, url))
let promises = TEST_URLS.map(url => win.gBrowser.addTab(url))
.map(tab => BrowserTestUtils.browserLoaded(tab.linkedBrowser));
return Promise.all(promises);
}
@@ -313,7 +313,7 @@ add_task(async function test_open_close_window_and_popup() {
openDialog(location, "popup2", POPUP_FEATURES, TEST_URLS[1]);
let popup2 = await popup2Promise;
BrowserTestUtils.addTab(popup2.gBrowser, TEST_URLS[0]);
popup2.gBrowser.addTab(TEST_URLS[0]);
let closed = await closeWindowForRestoration(newWin);
ok(closed, "Should be able to close the window");
@@ -378,7 +378,7 @@ add_task(async function test_open_close_only_popup() {
openDialog(location, "popup", POPUP_FEATURES, TEST_URLS[1]);
popup = await popupPromise;
BrowserTestUtils.addTab(popup.gBrowser, TEST_URLS[0]);
popup.gBrowser.addTab(TEST_URLS[0]);
is(popup.gBrowser.browsers.length, 2,
"Did not restore to the popup window (2)");

View File

@@ -25,7 +25,7 @@ add_task(async function new_window() {
let newWin;
try {
newWin = await promiseNewWindowLoaded();
let tab = BrowserTestUtils.addTab(newWin.gBrowser, "http://example.com/browser_625016.js?" + Math.random());
let tab = newWin.gBrowser.addTab("http://example.com/browser_625016.js?" + Math.random());
await promiseBrowserLoaded(tab.linkedBrowser);
// Double check that we have no closed windows

View File

@@ -113,7 +113,7 @@ add_task(async function test_3() {
});
async function promiseTabLoad(win, url) {
let tab = BrowserTestUtils.addTab(win.gBrowser, url);
let tab = win.gBrowser.addTab(url);
await promiseBrowserLoaded(tab.linkedBrowser);
await TabStateFlusher.flush(tab.linkedBrowser);
}

View File

@@ -116,7 +116,7 @@ function promiseNewWindow() {
}
async function createTabWithStorageData(urls, win = window) {
let tab = BrowserTestUtils.addTab(win.gBrowser);
let tab = win.gBrowser.addTab();
let browser = tab.linkedBrowser;
for (let url of urls) {

View File

@@ -50,7 +50,7 @@ add_task(async function test_open_and_close() {
await promiseBrowserLoaded(newTab2.linkedBrowser);
let newWin = await promiseNewWindowLoaded();
let tab = BrowserTestUtils.addTab(newWin.gBrowser, URL_NEWWIN);
let tab = newWin.gBrowser.addTab(URL_NEWWIN);
await promiseBrowserLoaded(tab.linkedBrowser);

View File

@@ -300,7 +300,7 @@ add_task(async function test_revive_all_tabs_from_session_store() {
// a second window, since only selected tabs will show
// about:tabcrashed.
let win2 = await BrowserTestUtils.openNewBrowserWindow();
let newTab2 = BrowserTestUtils.addTab(win2.gBrowser, PAGE_1, { sameProcessAsFrameLoader: browser.frameLoader });
let newTab2 = win2.gBrowser.addTab(PAGE_1, { sameProcessAsFrameLoader: browser.frameLoader });
win2.gBrowser.selectedTab = newTab2;
let browser2 = newTab2.linkedBrowser;
ok(browser2.isRemoteBrowser, "Should be a remote browser");
@@ -407,7 +407,7 @@ add_task(async function test_hide_restore_all_button() {
// Load up a second window so we can get another tab to show
// about:tabcrashed
let win2 = await BrowserTestUtils.openNewBrowserWindow();
let newTab3 = BrowserTestUtils.addTab(win2.gBrowser, PAGE_2, { sameProcessAsFrameLoader: browser.frameLoader });
let newTab3 = win2.gBrowser.addTab(PAGE_2, { sameProcessAsFrameLoader: browser.frameLoader });
win2.gBrowser.selectedTab = newTab3;
let otherWinBrowser = newTab3.linkedBrowser;
await promiseBrowserLoaded(otherWinBrowser);

View File

@@ -16,7 +16,7 @@ add_task(async function test() {
await promiseBrowserLoaded(win.gBrowser.selectedBrowser);
// Open a second tab and close the first one.
let tab = BrowserTestUtils.addTab(win.gBrowser, "about:mozilla");
let tab = win.gBrowser.addTab("about:mozilla");
await promiseBrowserLoaded(tab.linkedBrowser);
await TabStateFlusher.flush(tab.linkedBrowser);
await promiseRemoveTabAndSessionState(win.gBrowser.tabs[0]);

View File

@@ -72,7 +72,7 @@ add_task(async function() {
mm.loadFrameScript(FRAME_SCRIPT, true);
// Create a new tab in the new window that will load the frame script.
let tab = BrowserTestUtils.addTab(win.gBrowser, "about:mozilla");
let tab = win.gBrowser.addTab("about:mozilla");
let browser = tab.linkedBrowser;
await promiseBrowserLoaded(browser);
await TabStateFlusher.flush(browser);
@@ -86,7 +86,7 @@ add_task(async function() {
is(ss.getClosedTabCount(win), 0, "no tabs to restore");
// Create a new tab in the new window that will load the frame script.
tab = BrowserTestUtils.addTab(win.gBrowser, "about:mozilla");
tab = win.gBrowser.addTab("about:mozilla");
browser = tab.linkedBrowser;
await promiseBrowserLoaded(browser);
await TabStateFlusher.flush(browser);
@@ -109,7 +109,7 @@ add_task(async function() {
let win = await promiseNewWindowLoaded({private: true});
// Create a new tab in the new window that will load the frame script.
let tab = BrowserTestUtils.addTab(win.gBrowser, "about:mozilla");
let tab = win.gBrowser.addTab("about:mozilla");
let browser = tab.linkedBrowser;
await promiseBrowserLoaded(browser);
await TabStateFlusher.flush(browser);

View File

@@ -116,7 +116,7 @@ add_task(async function test_scroll_background_tabs() {
pushPrefs(["browser.sessionstore.restore_on_demand", true]);
let newWin = await BrowserTestUtils.openNewBrowserWindow();
let tab = BrowserTestUtils.addTab(newWin.gBrowser, URL);
let tab = newWin.gBrowser.addTab(URL);
let browser = tab.linkedBrowser;
await BrowserTestUtils.browserLoaded(browser);

View File

@@ -21,7 +21,7 @@ add_task(async function test_scroll_background_about_reader_tabs() {
pushPrefs(["browser.sessionstore.restore_on_demand", true]);
let newWin = await BrowserTestUtils.openNewBrowserWindow();
let tab = BrowserTestUtils.addTab(newWin.gBrowser, READER_MODE_URL);
let tab = newWin.gBrowser.addTab(READER_MODE_URL);
let browser = tab.linkedBrowser;
await Promise.all([
BrowserTestUtils.browserLoaded(browser),

View File

@@ -16,7 +16,7 @@ add_task(async function() {
let win = await promiseNewWindowLoaded();
// Add a new tab.
let tab = BrowserTestUtils.addTab(win.gBrowser, "about:blank");
let tab = win.gBrowser.addTab("about:blank");
let browser = tab.linkedBrowser;
await promiseBrowserLoaded(browser);
ok(browser.isRemoteBrowser, "browser is remote");

View File

@@ -8,7 +8,7 @@
ChromeUtils.import("resource:///modules/sessionstore/SessionStore.jsm");
async function openAndCloseTab(window, url) {
let tab = BrowserTestUtils.addTab(window.gBrowser, url);
let tab = window.gBrowser.addTab(url);
await promiseBrowserLoaded(tab.linkedBrowser, true, url);
await TabStateFlusher.flush(tab.linkedBrowser);
await promiseRemoveTabAndSessionState(tab);

View File

@@ -13,9 +13,7 @@ add_task(async function() {
// Create 4 tabs with different userContextId.
for (let userContextId = 1; userContextId < 5; userContextId++) {
let tab = BrowserTestUtils.addTab(win.gBrowser, "http://example.com/", {
userContextId,
});
let tab = win.gBrowser.addTab("http://example.com/", {userContextId});
await promiseBrowserLoaded(tab.linkedBrowser);
await TabStateFlusher.flush(tab.linkedBrowser);
}
@@ -38,9 +36,7 @@ add_task(async function() {
// Create tabs with different userContextId, but this time we create them with
// fewer tabs and with different order with win.
for (let userContextId = 3; userContextId > 0; userContextId--) {
let tab = BrowserTestUtils.addTab(win2.gBrowser, "http://example.com/", {
userContextId,
});
let tab = win2.gBrowser.addTab("http://example.com/", {userContextId});
await promiseBrowserLoaded(tab.linkedBrowser);
await TabStateFlusher.flush(tab.linkedBrowser);
}
@@ -80,9 +76,7 @@ add_task(async function() {
let win = await BrowserTestUtils.openNewBrowserWindow();
await TabStateFlusher.flush(win.gBrowser.selectedBrowser);
let tab = BrowserTestUtils.addTab(win.gBrowser, "http://example.com/", {
userContextId: 1,
});
let tab = win.gBrowser.addTab("http://example.com/", { userContextId: 1 });
await promiseBrowserLoaded(tab.linkedBrowser);
await TabStateFlusher.flush(tab.linkedBrowser);
@@ -98,9 +92,7 @@ add_task(async function() {
let win2 = await BrowserTestUtils.openNewBrowserWindow();
let tab2 = BrowserTestUtils.addTab(win2.gBrowser, "http://example.com/", {
userContextId: 1,
});
let tab2 = win2.gBrowser.addTab("http://example.com/", { userContextId: 1 });
await promiseBrowserLoaded(tab2.linkedBrowser);
await TabStateFlusher.flush(tab2.linkedBrowser);

View File

@@ -71,7 +71,7 @@ var { helpers, assert } = (function () {
options.isFirefox = true;
var tabbrowser = options.chromeWindow.gBrowser;
options.tab = BrowserTestUtils.addTab(tabbrowser);
options.tab = tabbrowser.addTab();
tabbrowser.selectedTab = options.tab;
options.browser = tabbrowser.getBrowserForTab(options.tab);
options.target = TargetFactory.forTab(options.tab);
@@ -117,7 +117,7 @@ var { helpers, assert } = (function () {
options.isFirefox = true;
var tabbrowser = options.chromeWindow.gBrowser;
options.tab = BrowserTestUtils.addTab(tabbrowser);
options.tab = tabbrowser.addTab();
tabbrowser.selectedTab = options.tab;
options.browser = tabbrowser.getBrowserForTab(options.tab);
options.target = TargetFactory.forTab(options.tab);

View File

@@ -88,7 +88,7 @@ this.addTab = function addTab(aUrl, aWindow) {
let targetBrowser = targetWindow.gBrowser;
targetWindow.focus();
let tab = targetBrowser.selectedTab = BrowserTestUtils.addTab(targetBrowser, aUrl);
let tab = targetBrowser.selectedTab = targetBrowser.addTab(aUrl);
let linkedBrowser = tab.linkedBrowser;
info("Loading frame script with url " + FRAME_SCRIPT_URL + ".");

View File

@@ -285,7 +285,7 @@ var gDevToolsBrowser = exports.gDevToolsBrowser = {
// Used by browser-sets.inc, command
openAboutDebugging(gBrowser, hash) {
const url = "about:debugging" + (hash ? "#" + hash : "");
gBrowser.selectedTab = gBrowser.addTrustedTab(url);
gBrowser.selectedTab = gBrowser.addTab(url);
},
/**
@@ -293,7 +293,7 @@ var gDevToolsBrowser = exports.gDevToolsBrowser = {
*/
// Used by browser-sets.inc, command
openConnectScreen(gBrowser) {
gBrowser.selectedTab = gBrowser.addTrustedTab("chrome://devtools/content/framework/connect/connect.xhtml");
gBrowser.selectedTab = gBrowser.addTab("chrome://devtools/content/framework/connect/connect.xhtml");
},
/**

View File

@@ -33,15 +33,8 @@ function openRequestInTab(url, requestPostData) {
postData.addHeader("Content-Type", "application/x-www-form-urlencoded");
postData.setData(stringStream);
}
const userContextId = win.gBrowser.contentPrincipal.userContextId;
win.gBrowser.selectedTab = win.gBrowser.addWebTab(url, {
// TODO this should be using the original request principal
triggeringPrincipal: Services.scriptSecurityManager.createNullPrincipal({
userContextId,
}),
userContextId,
postData,
});
win.gBrowser.selectedTab = win.gBrowser.addTab(url, { postData });
}
function getInputStreamFromString(data) {

View File

@@ -28,11 +28,7 @@ function receiveProfile(profile) {
const browser = win.gBrowser;
Services.focus.activeWindow = win;
const tab = browser.addWebTab("https://perf-html.io/from-addon", {
triggeringPrincipal: Services.scriptSecurityManager.createNullPrincipal({
userContextId: browser.contentPrincipal.userContextId,
})
});
const tab = browser.addTab("https://perf-html.io/from-addon");
browser.selectedTab = tab;
const mm = tab.linkedBrowser.messageManager;
mm.loadFrameScript(

View File

@@ -7,7 +7,6 @@
const { Ci } = require("chrome");
const { E10SUtils } = require("resource://gre/modules/E10SUtils.jsm");
const { tunnelToInnerBrowser } = require("./tunnel");
const Services = require("Services");
function debug(msg) {
// console.log(`RDM swap: ${msg}`);
@@ -59,10 +58,7 @@ function swapToInnerBrowser({ tab, containerURL, getInnerBrowser }) {
browserWindow.addEventListener("TabOpen", event => {
event.stopImmediatePropagation();
}, { capture: true, once: true });
options.triggeringPrincipal = Services.scriptSecurityManager.createNullPrincipal({
userContextId: options.userContextId,
});
return gBrowser.addWebTab(uri, options);
return gBrowser.addTab(uri, options);
};
// A version of `gBrowser.swapBrowsersAndCloseOther` that absorbs the `TabClose` event.

View File

@@ -28,7 +28,7 @@ var addTab = function(url, win) {
const targetWindow = win || window;
const targetBrowser = targetWindow.gBrowser;
const tab = targetBrowser.selectedTab = BrowserTestUtils.addTab(targetBrowser, url);
const tab = targetBrowser.selectedTab = targetBrowser.addTab(url);
BrowserTestUtils.browserLoaded(targetBrowser.selectedBrowser)
.then(function() {
info("URL '" + url + "' loading complete");

View File

@@ -31,7 +31,7 @@ add_task(async function() {
const privateWindow = await openNewBrowserWindow({ private: true });
ok(PrivateBrowsingUtils.isWindowPrivate(privateWindow), "window is private");
const privateBrowser = privateWindow.gBrowser;
privateBrowser.selectedTab = BrowserTestUtils.addTab(privateBrowser, PRIVATE_TEST_URI);
privateBrowser.selectedTab = privateBrowser.addTab(PRIVATE_TEST_URI);
const privateTab = privateBrowser.selectedTab;
info("private tab opened");

View File

@@ -691,7 +691,7 @@ DevToolsStartup.prototype = {
}
// Set relatedToCurrent: true to open the tab next to the current one.
gBrowser.selectedTab = gBrowser.addTrustedTab(url, {relatedToCurrent: true});
gBrowser.selectedTab = gBrowser.addTab(url, {relatedToCurrent: true});
},
handleConsoleFlag: function(cmdLine) {

View File

@@ -34,8 +34,7 @@ add_task(async function() {
await waitForDelayedStartupFinished(win);
info("Open a new tab on the new window to ensure the focus is on the new window");
const tab = BrowserTestUtils.addTab(win.gBrowser,
"data:text/html;charset=utf-8,<title>foo</title>");
const tab = win.gBrowser.addTab("data:text/html;charset=utf-8,<title>foo</title>");
await BrowserTestUtils.browserLoaded(win.gBrowser.getBrowserForTab(tab));
info("Synthesize a DevTools shortcut, the toolbox should not open on this new window.");

View File

@@ -953,7 +953,6 @@ nsDocShell::LoadURI(nsIURI* aURI,
uint32_t flags = 0;
if (inheritPrincipal) {
MOZ_ASSERT(!nsContentUtils::IsSystemPrincipal(principalToInherit), "Should not inherit SystemPrincipal");
flags |= INTERNAL_LOAD_FLAGS_INHERIT_PRINCIPAL;
}

View File

@@ -48,8 +48,7 @@ function timelineTestOpenUrl(url) {
});
let loadPromise = new Promise(function(resolve, reject) {
let browser = window.gBrowser;
let tab = browser.selectedTab = BrowserTestUtils.addTab(browser, url);
let tab = window.gBrowser.selectedTab = window.gBrowser.addTab(url);
let linkedBrowser = tab.linkedBrowser;
BrowserTestUtils.browserLoaded(linkedBrowser).then(() => resolve(tab));

View File

@@ -4,7 +4,7 @@ const TEST_URI = getRootDirectory(gTestPath).replace("chrome://mochitests/conten
* Loading an image from https:// should work.
*/
add_task(async function load_image_from_https_test() {
let tab = BrowserTestUtils.addTab(gBrowser, TEST_URI);
let tab = gBrowser.addTab(TEST_URI);
await BrowserTestUtils.browserLoaded(tab.linkedBrowser);
gBrowser.selectedTab = tab;
@@ -38,7 +38,7 @@ add_task(async function load_image_from_https_test() {
* Loading an image from http:// should be rejected.
*/
add_task(async function load_image_from_http_test() {
let tab = BrowserTestUtils.addTab(gBrowser, TEST_URI);
let tab = gBrowser.addTab(TEST_URI);
await BrowserTestUtils.browserLoaded(tab.linkedBrowser);
gBrowser.selectedTab = tab;
@@ -74,7 +74,7 @@ add_task(async function load_image_from_http_test() {
* The load from https:// should be replaced.
*/
add_task(async function load_https_and_http_test() {
let tab = BrowserTestUtils.addTab(gBrowser, TEST_URI);
let tab = gBrowser.addTab(TEST_URI);
await BrowserTestUtils.browserLoaded(tab.linkedBrowser);
// Clear image cache, otherwise in non-e10s mode the image might be cached by
@@ -121,7 +121,7 @@ add_task(async function load_https_and_http_test() {
* the imageBlockingStatus value.
*/
add_task(async function block_pending_request_test() {
let tab = BrowserTestUtils.addTab(gBrowser, TEST_URI);
let tab = gBrowser.addTab(TEST_URI);
await BrowserTestUtils.browserLoaded(tab.linkedBrowser);
gBrowser.selectedTab = tab;

View File

@@ -20,11 +20,11 @@ add_task(async function() {
});
await win2Promise;
var tab1 = BrowserTestUtils.addTab(win1.gBrowser, URL);
var tab1 = win1.gBrowser.addTab(URL);
await BrowserTestUtils.browserLoaded(win1.gBrowser.getBrowserForTab(tab1));
var browser1 = gBrowser.getBrowserForTab(tab1);
var tab2 = BrowserTestUtils.addTab(win2.gBrowser, URL);
var tab2 = win2.gBrowser.addTab(URL);
await BrowserTestUtils.browserLoaded(win2.gBrowser.getBrowserForTab(tab2));
var browser2 = gBrowser.getBrowserForTab(tab2);

View File

@@ -103,7 +103,7 @@ function test() {
return BrowserTestUtils.openNewBrowserWindow({private: true});
}).then(pw => {
privateWin = pw;
privateTab = BrowserTestUtils.addTab(pw.gBrowser, "http://example.com/");
privateTab = pw.gBrowser.addTab("http://example.com/");
return BrowserTestUtils.browserLoaded(privateTab.linkedBrowser);
}).then(tab => {
return Promise.all([

View File

@@ -43,7 +43,7 @@ function runPass(getterFile, finishedCallback) {
function afterPrivateWindowOpened() {
// In the private window, open the getter file, and wait for a new tab to be opened.
privateWin.gBrowser.selectedTab = BrowserTestUtils.addTab(privateWin.gBrowser, rootDir + getterFile);
privateWin.gBrowser.selectedTab = privateWin.gBrowser.addTab(rootDir + getterFile);
testBrowser = privateWin.gBrowser.selectedBrowser;
privateWin.gBrowser.tabContainer.addEventListener("TabOpen", onNewTabOpened, true);
}
@@ -77,7 +77,7 @@ function runPass(getterFile, finishedCallback) {
function afterPrivateWindowOpened2() {
// In the private window, open the setter file, and wait for it to load.
privateWin.gBrowser.selectedTab = BrowserTestUtils.addTab(privateWin.gBrowser, rootDir + "file_bug1108547-1.html");
privateWin.gBrowser.selectedTab = privateWin.gBrowser.addTab(rootDir + "file_bug1108547-1.html");
BrowserTestUtils.browserLoaded(privateWin.gBrowser.selectedBrowser).then(afterOpenCookieSetter2);
}

View File

@@ -49,7 +49,7 @@ add_task(async function test2() {
}, win);
info("creating private tab");
win.gBrowser.selectedTab = BrowserTestUtils.addTab(win.gBrowser);
win.gBrowser.selectedTab = win.gBrowser.addTab();
info("loading test page: " + testPageURL);
win.gBrowser.selectedBrowser.loadURI(testPageURL);

View File

@@ -26,7 +26,7 @@ add_task(async function test2() {
let win = await BrowserTestUtils.openNewBrowserWindow({ private: true });
info("creating tab");
win.gBrowser.selectedTab = BrowserTestUtils.addTab(win.gBrowser);
win.gBrowser.selectedTab = win.gBrowser.addTab();
win.gBrowser.selectedBrowser.loadURI(testPageURL);
await waitForMessage("InvalidStateError", win.gBrowser);
win.gBrowser.removeCurrentTab();

View File

@@ -22,7 +22,7 @@ add_task(async function testPermissionUnknownInPrivateWindow() {
}, win);
info("Creating private tab");
win.gBrowser.selectedTab = BrowserTestUtils.addTab(win.gBrowser);
win.gBrowser.selectedTab = win.gBrowser.addTab();
info("Loading test page: " + testPageURL);
win.gBrowser.selectedBrowser.loadURI(testPageURL);

View File

@@ -15,11 +15,11 @@ add_task(async function() {
var URL = "http://mochi.test:8888/browser/dom/tests/browser/page_privatestorageevent.html";
var privTab = BrowserTestUtils.addTab(privWin.gBrowser, URL);
var privTab = privWin.gBrowser.addTab(URL);
await BrowserTestUtils.browserLoaded(privWin.gBrowser.getBrowserForTab(privTab));
var privBrowser = gBrowser.getBrowserForTab(privTab);
var pubTab = BrowserTestUtils.addTab(pubWin.gBrowser, URL);
var pubTab = pubWin.gBrowser.addTab(URL);
await BrowserTestUtils.browserLoaded(pubWin.gBrowser.getBrowserForTab(pubTab));
var pubBrowser = gBrowser.getBrowserForTab(pubTab);

View File

@@ -420,8 +420,7 @@ async function largeAllocSuccessTests() {
let newWindow = await BrowserTestUtils.openNewBrowserWindow();
newWindow.gBrowser.adoptTab(gBrowser.getTabForBrowser(aBrowser), 0, null,
Services.scriptSecurityManager.getSystemPrincipal());
newWindow.gBrowser.adoptTab(gBrowser.getTabForBrowser(aBrowser), 0);
let newTab = newWindow.gBrowser.tabs[0];
is(newTab.linkedBrowser.currentURI.spec, TEST_URI);

View File

@@ -1187,8 +1187,6 @@ var BrowserApp = {
if ("userRequested" in aParams) tab.userRequested = aParams.userRequested;
tab.isSearch = ("isSearch" in aParams) ? aParams.isSearch : false;
}
// Don't fall back to System here Bug 1474619
let triggeringPrincipal = "triggeringPrincipal" in aParams ? aParams.triggeringPrincipal : Services.scriptSecurityManager.getSystemPrincipal();
try {
aBrowser.loadURI(aURI, {
@@ -1196,7 +1194,6 @@ var BrowserApp = {
referrerURI,
charset,
postData,
triggeringPrincipal,
});
} catch(e) {
if (tab) {

View File

@@ -247,7 +247,6 @@ this.tabs = class extends ExtensionAPI {
}).api(),
async create(createProperties) {
let principal = context.principal;
let window = createProperties.windowId !== null ?
windowTracker.getWindow(createProperties.windowId, context) :
windowTracker.topWindow;
@@ -261,9 +260,6 @@ this.tabs = class extends ExtensionAPI {
if (!context.checkLoadURL(url, {dontReportErrors: true})) {
return Promise.reject({message: `Illegal URL: ${url}`});
}
} else {
// Falling back to system here as about:newtab requires it, however is safe.
principal = Services.scriptSecurityManager.getSystemPrincipal();
}
let options = {};
@@ -289,7 +285,6 @@ this.tabs = class extends ExtensionAPI {
options.parentId = BrowserApp.selectedTab.id;
tabListener.initTabReady();
options.triggeringPrincipal = principal;
let nativeTab = BrowserApp.addTab(url, options);
if (createProperties.url) {

View File

@@ -196,7 +196,7 @@ var BrowserTestUtils = {
opening();
tab = tabbrowser.selectedTab;
} else {
tabbrowser.selectedTab = tab = BrowserTestUtils.addTab(tabbrowser, opening);
tabbrowser.selectedTab = tab = tabbrowser.addTab(opening);
}
})
];

View File

@@ -95,8 +95,7 @@ function loadMochitest(e) {
win.removeEventListener("mochitest-load", loadMochitest);
// for mochitest-plain, navigating to the url is all we need
win.loadURI(url, null, null, null, null, null, null, null,
Services.scriptSecurityManager.getSystemPrincipal());
win.loadURI(url);
if (flavor == "mochitest") {
return;
}

View File

@@ -576,10 +576,7 @@ Tester.prototype = {
// Replace the last tab with a fresh one
if (window.gBrowser) {
gBrowser.addTab("about:blank", {
skipAnimation: true,
triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
});
gBrowser.addTab("about:blank", { skipAnimation: true });
gBrowser.removeTab(gBrowser.selectedTab, { skipPermitUnload: true });
gBrowser.stop();
}

View File

@@ -18,7 +18,7 @@ add_task(async function test_support_tab_separators() {
info("Checking background tab separator color");
let tab = BrowserTestUtils.addTab(gBrowser, "about:blank");
let tab = gBrowser.addTab("about:blank");
Assert.equal(window.getComputedStyle(tab, "::before").borderLeftColor,
`rgb(${hexToRGB(TAB_SEPARATOR_COLOR).join(", ")})`,

View File

@@ -346,10 +346,7 @@ var Heartbeat = class {
this.options.postAnswerUrl.searchParams.append(key, engagementParams[key]);
}
// Open the engagement URL in a new tab.
let { gBrowser} = this.chromeWindow;
gBrowser.selectedTab = gBrowser.addWebTab(this.options.postAnswerUrl.toString(), {
triggeringPrincipal: Services.scriptSecurityManager.createNullPrincipal({}),
});
this.chromeWindow.gBrowser.selectedTab = this.chromeWindow.gBrowser.addTab(this.options.postAnswerUrl.toString());
}
this.endTimerIfPresent("surveyEndTimer");

View File

@@ -38,7 +38,7 @@ add_task(async function setup_test_preference() {
add_task(async function block_autoplay_media() {
info("- open new background tab1 -");
let tab1 = BrowserTestUtils.addTab(window.gBrowser, "about:blank");
let tab1 = window.gBrowser.addTab("about:blank");
tab1.linkedBrowser.loadURI(PAGE);
await BrowserTestUtils.browserLoaded(tab1.linkedBrowser);
@@ -46,7 +46,7 @@ add_task(async function block_autoplay_media() {
await check_audio_suspended(tab1.linkedBrowser, SuspendedType.SUSPENDED_BLOCK);
info("- open new background tab2 -");
let tab2 = BrowserTestUtils.addTab(window.gBrowser, "about:blank");
let tab2 = window.gBrowser.addTab("about:blank");
tab2.linkedBrowser.loadURI(PAGE);
await BrowserTestUtils.browserLoaded(tab2.linkedBrowser);
@@ -90,7 +90,7 @@ add_task(async function block_autoplay_media() {
]});
info("- open new background tab4 -");
let tab4 = BrowserTestUtils.addTab(window.gBrowser, "about:blank");
let tab4 = window.gBrowser.addTab("about:blank");
tab4.linkedBrowser.loadURI(PAGE);
await BrowserTestUtils.browserLoaded(tab4.linkedBrowser);
info("- should block autoplay for non-visited tab4 -");

View File

@@ -37,7 +37,7 @@ add_task(async function setup_test_preference() {
add_task(async function block_autoplay_media() {
info("- open new background tab1, and check tab1's media suspend type -");
let tab1 = BrowserTestUtils.addTab(window.gBrowser, "about:blank");
let tab1 = window.gBrowser.addTab("about:blank");
tab1.linkedBrowser.loadURI(PAGE_SHOULD_NOT_PLAY);
await BrowserTestUtils.browserLoaded(tab1.linkedBrowser);
await ContentTask.spawn(tab1.linkedBrowser, SuspendedType.NONE_SUSPENDED,
@@ -47,7 +47,7 @@ add_task(async function block_autoplay_media() {
await waitForTabBlockEvent(tab1, false);
info("- open new background tab2, and check tab2's media suspend type -");
let tab2 = BrowserTestUtils.addTab(window.gBrowser, "about:blank");
let tab2 = window.gBrowser.addTab("about:blank");
tab2.linkedBrowser.loadURI(PAGE_SHOULD_PLAY);
await BrowserTestUtils.browserLoaded(tab2.linkedBrowser);
await ContentTask.spawn(tab2.linkedBrowser, SuspendedType.SUSPENDED_BLOCK,

View File

@@ -58,7 +58,7 @@ add_task(async function setup_test_preference() {
*/
add_task(async function media_should_be_able_to_play_in_visible_tab() {
info("- open new background tab, and check tab's media pause state -");
let tab = BrowserTestUtils.addTab(window.gBrowser, "about:blank");
let tab = window.gBrowser.addTab("about:blank");
tab.linkedBrowser.loadURI(PAGE);
await BrowserTestUtils.browserLoaded(tab.linkedBrowser);
await ContentTask.spawn(tab.linkedBrowser, true,

View File

@@ -84,7 +84,7 @@ add_task(async function setup_test_preference() {
add_task(async function block_multiple_media() {
info("- open new background tab -");
let tab = BrowserTestUtils.addTab(window.gBrowser, "about:blank");
let tab = window.gBrowser.addTab("about:blank");
let browser = tab.linkedBrowser;
browser.loadURI(PAGE);
await BrowserTestUtils.browserLoaded(browser);

View File

@@ -52,7 +52,7 @@ add_task(async function setup_test_preference() {
add_task(async function block_not_in_tree_media() {
info("- open new background tab -");
let tab = BrowserTestUtils.addTab(window.gBrowser, "about:blank");
let tab = window.gBrowser.addTab("about:blank");
tab.linkedBrowser.loadURI(PAGE);
await BrowserTestUtils.browserLoaded(tab.linkedBrowser);

View File

@@ -63,7 +63,7 @@ add_task(async function setup_test_preference() {
add_task(async function unblock_icon_should_disapear_after_resume_tab() {
info("- open new background tab -");
let tab = BrowserTestUtils.addTab(window.gBrowser, "about:blank");
let tab = window.gBrowser.addTab("about:blank");
tab.linkedBrowser.loadURI(PAGE);
await BrowserTestUtils.browserLoaded(tab.linkedBrowser);

View File

@@ -10,7 +10,7 @@ add_task(async function setup_test_preference() {
add_task(async function block_plug_in() {
info("- open new background tab -");
let tab = BrowserTestUtils.addTab(window.gBrowser, "about:blank");
let tab = window.gBrowser.addTab("about:blank");
tab.linkedBrowser.loadURI(PAGE);
await BrowserTestUtils.browserLoaded(tab.linkedBrowser);

View File

@@ -34,7 +34,7 @@ add_task(async function setup_test_preference() {
add_task(async function unblock_icon_should_disapear_after_resume_tab() {
info("- open new background tab -");
let tab = BrowserTestUtils.addTab(window.gBrowser, "about:blank");
let tab = window.gBrowser.addTab("about:blank");
tab.linkedBrowser.loadURI(PAGE);
await BrowserTestUtils.browserLoaded(tab.linkedBrowser);
@@ -64,7 +64,7 @@ add_task(async function unblock_icon_should_disapear_after_resume_tab() {
add_task(async function should_not_show_sound_indicator_after_resume_tab() {
info("- open new background tab -");
let tab = BrowserTestUtils.addTab(window.gBrowser, "about:blank");
let tab = window.gBrowser.addTab("about:blank");
tab.linkedBrowser.loadURI(PAGE);
await BrowserTestUtils.browserLoaded(tab.linkedBrowser);

View File

@@ -16,7 +16,7 @@ add_task(async function setup_test_preference() {
add_task(async function block_web_audio() {
info("- open new background tab -");
let tab = BrowserTestUtils.addTab(window.gBrowser, "about:blank");
let tab = window.gBrowser.addTab("about:blank");
tab.linkedBrowser.loadURI(PAGE);
await BrowserTestUtils.browserLoaded(tab.linkedBrowser);

View File

@@ -102,7 +102,7 @@ add_task(async function setup_test_preference() {
*/
add_task(async function resume_and_suspend_background_video_decoding() {
info("- open new background tab -");
let tab = BrowserTestUtils.addTab(window.gBrowser, "about:blank");
let tab = window.gBrowser.addTab("about:blank");
let browser = tab.linkedBrowser;
info("- before loading media, we shoudn't send the tab hover msg for tab -");