Backed out 2 changesets (bug 1293067) for failures on browser_oversize.js.

CLOSED TREE

Backed out changeset 5df9d39b0b98 (bug 1293067)
Backed out changeset 8ed41aa3ed4f (bug 1293067)
This commit is contained in:
Cosmin Sabou 2020-03-25 13:24:19 +02:00
Родитель 6a03963e65
Коммит 22c2e8d92c
6 изменённых файлов: 33 добавлений и 165 удалений

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

@ -3264,17 +3264,6 @@ bool nsCookieService::CanSetCookie(nsIURI* aHostURI, const nsCookieKey& aKey,
kMaxBytesPerCookie) {
COOKIE_LOGFAILURE(SET_COOKIE, aHostURI, savedCookieHeader,
"cookie too big (> 4kb)");
AutoTArray<nsString, 2> params = {
NS_ConvertUTF8toUTF16(aCookieData.name())};
nsString size;
size.AppendInt(kMaxBytesPerCookie);
params.AppendElement(size);
LogMessageToConsole(aChannel, aHostURI, nsIScriptError::warningFlag,
CONSOLE_GENERIC_CATEGORY,
NS_LITERAL_CSTRING("CookieOversize"), params);
return newCookie;
}
@ -3297,7 +3286,7 @@ bool nsCookieService::CanSetCookie(nsIURI* aHostURI, const nsCookieKey& aKey,
return newCookie;
}
if (!CheckPath(aCookieData, aChannel, aHostURI)) {
if (!CheckPath(aCookieData, aHostURI)) {
COOKIE_LOGFAILURE(SET_COOKIE, aHostURI, savedCookieHeader,
"failed the path tests");
return newCookie;
@ -3866,11 +3855,10 @@ bool nsCookieService::ParseAttributes(nsIChannel* aChannel, nsIURI* aHostURI,
aCookieData.rawSameSite() = nsICookie::SAMESITE_NONE;
sameSiteSet = true;
} else {
LogMessageToConsole(
aChannel, aHostURI, nsIScriptError::infoFlag,
CONSOLE_GENERIC_CATEGORY,
NS_LITERAL_CSTRING("CookieSameSiteValueInvalid"),
AutoTArray<nsString, 1>{NS_ConvertUTF8toUTF16(aCookieData.name())});
LogMessageToConsole(aChannel, aHostURI, nsIScriptError::infoFlag,
CONSOLE_GENERIC_CATEGORY,
NS_LITERAL_CSTRING("CookieSameSiteValueInvalid"),
aCookieData.name());
}
}
}
@ -3887,11 +3875,10 @@ bool nsCookieService::ParseAttributes(nsIChannel* aChannel, nsIURI* aHostURI,
aCookieData.sameSite() == nsICookie::SAMESITE_NONE) {
if (laxByDefault &&
StaticPrefs::network_cookie_sameSite_noneRequiresSecure()) {
LogMessageToConsole(
aChannel, aHostURI, nsIScriptError::infoFlag,
CONSOLE_SAMESITE_CATEGORY,
NS_LITERAL_CSTRING("CookieRejectedNonRequiresSecure"),
AutoTArray<nsString, 1>{NS_ConvertUTF8toUTF16(aCookieData.name())});
LogMessageToConsole(aChannel, aHostURI, nsIScriptError::infoFlag,
CONSOLE_SAMESITE_CATEGORY,
NS_LITERAL_CSTRING("CookieRejectedNonRequiresSecure"),
aCookieData.name());
return newCookie;
}
@ -3900,24 +3887,21 @@ bool nsCookieService::ParseAttributes(nsIChannel* aChannel, nsIURI* aHostURI,
aChannel, aHostURI, nsIScriptError::warningFlag,
CONSOLE_SAMESITE_CATEGORY,
NS_LITERAL_CSTRING("CookieRejectedNonRequiresSecureForBeta"),
AutoTArray<nsString, 2>{NS_ConvertUTF8toUTF16(aCookieData.name()),
SAMESITE_MDN_URL});
aCookieData.name(), SAMESITE_MDN_URL);
}
if (aCookieData.rawSameSite() == nsICookie::SAMESITE_NONE &&
aCookieData.sameSite() == nsICookie::SAMESITE_LAX) {
if (laxByDefault) {
LogMessageToConsole(
aChannel, aHostURI, nsIScriptError::infoFlag,
CONSOLE_SAMESITE_CATEGORY, NS_LITERAL_CSTRING("CookieLaxForced"),
AutoTArray<nsString, 1>{NS_ConvertUTF8toUTF16(aCookieData.name())});
LogMessageToConsole(aChannel, aHostURI, nsIScriptError::infoFlag,
CONSOLE_SAMESITE_CATEGORY,
NS_LITERAL_CSTRING("CookieLaxForced"),
aCookieData.name());
} else {
LogMessageToConsole(
aChannel, aHostURI, nsIScriptError::warningFlag,
CONSOLE_SAMESITE_CATEGORY,
NS_LITERAL_CSTRING("CookieLaxForcedForBeta"),
AutoTArray<nsString, 2>{NS_ConvertUTF8toUTF16(aCookieData.name()),
SAMESITE_MDN_URL});
LogMessageToConsole(aChannel, aHostURI, nsIScriptError::warningFlag,
CONSOLE_SAMESITE_CATEGORY,
NS_LITERAL_CSTRING("CookieLaxForcedForBeta"),
aCookieData.name(), SAMESITE_MDN_URL);
}
}
@ -3933,7 +3917,8 @@ void nsCookieService::LogMessageToConsole(nsIChannel* aChannel, nsIURI* aURI,
uint32_t aErrorFlags,
const nsACString& aCategory,
const nsACString& aMsg,
const nsTArray<nsString>& aParams) {
const nsACString& aCookieName,
const nsAString& aMDNURL) {
MOZ_ASSERT(aURI);
nsCOMPtr<HttpBaseChannel> httpChannel = do_QueryInterface(aChannel);
@ -3947,9 +3932,15 @@ void nsCookieService::LogMessageToConsole(nsIChannel* aChannel, nsIURI* aURI,
return;
}
AutoTArray<nsString, 1> params = {NS_ConvertUTF8toUTF16(aCookieName)};
if (!aMDNURL.IsEmpty()) {
params.AppendElement(aMDNURL);
}
httpChannel->AddConsoleReport(aErrorFlags, aCategory,
nsContentUtils::eNECKO_PROPERTIES, uri, 0, 0,
aMsg, aParams);
aMsg, params);
}
/******************************************************************************
@ -4262,8 +4253,7 @@ nsAutoCString nsCookieService::GetPathFromURI(nsIURI* aHostURI) {
return path;
}
bool nsCookieService::CheckPath(CookieStruct& aCookieData, nsIChannel* aChannel,
nsIURI* aHostURI) {
bool nsCookieService::CheckPath(CookieStruct& aCookieData, nsIURI* aHostURI) {
// if a path is given, check the host has permission
if (aCookieData.path().IsEmpty() || aCookieData.path().First() != '/') {
aCookieData.path() = GetPathFromURI(aHostURI);
@ -4285,23 +4275,9 @@ bool nsCookieService::CheckPath(CookieStruct& aCookieData, nsIChannel* aChannel,
#endif
}
if (aCookieData.path().Length() > kMaxBytesPerPath) {
AutoTArray<nsString, 2> params = {
NS_ConvertUTF8toUTF16(aCookieData.name())};
nsString size;
size.AppendInt(kMaxBytesPerPath);
params.AppendElement(size);
LogMessageToConsole(aChannel, aHostURI, nsIScriptError::warningFlag,
CONSOLE_GENERIC_CATEGORY,
NS_LITERAL_CSTRING("CookiePathOversize"), params);
if (aCookieData.path().Length() > kMaxBytesPerPath ||
aCookieData.path().Contains('\t'))
return false;
}
if (aCookieData.path().Contains('\t')) {
return false;
}
return true;
}

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

@ -307,7 +307,7 @@ class nsCookieService final : public nsICookieService,
nsIURI* aHostURI, const nsCString& aBaseDomain,
bool aRequireHostMatch);
static bool CheckPath(mozilla::net::CookieStruct& aCookieData,
nsIChannel* aChannel, nsIURI* aHostURI);
nsIURI* aHostURI);
static bool CheckPrefixes(mozilla::net::CookieStruct& aCookieData,
bool aSecureRequest);
static bool GetExpiry(mozilla::net::CookieStruct& aCookieData,
@ -353,7 +353,8 @@ class nsCookieService final : public nsICookieService,
uint32_t aErrorFlags,
const nsACString& aCategory,
const nsACString& aMsg,
const nsTArray<nsString>& aParams);
const nsACString& aCookieName,
const nsAString& aMDNURL = VoidString());
// cached members.
nsCOMPtr<nsICookiePermission> mPermissionService;

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

@ -16,5 +16,3 @@ support-files = server.sjs
skip-if = fission #Bug 1582318
[browser_sameSiteConsole.js]
support-files = sameSite.sjs
[browser_oversize.js]
support-files = oversize.sjs

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

@ -1,94 +0,0 @@
const OVERSIZE_DOMAIN = "http://example.com/";
const OVERSIZE_PATH = "browser/netwerk/cookie/test/browser/";
const OVERSIZE_TOP_PAGE = OVERSIZE_DOMAIN + OVERSIZE_PATH + "oversize.sjs";
add_task(async _ => {
const expected = [];
const consoleListener = {
observe(what) {
if (!(what instanceof Ci.nsIConsoleMessage)) {
return;
}
info("Console Listener: " + what);
for (let i = expected.length - 1; i >= 0; --i) {
const e = expected[i];
if (what.message.includes(e.match)) {
ok(true, "Message received: " + e.match);
expected.splice(i, 1);
e.resolve();
}
}
},
};
Services.console.registerListener(consoleListener);
registerCleanupFunction(() =>
Services.console.unregisterListener(consoleListener)
);
const netPromises = [
new Promise(resolve => {
expected.push({
resolve,
match:
"Cookie “a” is invalid because its size is too big. Max size is 4096 bytes.",
});
}),
new Promise(resolve => {
expected.push({
resolve,
match:
"Cookie “b” is invalid because its path size is too big. Max size is 1024 bytes.",
});
}),
];
// Let's open our tab.
const tab = BrowserTestUtils.addTab(gBrowser, OVERSIZE_TOP_PAGE);
gBrowser.selectedTab = tab;
const browser = gBrowser.getBrowserForTab(tab);
await BrowserTestUtils.browserLoaded(browser);
// Let's wait for the first set of console events.
await Promise.all(netPromises);
// the DOM list of events.
const domPromises = [
new Promise(resolve => {
expected.push({
resolve,
match:
"Cookie “d” is invalid because its size is too big. Max size is 4096 bytes.",
});
}),
new Promise(resolve => {
expected.push({
resolve,
match:
"Cookie “e” is invalid because its path size is too big. Max size is 1024 bytes.",
});
}),
];
// Let's use document.cookie
SpecialPowers.spawn(browser, [], () => {
const maxBytesPerCookie = 4096;
const maxBytesPerCookiePath = 1024;
content.document.cookie = "d=" + Array(maxBytesPerCookie + 1).join("x");
content.document.cookie =
"e=f; path=/" + Array(maxBytesPerCookiePath + 1).join("x");
});
// Let's wait for the dom events.
await Promise.all(domPromises);
// Let's close the tab.
BrowserTestUtils.removeTab(tab);
});

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

@ -1,9 +0,0 @@
function handleRequest(aRequest, aResponse) {
aResponse.setStatusLine(aRequest.httpVersion, 200);
const maxBytesPerCookie = 4096;
const maxBytesPerCookiePath = 1024;
aResponse.setHeader("Set-Cookie", "a=" + Array(maxBytesPerCookie + 1).join('x'), true);
aResponse.setHeader("Set-Cookie", "b=c; path=/" + Array(maxBytesPerCookiePath + 1).join('x'), true);
}

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

@ -59,7 +59,3 @@ CookieLaxForced=Cookie “%1$S” has “sameSite” policy set to “lax” bec
CookieLaxForcedForBeta=Cookie “%1$S” does not have a proper “sameSite” attribute value. Soon, cookies without the “sameSite” attribute or with an invalid value will be treated as “lax”. This means that the cookie will no longer be sent in third-party contexts. If your application depends on this cookie being available in such contexts, please add the “sameSite=none“ attribute to it. To know more about the “sameSite“ attribute, read %2$S
# LOCALIZATION NOTE: %1$S is cookie name. Do not localize "sameSite", "lax", "strict" and "none"
CookieSameSiteValueInvalid=Invalid “sameSite“ value for cookie “%1$S”. The supported values are: “lax“, “strict“, “none“.
# LOCALIZATION NOTE (CookieOversize): %1$S is the cookie name. %2$S is the number of bytes. "B" means bytes.
CookieOversize=Cookie “%1$S” is invalid because its size is too big. Max size is %2$S B.
# LOCALIZATION NOTE (CookiePathOversiz): %1$S is the cookie name. %2$S is the number of bytes. "B" means bytes.
CookiePathOversize=Cookie “%1$S” is invalid because its path size is too big. Max size is %2$S B.