Bug 1422456 - Origin for about: URL should not contain query or ref parts, r=smaug

This commit is contained in:
Andrea Marchesini 2018-09-14 20:07:22 +02:00
Родитель 99db42b684
Коммит d654a2915d
3 изменённых файлов: 25 добавлений и 0 удалений

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

@ -157,6 +157,18 @@ ContentPrincipal::GenerateOriginNoSuffixFromURI(nsIURI* aURI,
(NS_SUCCEEDED(origin->SchemeIs("indexeddb", &isBehaved)) && isBehaved)) {
rv = origin->GetAsciiSpec(aOriginNoSuffix);
NS_ENSURE_SUCCESS(rv, rv);
int32_t pos = aOriginNoSuffix.FindChar('?');
int32_t hashPos = aOriginNoSuffix.FindChar('#');
if (hashPos != kNotFound && (pos == kNotFound || hashPos < pos)) {
pos = hashPos;
}
if (pos != kNotFound) {
aOriginNoSuffix.Truncate(pos);
}
// These URIs could technically contain a '^', but they never should.
if (NS_WARN_IF(aOriginNoSuffix.FindChar('^', 0) != -1)) {
aOriginNoSuffix.Truncate();

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

@ -1 +1,2 @@
[browser_checkloaduri.js]
[browser_aboutOrigin.js]

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

@ -0,0 +1,12 @@
"use strict";
let tests = [ "about:robots?foo", "about:robots#foo", "about:robots?foo#bar"];
tests.forEach(async test => {
add_task(async () => {
await BrowserTestUtils.withNewTab(test, async browser => {
await ContentTask.spawn(browser, null, () => {
is(content.document.nodePrincipal.origin, "about:robots");
});
});
});
});