haikuwebkit/LayoutTests/fetch/fetch-url-serialization.html

33 lines
1.0 KiB
HTML
Raw Permalink Normal View History

[Fetch API] Request and Response url getter should use URL serialization https://bugs.webkit.org/show_bug.cgi?id=159705 Patch by Youenn Fablet <youenn@apple.com> on 2016-07-14 Reviewed by Alex Christensen. LayoutTests/imported/w3c: * web-platform-tests/fetch/api/basic/response-url-expected.txt: Added. * web-platform-tests/fetch/api/basic/response-url-worker-expected.txt: Added. * web-platform-tests/fetch/api/basic/response-url-worker.html: Added. * web-platform-tests/fetch/api/basic/response-url.html: Added. * web-platform-tests/fetch/api/basic/response-url.js: Added. (checkResponseURL): * web-platform-tests/fetch/api/request/request-init-003.sub-expected.txt: * web-platform-tests/fetch/api/request/request-init-003.sub.html: Source/WebCore: Tests: fetch/fetch-url-serialization.html imported/w3c/web-platform-tests/fetch/api/basic/response-url-worker.html imported/w3c/web-platform-tests/fetch/api/basic/response-url.html Implementing https://url.spec.whatwg.org/#concept-url-serializer and applying it to Request and Response getter. Adding a temporary routine to compute url cannot-be-a-base-url flag. The parsing routine should store that information in the URL itself. Added tests to cover serialization routine. Failing tests are mostly due to limitations of the URL parser. Tests do not check for URLs with username and password as Request constructor throws with such URLs. * Modules/fetch/FetchRequest.cpp: (WebCore::FetchRequest::url): Adding request url serialization, fragment included. * Modules/fetch/FetchRequest.h: * Modules/fetch/FetchResponse.cpp: (WebCore::FetchResponse::url): Adding response url serialization, fragment excluded. * Modules/fetch/FetchResponse.h: * platform/URL.cpp: (WebCore::cannotBeABaseURL): Temporary helper function to have a coarse evaluation of url cannot-be-a-base-url flag. (WebCore::URL::serialize): Implementation of https://url.spec.whatwg.org/#concept-url-serializer. * platform/URL.h: (WebCore::URL::hasUser): Helper getter. (WebCore::URL::hasPassword): Ditto. (WebCore::URL::hasQuery): Ditto. (WebCore::URL::hasFragment): Ditto. LayoutTests: * fetch/fetch-url-serialization-expected.txt: Added. * fetch/fetch-url-serialization.html: Added. * fetch/fetch-urls.json: Added. Canonical link: https://commits.webkit.org/177911@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@203221 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-07-14 10:14:53 +00:00
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Request URL handling</title>
<meta name="help" href="https://fetch.spec.whatwg.org/#request">
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<base id="base">
</head>
<body>
<script>
function executeTests(urls)
{
for (url of urls) {
if (url.input) {
test(function() {
document.getElementById("base").setAttribute("href", url.base);
if (url.username || url.password || url.failure)
assert_throws(new TypeError(), function() { new Request(url.input); });
else {
var request = new Request(url.input);
assert_equals(request.url, url.href);
}
}, "Testing Request url '" + url.input + "' with base '" + url.base + "'");
}
}
}
</script>
<script src="fetch-urls.json"></script>
</body>
</html>