Chromium Code Reviews| Index: third_party/WebKit/Source/modules/fetch/Request.cpp |
| diff --git a/third_party/WebKit/Source/modules/fetch/Request.cpp b/third_party/WebKit/Source/modules/fetch/Request.cpp |
| index 6cc792b88301ee34dc12b0111f299471192655fa..8c1fd8a33553ee18bd4c05348367624d7910b88f 100644 |
| --- a/third_party/WebKit/Source/modules/fetch/Request.cpp |
| +++ b/third_party/WebKit/Source/modules/fetch/Request.cpp |
| @@ -120,15 +120,23 @@ Request* Request::createRequestWithRequestOrString(ScriptState* scriptState, Req |
| // We don't use fallback values. We set these flags directly in below. |
| } |
| - // 14. If any of |init|'s members are present, set |request|'s referrer |
| - // to client, and |request|'s referrer policy to the empty string. |
| - // => RequestInit::RequestInit. |
| + // "14. If any of |init|'s members are present, run these substeps:" |
| + if (init.areAnyMembersSet) { |
| + // "1. If request's |mode| is "navigate", throw a TypeError." |
| + if (request->mode() == WebURLRequest::FetchRequestModeNavigate) { |
| + exceptionState.throwTypeError("Cannot construct a Request with a Request mode as navigate."); |
| + return nullptr; |
| + } |
| + } |
| + |
| // 15. If |init|'s referrer member is present, run these substeps: |
| // Note that JS null and undefined are encoded as an empty string and thus |
| // a null string means referrer member is not set. |
| // 16. If |init|'s referrerPolicy member is present, set |request|'s |
| // referrer policy to it. |
| - if (init.isReferrerSet) { |
| + // areAnyMembersSet will be True, if any members in RequestInit are set and |
| + // hence the referrer member |
|
Mike West
2015/10/20 07:27:04
Nit: hence the referrer member what?
shiva.jm
2015/10/21 08:34:59
actually below condition is checking,
If |init|'s
|
| + if (init.areAnyMembersSet) { |
| // 1. Let |referrer| be |init|'s referrer member. |
| if (init.referrer.referrer.isEmpty()) { |
| // 2. if |referrer| is the empty string, set |request|'s referrer to |
| @@ -161,10 +169,14 @@ Request* Request::createRequestWithRequestOrString(ScriptState* scriptState, Req |
| request->setReferrerPolicy(init.referrer.referrerPolicy); |
| } |
| - |
| - // "17. Let |mode| be |init|'s mode member if it is present, and |
| + // "16. Let |mode| be |init|'s mode member if it is present, and |
| // |fallbackMode| otherwise." |
| + // "17.If mode is "navigate", throw a TypeError. |
| // "18. If |mode| is non-null, set |request|'s mode to |mode|." |
| + if (init.mode == "navigate") { |
| + exceptionState.throwTypeError("Cannot construct a Request with a Request mode as navigate."); |
| + return nullptr; |
| + } |
| if (init.mode == "same-origin") { |
| request->setMode(WebURLRequest::FetchRequestModeSameOrigin); |
| } else if (init.mode == "no-cors") { |
| @@ -497,6 +509,8 @@ String Request::mode() const |
| case WebURLRequest::FetchRequestModeCORS: |
| case WebURLRequest::FetchRequestModeCORSWithForcedPreflight: |
| return "cors"; |
| + case WebURLRequest::FetchRequestModeNavigate: |
| + return "navigate"; |
| } |
| ASSERT_NOT_REACHED(); |
| return ""; |