Backed out 2 changesets (bug 1393570) for build bustage on linux on a CLOSED TREE

Backed out changeset 23f496cd8a42 (bug 1393570)
Backed out changeset e41e69aa9eb5 (bug 1393570)

--HG--
extra : source : 56a508217ab7e7c28e1e5622f8dd31caa98a8706
This commit is contained in:
Coroiu Cristina 2018-09-12 20:40:27 +03:00
Родитель fe594e1d36
Коммит 437a9f5e37
9 изменённых файлов: 33 добавлений и 308 удалений

Просмотреть файл

@ -1658,22 +1658,17 @@ var gBrowserInit = {
gBrowser.loadTabs(specs, {
inBackground: false,
replace: true,
// See below for the semantics of window.arguments. Only the minimum is supported.
userContextId: window.arguments[6],
triggeringPrincipal: window.arguments[8] || Services.scriptSecurityManager.getSystemPrincipal(),
allowInheritPrincipal: window.arguments[9],
triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
});
} catch (e) {}
} else if (window.arguments.length >= 3) {
// window.arguments[1]: unused (bug 871161)
// [2]: referrer (nsIURI | string)
// window.arguments[2]: referrer (nsIURI | string)
// [3]: postData (nsIInputStream)
// [4]: allowThirdPartyFixup (bool)
// [5]: referrerPolicy (int)
// [6]: userContextId (int)
// [7]: originPrincipal (nsIPrincipal)
// [8]: triggeringPrincipal (nsIPrincipal)
// [9]: allowInheritPrincipal (bool)
let referrerURI = window.arguments[2];
if (typeof(referrerURI) == "string") {
try {
@ -1691,9 +1686,9 @@ var gBrowserInit = {
// pass the origin principal (if any) and force its use to create
// an initial about:blank viewer if present:
window.arguments[7], !!window.arguments[7], window.arguments[8],
// TODO fix allowInheritPrincipal to default to false.
// Default to true unless explicitly set to false because of bug 1475201.
window.arguments[9] !== false);
// TODO fix allowInheritPrincipal
// (this is required by javascript: drop to the new window) Bug 1475201
true);
window.focus();
} else {
// Note: loadOneOrMoreURIs *must not* be called if window.arguments.length >= 3.

Просмотреть файл

@ -1430,7 +1430,6 @@ window._gBrowser = {
},
loadTabs(aURIs, {
allowInheritPrincipal,
allowThirdPartyFixup,
inBackground,
newIndex,
@ -1487,9 +1486,6 @@ window._gBrowser = {
flags |= Ci.nsIWebNavigation.LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP |
Ci.nsIWebNavigation.LOAD_FLAGS_FIXUP_SCHEME_TYPOS;
}
if (!allowInheritPrincipal) {
flags |= Ci.nsIWebNavigation.LOAD_FLAGS_DISALLOW_INHERIT_PRINCIPAL;
}
try {
browser.loadURI(aURIs[0], {
flags,
@ -1502,7 +1498,6 @@ window._gBrowser = {
}
} else {
let params = {
allowInheritPrincipal,
ownerTab: owner,
skipAnimation: multiple,
allowThirdPartyFixup,
@ -1523,7 +1518,6 @@ window._gBrowser = {
let tabNum = targetTabIndex;
for (let i = 1; i < aURIs.length; ++i) {
let params = {
allowInheritPrincipal,
skipAnimation: true,
allowThirdPartyFixup,
postData: postDatas && postDatas[i],

Просмотреть файл

@ -525,10 +525,34 @@ this.tabs = class extends ExtensionAPI {
let url;
let principal = context.principal;
if (createProperties.cookieStoreId && !extension.hasPermission("cookies")) {
return Promise.reject({message: `No permission for cookieStoreId: ${createProperties.cookieStoreId}`});
}
let options = {};
if (createProperties.cookieStoreId) {
// May throw if validation fails.
options.userContextId = getUserContextIdForCookieStoreId(extension, createProperties.cookieStoreId, PrivateBrowsingUtils.isBrowserPrivate(window.gBrowser));
if (!global.isValidCookieStoreId(createProperties.cookieStoreId)) {
return Promise.reject({message: `Illegal cookieStoreId: ${createProperties.cookieStoreId}`});
}
let privateWindow = PrivateBrowsingUtils.isBrowserPrivate(window.gBrowser);
if (privateWindow && !global.isPrivateCookieStoreId(createProperties.cookieStoreId)) {
return Promise.reject({message: `Illegal to set non-private cookieStoreId in a private window`});
}
if (!privateWindow && global.isPrivateCookieStoreId(createProperties.cookieStoreId)) {
return Promise.reject({message: `Illegal to set private cookieStoreId in a non-private window`});
}
if (global.isContainerCookieStoreId(createProperties.cookieStoreId)) {
let containerId = global.getContainerForCookieStoreId(createProperties.cookieStoreId);
if (!containerId) {
return Promise.reject({message: `No cookie store exists with ID ${createProperties.cookieStoreId}`});
}
options.userContextId = containerId;
}
}
if (createProperties.url !== null) {

Просмотреть файл

@ -138,7 +138,6 @@ this.windows = class extends ExtensionAPI {
let args = Cc["@mozilla.org/array;1"].createInstance(Ci.nsIMutableArray);
let principal = context.principal;
if (createData.tabId !== null) {
if (createData.url !== null) {
return Promise.reject({message: "`tabId` may not be used in conjunction with `url`"});
@ -161,10 +160,6 @@ this.windows = class extends ExtensionAPI {
}
createData.incognito = incognito;
if (createData.cookieStoreId && createData.cookieStoreId !== getCookieStoreIdForTab(createData, tab)) {
return Promise.reject({message: "`cookieStoreId` must match the tab's cookieStoreId"});
}
args.appendElement(tab);
} else if (createData.url !== null) {
if (Array.isArray(createData.url)) {
@ -177,35 +172,9 @@ this.windows = class extends ExtensionAPI {
args.appendElement(mkstr(createData.url));
}
} else {
let url = aboutNewTabService.newTabURL;
args.appendElement(mkstr(url));
if (url === "about:newtab") {
// The extension principal cannot directly load about:newtab,
// so use the system principal instead.
principal = Services.scriptSecurityManager.getSystemPrincipal();
}
args.appendElement(mkstr(aboutNewTabService.newTabURL));
}
args.appendElement(null); // unused
args.appendElement(null); // referrer
args.appendElement(null); // postData
args.appendElement(null); // allowThirdPartyFixup
args.appendElement(null); // referrerPolicy
if (createData.cookieStoreId) {
let userContextIdSupports = Cc["@mozilla.org/supports-PRUint32;1"].createInstance(Ci.nsISupportsPRUint32);
// May throw if validation fails.
userContextIdSupports.data = getUserContextIdForCookieStoreId(extension, createData.cookieStoreId, createData.incognito);
args.appendElement(userContextIdSupports); // userContextId
} else {
args.appendElement(null);
}
args.appendElement(context.principal); // originPrincipal - not important.
args.appendElement(principal); // triggeringPrincipal
args.appendElement(Cc["@mozilla.org/supports-PRBool;1"].createInstance(Ci.nsISupportsPRBool)); // allowInheritPrincipal
let features = ["chrome"];
if (createData.type === null || createData.type == "normal") {

Просмотреть файл

@ -313,11 +313,6 @@
"optional": true,
"description": "Allow scripts to close the window."
},
"cookieStoreId": {
"type": "string",
"optional": true,
"description": "The CookieStoreId to use for all tabs that were created when the window is opened."
},
"titlePreface": {
"type": "string",
"optional": true,

Просмотреть файл

@ -241,7 +241,6 @@ skip-if = os == 'mac' # Save as PDF not supported on Mac OS X
[browser_ext_windows_create.js]
skip-if = (verify && (os == 'mac'))
tags = fullscreen
[browser_ext_windows_create_cookieStoreId.js]
[browser_ext_windows_create_params.js]
[browser_ext_windows_create_tabId.js]
[browser_ext_windows_create_url.js]

Просмотреть файл

@ -1,222 +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 no_cookies_permission() {
await SpecialPowers.pushPrefEnv({"set": [
["privacy.userContext.enabled", true],
]});
let extension = ExtensionTestUtils.loadExtension({
async background() {
await browser.test.assertRejects(
browser.windows.create({cookieStoreId: "firefox-container-1"}),
/No permission for cookieStoreId/,
"cookieStoreId requires cookies permission");
browser.test.sendMessage("done");
},
});
await extension.startup();
await extension.awaitMessage("done");
await extension.unload();
});
add_task(async function invalid_cookieStoreId() {
await SpecialPowers.pushPrefEnv({"set": [
["privacy.userContext.enabled", true],
]});
let extension = ExtensionTestUtils.loadExtension({
manifest: {
permissions: ["cookies"],
},
async background() {
await browser.test.assertRejects(
browser.windows.create({cookieStoreId: "not-firefox-container-1"}),
/Illegal cookieStoreId/,
"cookieStoreId must be valid");
await browser.test.assertRejects(
browser.windows.create({cookieStoreId: "firefox-private"}),
/Illegal to set private cookieStoreId in a non-private window/,
"cookieStoreId cannot be private in a non-private window");
await browser.test.assertRejects(
browser.windows.create({cookieStoreId: "firefox-default", incognito: true}),
/Illegal to set non-private cookieStoreId in a private window/,
"cookieStoreId cannot be non-private in an private window");
await browser.test.assertRejects(
browser.windows.create({cookieStoreId: "firefox-container-1", incognito: true}),
/Illegal to set non-private cookieStoreId in a private window/,
"cookieStoreId cannot be a container tab ID in a private window");
browser.test.sendMessage("done");
},
});
await extension.startup();
await extension.awaitMessage("done");
await extension.unload();
});
add_task(async function valid_cookieStoreId() {
await SpecialPowers.pushPrefEnv({"set": [
["privacy.userContext.enabled", true],
]});
const testCases = [{
description: "no explicit URL",
createParams: {
cookieStoreId: "firefox-container-1",
},
expectedCookieStoreIds: [
"firefox-container-1",
],
expectedExecuteScriptResult: [
// Default URL is about:newtab, and extensions cannot run scripts in it.
"Missing host permission for the tab",
],
}, {
description: "one URL",
createParams: {
url: "about:blank",
cookieStoreId: "firefox-container-1",
},
expectedCookieStoreIds: [
"firefox-container-1",
],
expectedExecuteScriptResult: [
"about:blank - null",
],
}, {
description: "one URL in an array",
createParams: {
url: ["about:blank"],
cookieStoreId: "firefox-container-1",
},
expectedCookieStoreIds: [
"firefox-container-1",
],
expectedExecuteScriptResult: [
"about:blank - null",
],
}, {
description: "two URLs in an array",
createParams: {
url: ["about:blank", "about:blank"],
cookieStoreId: "firefox-container-1",
},
expectedCookieStoreIds: [
"firefox-container-1",
"firefox-container-1",
],
expectedExecuteScriptResult: [
"about:blank - null",
"about:blank - null",
],
}];
async function background(testCases) {
async function executeScriptAndGetResult(tabId, attempts = 0) {
try {
return (await browser.tabs.executeScript(tabId, {
matchAboutBlank: true,
code: "`${document.URL} - ${origin}`",
}))[0];
} catch (e) {
if (e.message === "No matching message handler") {
if (++attempts < 10) {
// The tabs.executeScript API does not wait for the tab to load
// if the tab is "about:blank" ( bug 1397667 ):
// https://searchfox.org/mozilla-central/rev/c3fef66a5b211ea8038c1c132706d02db408093a/browser/components/extensions/parent/ext-tabs.js#112
// If the test called tabs.executeScript too soon, wait a little bit
// and retry a couple of times before giving up.
// eslint-disable-next-line mozilla/no-arbitrary-setTimeout
await new Promise(resolve => setTimeout(resolve, 100 * attempts));
return executeScriptAndGetResult(tabId, attempts);
}
browser.test.log(`Warning: Cannot execute script after ${attempts} attempts.`);
}
return e.message;
}
}
for (let {description, createParams, expectedCookieStoreIds, expectedExecuteScriptResult} of testCases) {
let win = await browser.windows.create(createParams);
browser.test.assertEq(expectedCookieStoreIds.length, win.tabs.length, "Expected number of tabs");
for (let [i, expectedCookieStoreId] of Object.entries(expectedCookieStoreIds)) {
browser.test.assertEq(expectedCookieStoreId, win.tabs[i].cookieStoreId, `expected cookieStoreId for tab ${i} (${description})`);
}
for (let [i, expectedResult] of Object.entries(expectedExecuteScriptResult)) {
let result = await executeScriptAndGetResult(win.tabs[i].id);
browser.test.assertEq(expectedResult, result, `expected executeScript result for tab ${i} (${description})`);
}
await browser.windows.remove(win.id);
}
browser.test.sendMessage("done");
}
let extension = ExtensionTestUtils.loadExtension({
manifest: {
permissions: ["cookies"],
},
background: `(${background})(${JSON.stringify(testCases)})`,
});
await extension.startup();
await extension.awaitMessage("done");
await extension.unload();
});
add_task(async function cookieStoreId_and_tabId() {
await SpecialPowers.pushPrefEnv({"set": [
["privacy.userContext.enabled", true],
]});
let extension = ExtensionTestUtils.loadExtension({
manifest: {
permissions: ["cookies"],
},
async background() {
for (let cookieStoreId of ["firefox-default", "firefox-container-1"]) {
let {id: normalTabId} = await browser.tabs.create({cookieStoreId});
await browser.test.assertRejects(
browser.windows.create({cookieStoreId: "firefox-private", tabId: normalTabId}),
/`cookieStoreId` must match the tab's cookieStoreId/,
"Cannot use cookieStoreId for pre-existing tabs with a different cookieStoreId");
let win = await browser.windows.create({cookieStoreId, tabId: normalTabId});
browser.test.assertEq(cookieStoreId, win.tabs[0].cookieStoreId, "Adopted tab");
await browser.windows.remove(win.id);
}
{
let privateWindow = await browser.windows.create({incognito: true});
let privateTabId = privateWindow.tabs[0].id;
await browser.test.assertRejects(
browser.windows.create({cookieStoreId: "firefox-default", tabId: privateTabId}),
/`cookieStoreId` must match the tab's cookieStoreId/,
"Cannot use cookieStoreId for pre-existing tab in a private window");
let win = await browser.windows.create({cookieStoreId: "firefox-private", tabId: privateTabId});
browser.test.assertEq("firefox-private", win.tabs[0].cookieStoreId, "Adopted private tab");
await browser.windows.remove(win.id);
await browser.test.assertRejects(
browser.windows.remove(privateWindow.id),
/Invalid window ID:/,
"The original private window should have been closed when its only tab was adopted.");
}
browser.test.sendMessage("done");
},
});
await extension.startup();
await extension.awaitMessage("done");
await extension.unload();
});

Просмотреть файл

@ -14,7 +14,6 @@ module.exports = {
"WindowBase": true,
"WindowManagerBase": true,
"WindowTrackerBase": true,
"getUserContextIdForCookieStoreId": true,
"getContainerForCookieStoreId": true,
"getCookieStoreIdForContainer": true,
"getCookieStoreIdForTab": true,

Просмотреть файл

@ -2054,32 +2054,4 @@ class WindowManagerBase {
/* eslint-enable valid-jsdoc */
}
function getUserContextIdForCookieStoreId(extension, cookieStoreId, isPrivateBrowsing) {
if (!extension.hasPermission("cookies")) {
throw new ExtensionError(`No permission for cookieStoreId: ${cookieStoreId}`);
}
if (!isValidCookieStoreId(cookieStoreId)) {
throw new ExtensionError(`Illegal cookieStoreId: ${cookieStoreId}`);
}
if (isPrivateBrowsing && !isPrivateCookieStoreId(cookieStoreId)) {
throw new ExtensionError(`Illegal to set non-private cookieStoreId in a private window`);
}
if (!isPrivateBrowsing && isPrivateCookieStoreId(cookieStoreId)) {
throw new ExtensionError(`Illegal to set private cookieStoreId in a non-private window`);
}
if (isContainerCookieStoreId(cookieStoreId)) {
let userContextId = getContainerForCookieStoreId(cookieStoreId);
if (!userContextId) {
throw new ExtensionError(`No cookie store exists with ID ${cookieStoreId}`);
}
return userContextId;
}
return Services.scriptSecurityManager.DEFAULT_USER_CONTEXT_ID;
}
Object.assign(global, {TabTrackerBase, TabManagerBase, TabBase, WindowTrackerBase, WindowManagerBase, WindowBase, getUserContextIdForCookieStoreId});
Object.assign(global, {TabTrackerBase, TabManagerBase, TabBase, WindowTrackerBase, WindowManagerBase, WindowBase});