Changeset 203221 in webkit
- Timestamp:
- Jul 14, 2016 3:14:53 AM (8 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r203219 r203221 1 2016-07-14 Youenn Fablet <youenn@apple.com> 2 3 [Fetch API] Request and Response url getter should use URL serialization 4 https://bugs.webkit.org/show_bug.cgi?id=159705 5 6 Reviewed by Alex Christensen. 7 8 * fetch/fetch-url-serialization-expected.txt: Added. 9 * fetch/fetch-url-serialization.html: Added. 10 * fetch/fetch-urls.json: Added. 11 1 12 2016-07-14 Jer Noble <jer.noble@apple.com> 2 13 -
trunk/LayoutTests/imported/w3c/ChangeLog
r203201 r203221 1 2016-07-14 Youenn Fablet <youenn@apple.com> 2 3 [Fetch API] Request and Response url getter should use URL serialization 4 https://bugs.webkit.org/show_bug.cgi?id=159705 5 6 Reviewed by Alex Christensen. 7 8 * web-platform-tests/fetch/api/basic/response-url-expected.txt: Added. 9 * web-platform-tests/fetch/api/basic/response-url-worker-expected.txt: Added. 10 * web-platform-tests/fetch/api/basic/response-url-worker.html: Added. 11 * web-platform-tests/fetch/api/basic/response-url.html: Added. 12 * web-platform-tests/fetch/api/basic/response-url.js: Added. 13 (checkResponseURL): 14 * web-platform-tests/fetch/api/request/request-init-003.sub-expected.txt: 15 * web-platform-tests/fetch/api/request/request-init-003.sub.html: 16 1 17 2016-07-13 Jiewen Tan <jiewen_tan@apple.com> 2 18 -
trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/response-url-expected.txt
r203164 r203221 1 1 2 2 PASS Testing response url getter with http://localhost:8800/ada 3 FAIL Testing response url getter with http://localhost:8800/# assert_equals: expected "http://localhost:8800/" but got "http://localhost:8800/#" 4 FAIL Testing response url getter with http://localhost:8800/#ada assert_equals: expected "http://localhost:8800/" but got "http://localhost:8800/#ada" 5 FAIL Testing response url getter with http://localhost:8800#ada assert_equals: expected "http://localhost:8800/" but got "http://localhost:8800/#ada" 3 PASS Testing response url getter with http://localhost:8800/# 4 PASS Testing response url getter with http://localhost:8800/#ada 5 PASS Testing response url getter with http://localhost:8800#ada 6 6 -
trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/response-url-worker-expected.txt
r203164 r203221 1 1 2 2 PASS Testing response url getter with http://localhost:8800/ada 3 FAIL Testing response url getter with http://localhost:8800/# assert_equals: expected "http://localhost:8800/" but got "http://localhost:8800/#" 4 FAIL Testing response url getter with http://localhost:8800/#ada assert_equals: expected "http://localhost:8800/" but got "http://localhost:8800/#ada" 5 FAIL Testing response url getter with http://localhost:8800#ada assert_equals: expected "http://localhost:8800/" but got "http://localhost:8800/#ada" 3 PASS Testing response url getter with http://localhost:8800/# 4 PASS Testing response url getter with http://localhost:8800/#ada 5 PASS Testing response url getter with http://localhost:8800#ada 6 6 -
trunk/Source/WebCore/ChangeLog
r203220 r203221 1 2016-07-14 Youenn Fablet <youenn@apple.com> 2 3 [Fetch API] Request and Response url getter should use URL serialization 4 https://bugs.webkit.org/show_bug.cgi?id=159705 5 6 Reviewed by Alex Christensen. 7 8 Tests: fetch/fetch-url-serialization.html 9 imported/w3c/web-platform-tests/fetch/api/basic/response-url-worker.html 10 imported/w3c/web-platform-tests/fetch/api/basic/response-url.html 11 12 Implementing https://url.spec.whatwg.org/#concept-url-serializer and applying it to Request and Response getter. 13 Adding a temporary routine to compute url cannot-be-a-base-url flag. The parsing routine should store that 14 information in the URL itself. 15 16 Added tests to cover serialization routine. Failing tests are mostly due to limitations of the URL parser. 17 Tests do not check for URLs with username and password as Request constructor throws with such URLs. 18 19 * Modules/fetch/FetchRequest.cpp: 20 (WebCore::FetchRequest::url): Adding request url serialization, fragment included. 21 * Modules/fetch/FetchRequest.h: 22 * Modules/fetch/FetchResponse.cpp: 23 (WebCore::FetchResponse::url): Adding response url serialization, fragment excluded. 24 * Modules/fetch/FetchResponse.h: 25 * platform/URL.cpp: 26 (WebCore::cannotBeABaseURL): Temporary helper function to have a coarse evaluation of url cannot-be-a-base-url flag. 27 (WebCore::URL::serialize): Implementation of https://url.spec.whatwg.org/#concept-url-serializer. 28 * platform/URL.h: 29 (WebCore::URL::hasUser): Helper getter. 30 (WebCore::URL::hasPassword): Ditto. 31 (WebCore::URL::hasQuery): Ditto. 32 (WebCore::URL::hasFragment): Ditto. 33 1 34 2016-07-14 Sergio Villar Senin <svillar@igalia.com> 2 35 -
trunk/Source/WebCore/Modules/fetch/FetchRequest.cpp
r202323 r203221 311 311 } 312 312 313 const String& FetchRequest::url() const 314 { 315 if (m_requestURL.isNull()) 316 m_requestURL = m_internalRequest.request.url().serialize(); 317 return m_requestURL; 318 } 319 313 320 ResourceRequest FetchRequest::internalRequest() const 314 321 { -
trunk/Source/WebCore/Modules/fetch/FetchRequest.h
r200361 r203221 50 50 51 51 const String& method() const { return m_internalRequest.request.httpMethod(); } 52 const String& url() const { return m_internalRequest.request.url().string(); }52 const String& url() const; 53 53 FetchHeaders& headers() { return m_headers.get(); } 54 54 … … 99 99 Ref<FetchHeaders> m_headers; 100 100 InternalRequest m_internalRequest; 101 mutable String m_requestURL; 101 102 }; 102 103 -
trunk/Source/WebCore/Modules/fetch/FetchResponse.cpp
r203162 r203221 152 152 } 153 153 154 const String& FetchResponse::url() const 155 { 156 if (m_responseURL.isNull()) 157 m_responseURL = m_response.url().serialize(true); 158 return m_responseURL; 159 } 160 154 161 void FetchResponse::fetch(ScriptExecutionContext& context, const String& url, const Dictionary& dictionary, FetchPromise&& promise) 155 162 { -
trunk/Source/WebCore/Modules/fetch/FetchResponse.h
r203162 r203221 62 62 63 63 Type type() const { return m_response.type(); } 64 const String& url() const { return m_response.url().string(); }64 const String& url() const; 65 65 bool redirected() const { return m_response.isRedirected(); } 66 66 int status() const { return m_response.httpStatusCode(); } … … 114 114 Ref<FetchHeaders> m_headers; 115 115 Optional<BodyLoader> m_bodyLoader; 116 mutable String m_responseURL; 116 117 }; 117 118 -
trunk/Source/WebCore/platform/URL.cpp
r203013 r203221 1194 1194 } 1195 1195 1196 static inline bool cannotBeABaseURL(const URL& url) 1197 { 1198 // FIXME: Support https://url.spec.whatwg.org/#url-cannot-be-a-base-url-flag properly 1199 // According spec, this should be computed at parsing time. 1200 // For the moment, we just check whether the scheme is special or not. 1201 if (url.protocolIs("ftp") || url.protocolIs("file") || url.protocolIs("gopher") || url.protocolIs("http") || url.protocolIs("https") || url.protocolIs("ws") || url.protocolIs("wss")) 1202 return false; 1203 return true; 1204 } 1205 1206 // Implementation of https://url.spec.whatwg.org/#url-serializing 1207 String URL::serialize(bool omitFragment) const 1208 { 1209 if (isNull()) 1210 return String(); 1211 1212 StringBuilder urlBuilder; 1213 urlBuilder.append(m_string, 0, m_schemeEnd); 1214 urlBuilder.append(":"); 1215 int start = hostStart(); 1216 if (start < m_hostEnd) { 1217 urlBuilder.append("//"); 1218 if (hasUsername()) { 1219 urlBuilder.append(m_string, m_userStart, m_userEnd - m_userStart); 1220 int passwordStart = m_userEnd + 1; 1221 if (hasPassword()) { 1222 urlBuilder.append(":"); 1223 urlBuilder.append(m_string, passwordStart, m_passwordEnd - passwordStart); 1224 } 1225 urlBuilder.append("@"); 1226 } 1227 // FIXME: Serialize host according https://url.spec.whatwg.org/#concept-host-serializer for IPv4 and IPv6 addresses. 1228 urlBuilder.append(m_string, start, m_hostEnd - start); 1229 if (hasPort()) { 1230 urlBuilder.append(":"); 1231 urlBuilder.appendNumber(port()); 1232 } 1233 } else if (protocolIs("file")) 1234 urlBuilder.append("//"); 1235 if (cannotBeABaseURL(*this)) 1236 urlBuilder.append(m_string, m_portEnd, m_pathEnd - m_portEnd); 1237 else { 1238 urlBuilder.append("/"); 1239 if (m_pathEnd > m_portEnd) { 1240 int pathStart = m_portEnd + 1; 1241 urlBuilder.append(m_string, pathStart, m_pathEnd - pathStart); 1242 } 1243 } 1244 if (hasQuery()) { 1245 urlBuilder.append("?"); 1246 urlBuilder.append(m_string, m_pathEnd + 1, m_queryEnd - (m_pathEnd + 1)); 1247 } 1248 if (!omitFragment && hasFragment()) { 1249 urlBuilder.append("#"); 1250 urlBuilder.append(m_string, m_queryEnd + 1, m_fragmentEnd - (m_queryEnd + 1)); 1251 } 1252 return urlBuilder.toString(); 1253 } 1254 1196 1255 #if PLATFORM(IOS) 1197 1256 static bool shouldCanonicalizeScheme = true; -
trunk/Source/WebCore/platform/URL.h
r203013 r203221 115 115 WEBCORE_EXPORT bool hasFragmentIdentifier() const; 116 116 117 bool hasUsername() const; 118 bool hasPassword() const; 119 bool hasQuery() const; 120 bool hasFragment() const; 121 117 122 // Unlike user() and pass(), these functions don't decode escape sequences. 118 123 // This is necessary for accurate round-tripping, because encoding doesn't encode '%' characters. … … 198 203 template <class Encoder> void encode(Encoder&) const; 199 204 template <class Decoder> static bool decode(Decoder&, URL&); 205 206 String serialize(bool omitFragment = false) const; 200 207 201 208 private: … … 391 398 } 392 399 400 inline bool URL::hasUsername() const 401 { 402 return m_userEnd > m_userStart; 403 } 404 405 inline bool URL::hasPassword() const 406 { 407 return m_passwordEnd > (m_userEnd + 1); 408 } 409 410 inline bool URL::hasQuery() const 411 { 412 return m_queryEnd > m_pathEnd; 413 } 414 415 inline bool URL::hasFragment() const 416 { 417 return m_fragmentEnd > m_queryEnd; 418 } 419 393 420 inline bool URL::protocolIsInHTTPFamily() const 394 421 {
Note: See TracChangeset
for help on using the changeset viewer.