Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fetch: align about:blank handling with the standard #10421

Merged
merged 3 commits into from Apr 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
37 changes: 10 additions & 27 deletions fetch/api/basic/scheme-about.any.js
@@ -1,34 +1,17 @@
// META: script=../resources/utils.js

function checkFetchResponse(url, method, desc) {
if (!desc) {
var cut = (url.length >= 40) ? "[...]" : "";
cut += " (" + method + ")"
desc = "Fetching " + url.substring(0, 40) + cut + " is OK"
}
function checkNetworkError(url, method) {
method = method || "GET";
const desc = "Fetching " + url.substring(0, 45) + " with method " + method + " is KO"
promise_test(function(test) {
return fetch(url, { method: method }).then(function(resp) {
assert_equals(resp.status, 200, "HTTP status is 200");
assert_equals(resp.type, "basic", "response type is basic");
assert_equals(resp.headers.get("Content-Type"), "text/html;charset=utf-8", "Content-Type is " + resp.headers.get("Content-Type"));
return resp.text();
})
}, desc);
}

checkFetchResponse("about:blank", "GET");
checkFetchResponse("about:blank", "PUT");
checkFetchResponse("about:blank", "POST");

function checkKoUrl(url, desc) {
if (!desc)
desc = "Fetching " + url.substring(0, 45) + " is KO"
promise_test(function(test) {
var promise = fetch(url);
var promise = fetch(url, { method: method });
return promise_rejects(test, new TypeError(), promise);
}, desc);
}

checkKoUrl("about:invalid.com");
checkKoUrl("about:config");
checkKoUrl("about:unicorn");
checkNetworkError("about:blank", "GET");
checkNetworkError("about:blank", "PUT");
checkNetworkError("about:blank", "POST");
checkNetworkError("about:invalid.com");
checkNetworkError("about:config");
checkNetworkError("about:unicorn");
6 changes: 3 additions & 3 deletions fetch/api/headers/header-values-normalize.html
Expand Up @@ -56,9 +56,9 @@
promise_test((t) => {
if(fail) {
return Promise.all([
promise_rejects(t, new TypeError(), fetch("about:blank", { headers: {"val1": val1} })),
promise_rejects(t, new TypeError(), fetch("about:blank", { headers: {"val2": val2} })),
promise_rejects(t, new TypeError(), fetch("about:blank", { headers: {"val3": val3} }))
promise_rejects(t, new TypeError(), fetch(url, { headers: {"val1": val1} })),
promise_rejects(t, new TypeError(), fetch(url, { headers: {"val2": val2} })),
promise_rejects(t, new TypeError(), fetch(url, { headers: {"val3": val3} }))
])
} else {
return fetch(url, { headers: {"val1": val1, "val2": val2, "val3": val3} }).then((res) => {
Expand Down
2 changes: 1 addition & 1 deletion fetch/api/headers/header-values.html
Expand Up @@ -15,7 +15,7 @@
assert_throws("SyntaxError", () => xhr.setRequestHeader("value-test", val))
}, "XMLHttpRequest with value " + encodeURI(val) + " needs to throw")

promise_test(t => promise_rejects(t, new TypeError(), fetch("about:blank", { headers: {"value-test": val} })), "fetch() with value " + encodeURI(val) + " needs to throw")
promise_test(t => promise_rejects(t, new TypeError(), fetch("/", { headers: {"value-test": val} })), "fetch() with value " + encodeURI(val) + " needs to throw")
})

// Valid values
Expand Down