Backed out changeset 5686e9cc48b2 (bug 1579992) for causing bc failures in browser/components/aboutlogins/tests/browser/browser_dismissFooter.js CLOSED TREE

This commit is contained in:
shindli 2019-10-21 21:09:24 +03:00
Родитель 54404e676b
Коммит ebcb4e6fbf
13 изменённых файлов: 59 добавлений и 239 удалений

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

@ -2699,43 +2699,18 @@ var SessionStoreInternal = {
let resultPrincipal = Services.scriptSecurityManager.getChannelResultPrincipal(
channel
);
const isCOOPSwitch =
E10SUtils.useCrossOriginOpenerPolicy() &&
switchRequestor.hasCrossOriginOpenerPolicyMismatch();
let preferredRemoteType = currentRemoteType;
if (
switchRequestor.crossOriginOpenerPolicy ==
Ci.nsILoadInfo.OPENER_POLICY_SAME_ORIGIN_EMBEDDER_POLICY_REQUIRE_CORP
) {
// We want documents with a SAME_ORIGIN_EMBEDDER_POLICY_REQUIRE_CORP
// COOP policy to be loaded in a separate process for which we can enable
// high resolution timers.
preferredRemoteType =
E10SUtils.WEB_REMOTE_COOP_COEP_TYPE_PREFIX + resultPrincipal.siteOrigin;
} else if (isCOOPSwitch) {
// If it is a coop switch, but doesn't have this flag, we want to switch
// to a default remoteType
preferredRemoteType = E10SUtils.DEFAULT_REMOTE_TYPE;
}
debug(
`[process-switch]: currentRemoteType (${currentRemoteType}) preferredRemoteType: ${preferredRemoteType}`
);
let remoteType = E10SUtils.getRemoteTypeForPrincipal(
resultPrincipal,
true,
useRemoteSubframes,
preferredRemoteType,
currentRemoteType,
currentPrincipal
);
debug(
`[process-switch]: ${currentRemoteType}, ${remoteType}, ${isCOOPSwitch}`
);
if (currentRemoteType == remoteType && !isCOOPSwitch) {
if (
currentRemoteType == remoteType &&
(!E10SUtils.useCrossOriginOpenerPolicy() ||
!switchRequestor.hasCrossOriginOpenerPolicyMismatch())
) {
debug(`[process-switch]: type (${remoteType}) is compatible - ignoring`);
return;
}
@ -2748,6 +2723,10 @@ var SessionStoreInternal = {
return;
}
const isCOOPSwitch =
E10SUtils.useCrossOriginOpenerPolicy() &&
switchRequestor.hasCrossOriginOpenerPolicyMismatch();
// ------------------------------------------------------------------------
// DANGER ZONE: Perform a process switch into the new process. This is
// destructive.

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

@ -80,7 +80,7 @@ already_AddRefed<WindowGlobalChild> WindowGlobalChild::Create(
if (httpChan &&
loadInfo->GetExternalContentPolicyType() ==
nsIContentPolicy::TYPE_DOCUMENT &&
NS_SUCCEEDED(httpChan->ComputeCrossOriginOpenerPolicy(
NS_SUCCEEDED(httpChan->GetCrossOriginOpenerPolicy(
nsILoadInfo::OPENER_POLICY_NULL, &policy))) {
bc->SetOpenerPolicy(policy);
}

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

@ -42,11 +42,4 @@ interface nsIProcessSwitchRequestor : nsISupports
* @throws NS_ERROR_NOT_AVAILABLE if we don't have a responseHead
*/
[must_use] boolean hasCrossOriginOpenerPolicyMismatch();
/**
* Returns a cached CrossOriginOpenerPolicy that is computed just before we
* determine if there is a policy mismatch.
* @throws NS_ERROR_NOT_AVAILABLE if it has not been computed yet
*/
[must_use] readonly attribute nsILoadInfo_CrossOriginOpenerPolicy crossOriginOpenerPolicy;
};

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

@ -904,22 +904,5 @@ DocumentChannelParent::HasCrossOriginOpenerPolicyMismatch(bool* aMismatch) {
return channel->HasCrossOriginOpenerPolicyMismatch(aMismatch);
}
NS_IMETHODIMP
DocumentChannelParent::GetCrossOriginOpenerPolicy(
nsILoadInfo::CrossOriginOpenerPolicy* aPolicy) {
MOZ_ASSERT(aPolicy);
if (!aPolicy) {
return NS_ERROR_INVALID_ARG;
}
nsCOMPtr<nsHttpChannel> channel = do_QueryInterface(mChannel);
if (!channel) {
*aPolicy = nsILoadInfo::OPENER_POLICY_NULL;
return NS_OK;
}
return channel->GetCrossOriginOpenerPolicy(aPolicy);
}
} // namespace net
} // namespace mozilla

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

@ -645,7 +645,7 @@ bool ClassifierDummyChannel::GetHasNonEmptySandboxingFlag() { return false; }
void ClassifierDummyChannel::SetHasNonEmptySandboxingFlag(
bool aHasNonEmptySandboxingFlag) {}
NS_IMETHODIMP ClassifierDummyChannel::ComputeCrossOriginOpenerPolicy(
NS_IMETHODIMP ClassifierDummyChannel::GetCrossOriginOpenerPolicy(
nsILoadInfo::CrossOriginOpenerPolicy aInitiatorPolicy,
nsILoadInfo::CrossOriginOpenerPolicy* aOutPolicy) {
return NS_ERROR_NOT_IMPLEMENTED;

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

@ -4463,7 +4463,7 @@ nsILoadInfo::CrossOriginOpenerPolicy CreateCrossOriginOpenerPolicy(
// Obtain a cross-origin opener-policy from a response response and a
// cross-origin opener policy initiator.
// https://gist.github.com/annevk/6f2dd8c79c77123f39797f6bdac43f3e
NS_IMETHODIMP HttpBaseChannel::ComputeCrossOriginOpenerPolicy(
NS_IMETHODIMP HttpBaseChannel::GetCrossOriginOpenerPolicy(
nsILoadInfo::CrossOriginOpenerPolicy aInitiatorPolicy,
nsILoadInfo::CrossOriginOpenerPolicy* aOutPolicy) {
MOZ_ASSERT(aOutPolicy);

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

@ -313,7 +313,7 @@ class HttpBaseChannel : public nsHashPropertyBag,
NS_IMETHOD CancelByURLClassifier(nsresult aErrorCode) override;
virtual void SetIPv4Disabled(void) override;
virtual void SetIPv6Disabled(void) override;
NS_IMETHOD ComputeCrossOriginOpenerPolicy(
NS_IMETHOD GetCrossOriginOpenerPolicy(
nsILoadInfo::CrossOriginOpenerPolicy aInitiatorPolicy,
nsILoadInfo::CrossOriginOpenerPolicy* aOutPolicy) override;
virtual bool GetHasNonEmptySandboxingFlag() override {
@ -590,6 +590,10 @@ class HttpBaseChannel : public nsHashPropertyBag,
nsresult GetResponseEmbedderPolicy(
nsILoadInfo::CrossOriginEmbedderPolicy* aResponseEmbedderPolicy);
nsresult GetCrossOriginOpenerPolicyWithInitiator(
nsILoadInfo::CrossOriginOpenerPolicy aInitiatorPolicy,
nsILoadInfo::CrossOriginOpenerPolicy* aOutPolicy);
friend class PrivateBrowsingChannel<HttpBaseChannel>;
friend class InterceptFailedOnStop;

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

@ -7289,23 +7289,6 @@ nsHttpChannel::HasCrossOriginOpenerPolicyMismatch(bool* aMismatch) {
return NS_OK;
}
NS_IMETHODIMP
nsHttpChannel::GetCrossOriginOpenerPolicy(
nsILoadInfo::CrossOriginOpenerPolicy* aPolicy) {
MOZ_ASSERT(aPolicy);
if (!aPolicy) {
return NS_ERROR_INVALID_ARG;
}
// If this method is called before OnStartRequest (ie. before we call
// ComputeCrossOriginOpenerPolicy) or if we were unable to compute the
// policy we'll throw an error.
if (!mComputedCrossOriginOpenerPolicy.isSome()) {
return NS_ERROR_NOT_AVAILABLE;
}
*aPolicy = mComputedCrossOriginOpenerPolicy.value();
return NS_OK;
}
nsresult nsHttpChannel::StartCrossProcessRedirect() {
nsresult rv;
@ -7396,8 +7379,7 @@ nsresult nsHttpChannel::ComputeCrossOriginOpenerPolicyMismatch() {
nsILoadInfo::CrossOriginOpenerPolicy documentPolicy = ctx->GetOpenerPolicy();
nsILoadInfo::CrossOriginOpenerPolicy resultPolicy =
nsILoadInfo::OPENER_POLICY_NULL;
Unused << ComputeCrossOriginOpenerPolicy(documentPolicy, &resultPolicy);
mComputedCrossOriginOpenerPolicy.emplace(resultPolicy);
Unused << GetCrossOriginOpenerPolicy(documentPolicy, &resultPolicy);
// If bc's popup sandboxing flag set is not empty and potentialCOOP is
// non-null, then navigate bc to a network error and abort these steps.

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

@ -648,10 +648,6 @@ class nsHttpChannel final : public HttpBaseChannel,
static const uint32_t WAIT_FOR_CACHE_ENTRY = 1;
static const uint32_t WAIT_FOR_OFFLINE_CACHE_ENTRY = 2;
// Gets computed during ComputeCrossOriginOpenerPolicyMismatch so we have
// the channel's policy even if we don't know policy initiator.
Maybe<nsILoadInfo::CrossOriginOpenerPolicy> mComputedCrossOriginOpenerPolicy;
bool mCacheOpenWithPriority;
uint32_t mCacheQueueSizeWhenOpen;

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

@ -394,7 +394,7 @@ interface nsIHttpChannelInternal : nsISupports
* Get the Cross-Origin-Opener-Policy of the top-level document channel.
*/
[noscript]
nsILoadInfo_CrossOriginOpenerPolicy computeCrossOriginOpenerPolicy(
nsILoadInfo_CrossOriginOpenerPolicy getCrossOriginOpenerPolicy(
in nsILoadInfo_CrossOriginOpenerPolicy aInitiatorPolicy);
[notxpcom, nostdcall] attribute boolean hasNonEmptySandboxingFlag;

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

@ -25,13 +25,7 @@ async function performLoad(browser, opts, action) {
await loadedPromise;
}
async function test_coop(
start,
target,
expectedProcessSwitch,
startRemoteTypeCheck,
targetRemoteTypeCheck
) {
async function test_coop(start, target, expectedProcessSwitch) {
return BrowserTestUtils.withNewTab(
{
gBrowser,
@ -43,16 +37,11 @@ async function test_coop(
await new Promise(resolve => setTimeout(resolve, 20));
let browser = gBrowser.selectedBrowser;
let firstRemoteType = browser.remoteType;
let firstProcessID = browser.frameLoader.remoteTab.osPid;
let firstProcessID = await ContentTask.spawn(browser, null, () => {
return Services.appinfo.processID;
});
info(
`firstProcessID: ${firstProcessID} firstRemoteType: ${firstRemoteType}`
);
if (startRemoteTypeCheck) {
startRemoteTypeCheck(firstRemoteType);
}
info(`firstProcessID: ${firstProcessID}`);
await performLoad(
browser,
@ -74,15 +63,11 @@ async function test_coop(
info(`Navigated to: ${target}`);
await new Promise(resolve => setTimeout(resolve, 20));
browser = gBrowser.selectedBrowser;
let secondRemoteType = browser.remoteType;
let secondProcessID = browser.frameLoader.remoteTab.osPid;
let secondProcessID = await ContentTask.spawn(browser, null, () => {
return Services.appinfo.processID;
});
info(
`secondProcessID: ${secondProcessID} secondRemoteType: ${secondRemoteType}`
);
if (targetRemoteTypeCheck) {
targetRemoteTypeCheck(secondRemoteType);
}
info(`secondProcessID: ${secondProcessID}`);
if (expectedProcessSwitch) {
Assert.notEqual(
firstProcessID,
@ -133,7 +118,7 @@ async function test_download_from(initCoop, downloadCoop) {
info(`test_download: Test tab ready`);
let start = httpURL(
"coop_header.sjs?downloadPage&coop=" + initCoop,
"coop_header.sjs?downloadPage&" + initCoop,
"https://example.com"
);
await performLoad(
@ -210,10 +195,7 @@ add_task(async function test_multiple_nav_process_switches() {
Assert.equal(prevPID, currentPID);
prevPID = currentPID;
target = httpURL(
"coop_header.sjs?coop=same-origin",
"https://example.org"
);
target = httpURL("coop_header.sjs?same-origin", "https://example.org");
await performLoad(
browser,
{
@ -237,10 +219,7 @@ add_task(async function test_multiple_nav_process_switches() {
Assert.notEqual(prevPID, currentPID);
prevPID = currentPID;
target = httpURL(
"coop_header.sjs?coop=same-origin",
"https://example.com"
);
target = httpURL("coop_header.sjs?same-origin", "https://example.com");
await performLoad(
browser,
{
@ -264,10 +243,7 @@ add_task(async function test_multiple_nav_process_switches() {
Assert.notEqual(prevPID, currentPID);
prevPID = currentPID;
target = httpURL(
"coop_header.sjs?coop=same-origin&index=4",
"https://example.com"
);
target = httpURL("coop_header.sjs?same-origin.#4", "https://example.com");
await performLoad(
browser,
{
@ -298,120 +274,43 @@ add_task(async function test_disabled() {
false
);
await test_coop(
httpURL("coop_header.sjs?coop=same-origin", "http://example.com"),
httpURL("coop_header.sjs?same-origin", "http://example.com"),
httpURL("coop_header.sjs", "http://example.com"),
false
);
await test_coop(
httpURL("coop_header.sjs", "http://example.com"),
httpURL("coop_header.sjs?coop=same-origin", "http://example.com"),
httpURL("coop_header.sjs?same-origin", "http://example.com"),
false
);
await test_coop(
httpURL("coop_header.sjs?coop=same-origin", "http://example.com"),
httpURL("coop_header.sjs?coop=same-site", "http://example.com"),
httpURL("coop_header.sjs?same-origin", "http://example.com"),
httpURL("coop_header.sjs?same-site", "http://example.com"),
false
); // assuming we don't have fission yet :)
});
add_task(async function test_enabled() {
await SpecialPowers.pushPrefEnv({ set: [[PREF_NAME, true]] });
function checkIsCoopRemoteType(remoteType) {
Assert.ok(
remoteType.startsWith(E10SUtils.WEB_REMOTE_COOP_COEP_TYPE_PREFIX),
`${remoteType} expected to be coop`
);
}
function checkIsNotCoopRemoteType(remoteType) {
if (gFissionBrowser) {
Assert.ok(
remoteType.startsWith("webIsolated="),
`${remoteType} expected to start with webIsolated=`
);
} else {
Assert.equal(
remoteType,
E10SUtils.WEB_REMOTE_TYPE,
`${remoteType} expected to be web`
);
}
}
await test_coop(
httpURL("coop_header.sjs", "https://example.com"),
httpURL("coop_header.sjs", "https://example.com"),
false,
checkIsNotCoopRemoteType,
checkIsNotCoopRemoteType
false
);
await test_coop(
httpURL("coop_header.sjs", "https://example.com"),
httpURL("coop_header.sjs?coop=same-origin", "https://example.org"),
true,
checkIsNotCoopRemoteType,
checkIsNotCoopRemoteType
httpURL("coop_header.sjs?same-origin", "https://example.org"),
true
);
await test_coop(
httpURL("coop_header.sjs?coop=same-origin&index=1", "https://example.com"),
httpURL("coop_header.sjs?coop=same-origin&index=1", "https://example.org"),
true,
checkIsNotCoopRemoteType,
checkIsNotCoopRemoteType
httpURL("coop_header.sjs?same-origin#1", "https://example.com"),
httpURL("coop_header.sjs?same-origin#1", "https://example.org"),
true
);
await test_coop(
httpURL("coop_header.sjs?coop=same-origin&index=2", "https://example.com"),
httpURL("coop_header.sjs?coop=same-site&index=2", "https://example.org"),
true,
checkIsNotCoopRemoteType,
checkIsNotCoopRemoteType
);
await test_coop(
httpURL("coop_header.sjs", "https://example.com"),
httpURL(
"coop_header.sjs?coop=same-origin&coep=require-corp",
"https://example.com"
),
true,
checkIsNotCoopRemoteType,
checkIsCoopRemoteType
);
await test_coop(
httpURL(
"coop_header.sjs?coop=same-origin&coep=require-corp&index=2",
"https://example.com"
),
httpURL(
"coop_header.sjs?coop=same-origin&coep=require-corp&index=3",
"https://example.com"
),
false,
checkIsCoopRemoteType,
checkIsCoopRemoteType
);
await test_coop(
httpURL(
"coop_header.sjs?coop=same-origin&coep=require-corp&index=4",
"https://example.com"
),
httpURL("coop_header.sjs", "https://example.com"),
true,
checkIsCoopRemoteType,
checkIsNotCoopRemoteType
);
await test_coop(
httpURL(
"coop_header.sjs?coop=same-origin&coep=require-corp&index=5",
"https://example.com"
),
httpURL(
"coop_header.sjs?coop=same-origin&coep=require-corp&index=6",
"https://example.org"
),
true,
checkIsCoopRemoteType,
checkIsCoopRemoteType
httpURL("coop_header.sjs?same-origin#2", "https://example.com"),
httpURL("coop_header.sjs?same-site#2", "https://example.org"),
true
);
});

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

@ -1,24 +1,22 @@
function handleRequest(request, response)
{
Components.utils.importGlobalProperties(["URLSearchParams"]);
let query = new URLSearchParams(request.queryString);
response.setStatusLine(request.httpVersion, 200, "OK");
let qs = request.queryString.replace(/\./g, '');
let isDownloadPage = false;
let isDownloadFile = false;
query.forEach((value, name) => {
if (name === "downloadPage") {
isDownloadPage = true;
} else if (name === "downloadFile") {
isDownloadFile = true;
} else if (name == "coop") {
response.setHeader("Cross-Origin-Opener-Policy", unescape(value), false);
} else if (name == "coep") {
response.setHeader("Cross-Origin-Embedder-Policy", unescape(value), false);
}
});
if (qs.length > 0) {
qs.split("&").forEach(param => {
if (param === "downloadPage") {
isDownloadPage = true;
} else if (param === "downloadFile") {
isDownloadFile = true;
} else if (param.length > 0) {
response.setHeader("Cross-Origin-Opener-Policy", unescape(param), false);
}
});
}
let downloadHTML = "";
if (isDownloadPage) {

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

@ -96,7 +96,6 @@ const NOT_REMOTE = null;
// These must match any similar ones in ContentParent.h and ProcInfo.h
const WEB_REMOTE_TYPE = "web";
const FISSION_WEB_REMOTE_TYPE_PREFIX = "webIsolated=";
const WEB_REMOTE_COOP_COEP_TYPE_PREFIX = "webCOOP+COEP=";
const FILE_REMOTE_TYPE = "file";
const EXTENSION_REMOTE_TYPE = "extension";
const PRIVILEGEDABOUT_REMOTE_TYPE = "privilegedabout";
@ -211,18 +210,6 @@ function validatedWebRemoteType(
// question, and use it to generate an isolated origin.
if (aRemoteSubframes) {
let targetPrincipal = sm.createContentPrincipal(aTargetUri, {});
// If this is a special webCOOP+COEP= remote type that matches the
// principal's siteOrigin, we don't want to override it with webIsolated=
// as it's already isolated.
if (
aPreferredRemoteType &&
aPreferredRemoteType ==
`${WEB_REMOTE_COOP_COEP_TYPE_PREFIX}${targetPrincipal.siteOrigin}`
) {
return aPreferredRemoteType;
}
return FISSION_WEB_REMOTE_TYPE_PREFIX + targetPrincipal.siteOrigin;
}
@ -262,7 +249,6 @@ var E10SUtils = {
DEFAULT_REMOTE_TYPE,
NOT_REMOTE,
WEB_REMOTE_TYPE,
WEB_REMOTE_COOP_COEP_TYPE_PREFIX,
FILE_REMOTE_TYPE,
EXTENSION_REMOTE_TYPE,
PRIVILEGEDABOUT_REMOTE_TYPE,