mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-31 11:37:30 +09:00
Bug 1298823 - Fix Request constructor - with "mode: navigate"
This commit is contained in:
parent
98546534b0
commit
56c088c2d4
3 changed files with 17 additions and 33 deletions
|
|
@ -338,8 +338,7 @@ Request::Constructor(const GlobalObject& aGlobal,
|
||||||
|
|
||||||
if (mode == RequestMode::Navigate ||
|
if (mode == RequestMode::Navigate ||
|
||||||
(aInit.IsAnyMemberPresent() && request->Mode() == RequestMode::Navigate)) {
|
(aInit.IsAnyMemberPresent() && request->Mode() == RequestMode::Navigate)) {
|
||||||
aRv.ThrowTypeError<MSG_INVALID_REQUEST_MODE>(NS_LITERAL_STRING("navigate"));
|
mode = RequestMode::Same_origin;
|
||||||
return nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aInit.IsAnyMemberPresent()) {
|
if (aInit.IsAnyMemberPresent()) {
|
||||||
|
|
@ -374,11 +373,7 @@ Request::Constructor(const GlobalObject& aGlobal,
|
||||||
nsresult rv = principal->CheckMayLoad(uri, /* report */ false,
|
nsresult rv = principal->CheckMayLoad(uri, /* report */ false,
|
||||||
/* allowIfInheritsPrincipal */ false);
|
/* allowIfInheritsPrincipal */ false);
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
nsAutoCString globalOrigin;
|
referrerURL.AssignLiteral(kFETCH_CLIENT_REFERRER_STR);
|
||||||
principal->GetOrigin(globalOrigin);
|
|
||||||
aRv.ThrowTypeError<MSG_CROSS_ORIGIN_REFERRER_URL>(referrer,
|
|
||||||
NS_ConvertUTF8toUTF16(globalOrigin));
|
|
||||||
return nullptr;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -403,11 +398,10 @@ Request::Constructor(const GlobalObject& aGlobal,
|
||||||
// this work in a single sync loop.
|
// this work in a single sync loop.
|
||||||
RefPtr<ReferrerSameOriginChecker> checker =
|
RefPtr<ReferrerSameOriginChecker> checker =
|
||||||
new ReferrerSameOriginChecker(worker, referrerURL, rv);
|
new ReferrerSameOriginChecker(worker, referrerURL, rv);
|
||||||
checker->Dispatch(Terminating, aRv);
|
IgnoredErrorResult error;
|
||||||
if (aRv.Failed() || NS_FAILED(rv)) {
|
checker->Dispatch(Terminating, error);
|
||||||
aRv.ThrowTypeError<MSG_CROSS_ORIGIN_REFERRER_URL>(referrer,
|
if (error.Failed() || NS_FAILED(rv)) {
|
||||||
worker->GetLocationInfo().mOrigin);
|
referrerURL.AssignLiteral(kFETCH_CLIENT_REFERRER_STR);
|
||||||
return nullptr;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -152,12 +152,9 @@ function testHeaderGuard() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function testMode() {
|
function testMode() {
|
||||||
try {
|
var req = new Request("http://example.com", {mode: "navigate"});
|
||||||
var req = new Request("http://example.com", {mode: "navigate"});
|
ok(true, "Creating a Request with navigate RequestMode should not throw.");
|
||||||
ok(false, "Creating a Request with navigate RequestMode should throw a TypeError");
|
is(req.mode, "same-origin", "Request mode becomes same-origin");
|
||||||
} catch(e) {
|
|
||||||
is(e.name, "TypeError", "Creating a Request with navigate RequestMode should throw a TypeError");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function testMethod() {
|
function testMethod() {
|
||||||
|
|
|
||||||
|
|
@ -148,28 +148,21 @@ onfetch = function(ev) {
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (ev.request.url.includes("navigate.html")) {
|
else if (ev.request.url.includes("navigate.html")) {
|
||||||
var navigateModeCorrectlyChecked = false;
|
|
||||||
var requests = [ // should not throw
|
var requests = [ // should not throw
|
||||||
new Request(ev.request),
|
new Request(ev.request),
|
||||||
new Request(ev.request, undefined),
|
new Request(ev.request, undefined),
|
||||||
new Request(ev.request, null),
|
new Request(ev.request, null),
|
||||||
new Request(ev.request, {}),
|
new Request(ev.request, {}),
|
||||||
new Request(ev.request, {someUnrelatedProperty: 42}),
|
new Request(ev.request, {someUnrelatedProperty: 42}),
|
||||||
|
new Request(ev.request, {method: "GET"}),
|
||||||
];
|
];
|
||||||
try {
|
ev.respondWith(Promise.resolve(
|
||||||
var request3 = new Request(ev.request, {method: "GET"}); // should throw
|
new Response("<script>window.frameElement.test_result = true;</script>", {
|
||||||
} catch(e) {
|
headers : {
|
||||||
navigateModeCorrectlyChecked = requests[0].mode == "navigate";
|
"Content-Type": "text/html"
|
||||||
}
|
}
|
||||||
if (navigateModeCorrectlyChecked) {
|
})
|
||||||
ev.respondWith(Promise.resolve(
|
));
|
||||||
new Response("<script>window.frameElement.test_result = true;</script>", {
|
|
||||||
headers : {
|
|
||||||
"Content-Type": "text/html"
|
|
||||||
}
|
|
||||||
})
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (ev.request.url.includes("nonexistent_worker_script.js")) {
|
else if (ev.request.url.includes("nonexistent_worker_script.js")) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue