Make Request throw less often (fixes #13457)

This commit is contained in:
Mathieu Hordesseaux 2016-10-03 13:43:59 +02:00 committed by Josh Matthews
parent ec5ed8edfd
commit 6f97ce826b
6 changed files with 15 additions and 29 deletions

View file

@ -183,9 +183,8 @@ impl Request {
!init.window.handle().is_undefined() {
// Step 13.1
if request.mode == NetTraitsRequestMode::Navigate {
return Err(Error::Type(
"Init is present and request mode is 'navigate'".to_string()));
}
request.mode = NetTraitsRequestMode::SameOrigin;
}
// Step 13.2
request.omit_origin_header.set(false);
// Step 13.3
@ -211,17 +210,13 @@ impl Request {
}
// Step 14.5
if let Ok(parsed_referrer) = parsed_referrer {
if parsed_referrer.cannot_be_a_base() &&
if (parsed_referrer.cannot_be_a_base() &&
parsed_referrer.scheme() == "about" &&
parsed_referrer.path() == "client" {
parsed_referrer.path() == "client") ||
parsed_referrer.origin() != origin {
*request.referrer.borrow_mut() = NetTraitsRequestReferrer::Client;
} else {
// Step 14.6
if parsed_referrer.origin() != origin {
return Err(Error::Type(
"RequestInit's referrer has invalid origin".to_string()));
}
// Step 14.7
*request.referrer.borrow_mut() = NetTraitsRequestReferrer::ReferrerUrl(parsed_referrer);
}
}
@ -576,7 +571,7 @@ impl RequestMethods for Request {
let referrer = r.referrer.borrow();
USVString(match &*referrer {
&NetTraitsRequestReferrer::NoReferrer => String::from("no-referrer"),
&NetTraitsRequestReferrer::Client => String::from("client"),
&NetTraitsRequestReferrer::Client => String::from("about:client"),
&NetTraitsRequestReferrer::ReferrerUrl(ref u) => {
let u_c = u.clone();
u_c.into_string()

View file

@ -164191,7 +164191,7 @@
"testharness"
],
"fetch/api/request/request-error.html": [
"bfd03777a43be514a0839ab14f5206f486332fdb",
"ff308916884f69b3f4aa8f2017c4d9fe0caf0f00",
"testharness"
],
"fetch/api/request/request-headers.html": [
@ -164203,7 +164203,7 @@
"testharness"
],
"fetch/api/request/request-init-001.sub.html": [
"096424b40f6a21e989a6a5d8684b29ee8cbb963e",
"49bc4349b4e7a85d88cacd54227355aa986535f1",
"testharness"
],
"fetch/api/request/request-init-002.html": [

View file

@ -1,20 +1,10 @@
[request-init-001.sub.html]
type: testharness
[Check referrer init value of about:client and associated getter]
expected: FAIL
[Check referrer init value of and associated getter]
expected: FAIL
[Check referrerPolicy init value of and associated getter]
expected: FAIL
[Check referrer init value of http://test.url and associated getter]
expected: FAIL
[Check referrerPolicy init value of same-origin and associated getter]
expected: FAIL
[Check mode init value of navigate and associated getter]
expected: FAIL

View file

@ -2,7 +2,3 @@
type: testharness
[Request has arrayBuffer method]
expected: FAIL
[Check referrer attribute]
expected: FAIL

View file

@ -26,6 +26,11 @@
"Expect TypeError exception");
},"Input URL has credentials");
test(function() {
assert_throws(new TypeError() , function() { new Request("", {"mode" : "navigate"}); },
"Expect TypeError exception");
},"RequestInit's mode is navigate");
test(function() {
assert_throws(new TypeError() , function() { new Request("", {"referrer" : "http://:not a valid URL"}); },
"Expect TypeError exception");

View file

@ -49,8 +49,8 @@
"strict-origin-when-cross-origin"
]
};
var modes = {"givenValues" : ["same-origin", "no-cors", "cors", "navigate"],
"expectedValues" : ["same-origin", "no-cors", "cors", "same-origin"]
var modes = {"givenValues" : ["same-origin", "no-cors", "cors"],
"expectedValues" : ["same-origin", "no-cors", "cors"]
};
var credentials = {"givenValues" : ["omit", "same-origin", "include"],
"expectedValues" : ["omit", "same-origin", "include"]