зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 2 changesets (bug 1405971) by request of evilpie.
Backed out changeset 1698a498f801 (bug 1405971) Backed out changeset 94512ff23703 (bug 1405971) --HG-- extra : rebase_source : 22b68902af62d1e4f4acd474f21684fce9640666
This commit is contained in:
Родитель
b61a4aacf6
Коммит
94f5338c33
|
@ -9699,31 +9699,27 @@ void nsHttpChannel::MaybeWarnAboutAppCache() {
|
|||
|
||||
// Step 10 of HTTP-network-or-cache fetch
|
||||
void nsHttpChannel::SetOriginHeader() {
|
||||
if (mRequestHead.IsGet() || mRequestHead.IsHead()) {
|
||||
return;
|
||||
}
|
||||
nsresult rv;
|
||||
|
||||
nsAutoCString existingHeader;
|
||||
Unused << mRequestHead.GetHeader(nsHttp::Origin, existingHeader);
|
||||
if (!existingHeader.IsEmpty() && !existingHeader.EqualsLiteral("null")) {
|
||||
LOG(
|
||||
("nsHttpChannel::SetOriginHeader Origin header already present "
|
||||
"[this=%p]",
|
||||
this));
|
||||
if (!existingHeader.IsEmpty()) {
|
||||
LOG(("nsHttpChannel::SetOriginHeader Origin header already present"));
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
rv = NS_NewURI(getter_AddRefs(uri), existingHeader);
|
||||
if (NS_FAILED(rv) || !dom::ReferrerInfo::IsReferrerSchemeAllowed(uri) ||
|
||||
if (NS_SUCCEEDED(rv) &&
|
||||
ReferrerInfo::ShouldSetNullOriginHeader(this, uri)) {
|
||||
LOG(("nsHttpChannel::SetOriginHeader to null Origin [this=%p]", this));
|
||||
DebugOnly<nsresult> success = mRequestHead.SetHeader(
|
||||
nsHttp::Origin, NS_LITERAL_CSTRING("null"), false /* merge */);
|
||||
MOZ_ASSERT(NS_SUCCEEDED(success));
|
||||
LOG(("nsHttpChannel::SetOriginHeader null Origin by Referrer-Policy"));
|
||||
rv = mRequestHead.SetHeader(nsHttp::Origin, NS_LITERAL_CSTRING("null"),
|
||||
false /* merge */);
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (mRequestHead.IsGet() || mRequestHead.IsHead()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Instead of consulting Preferences::GetInt() all the time we
|
||||
// can cache the result to speed things up.
|
||||
static int32_t sSendOriginHeader = 0;
|
||||
|
|
|
@ -48,7 +48,6 @@ support-files =
|
|||
redirect_auto.sjs
|
||||
redirection.sjs
|
||||
return_headers.sjs
|
||||
return_headers_cors.sjs
|
||||
slow_response.sjs
|
||||
webrequest_worker.js
|
||||
!/dom/tests/mochitest/geolocation/network_geolocation.sjs
|
||||
|
@ -154,4 +153,3 @@ skip-if = os == 'android' # Currently fails in emulator tests
|
|||
[test_ext_webrequest_redirect_data_uri.html]
|
||||
[test_ext_window_postMessage.html]
|
||||
[test_ext_webrequest_redirect_bypass_cors.html]
|
||||
[test_ext_fetch_origin.html]
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
|
||||
/* vim: set ft=javascript sts=2 sw=2 et tw=80: */
|
||||
"use strict";
|
||||
|
||||
/* exported handleRequest */
|
||||
|
||||
function handleRequest(request, response) {
|
||||
response.setStatusLine(request.httpVersion, 200, "OK");
|
||||
response.setHeader("Content-Type", "text/json", false);
|
||||
response.setHeader("Access-Control-Allow-Credentials", "true", false);
|
||||
response.setHeader("Access-Control-Allow-Origin", "*", false);
|
||||
|
||||
|
||||
let headers = {};
|
||||
// Why on earth is this a nsISimpleEnumerator...
|
||||
let enumerator = request.headers;
|
||||
while (enumerator.hasMoreElements()) {
|
||||
let header = enumerator.getNext().data;
|
||||
headers[header.toLowerCase()] = request.getHeader(header);
|
||||
}
|
||||
|
||||
response.write(JSON.stringify(headers));
|
||||
}
|
||||
|
|
@ -1,60 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test for simple WebExtension</title>
|
||||
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script src="/tests/SimpleTest/ExtensionTestUtils.js"></script>
|
||||
<script type="text/javascript" src="head.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<script type="text/javascript">
|
||||
"use strict";
|
||||
|
||||
add_task(async function test_fetch_origin() {
|
||||
let extension = ExtensionTestUtils.loadExtension({
|
||||
manifest: {
|
||||
permissions: [
|
||||
// We purposefully don't add any host permission for example.org
|
||||
// (or all_urls). This ensures the requests below use CORS,
|
||||
// which would normally send an Origin header with a moz-extension:
|
||||
// scheme.
|
||||
],
|
||||
},
|
||||
async background() {
|
||||
const PATH = "https://example.org/tests/toolkit/components/extensions/test/mochitest/return_headers_cors.sjs";
|
||||
|
||||
let response = await fetch(PATH);
|
||||
let headers = await response.json();
|
||||
|
||||
browser.test.assertEq(headers.host, "example.org", "right host");
|
||||
browser.test.assertEq(headers.origin, "null", "Origin: null header");
|
||||
|
||||
headers = await new Promise((resolve, reject) => {
|
||||
/* eslint-disable mozilla/balanced-listeners */
|
||||
let xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", PATH);
|
||||
xhr.addEventListener("load", () => {
|
||||
resolve(JSON.parse(xhr.response));
|
||||
})
|
||||
xhr.addEventListener("error", reject)
|
||||
xhr.send();
|
||||
})
|
||||
|
||||
browser.test.assertEq(headers.host, "example.org", "right host");
|
||||
browser.test.assertEq(headers.origin, "null", "Origin: null header");
|
||||
|
||||
browser.test.sendMessage("finished");
|
||||
},
|
||||
});
|
||||
|
||||
await extension.startup();
|
||||
await extension.awaitMessage("finished");
|
||||
await extension.unload();
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
Загрузка…
Ссылка в новой задаче