Skip to content

Commit 77a17f4

Browse files
KhafraDevronag
authored andcommitted
wpt: add scheme-about.any.js
1 parent e256ace commit 77a17f4

File tree

3 files changed

+28
-17
lines changed

3 files changed

+28
-17
lines changed

lib/fetch/index.js

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -753,31 +753,17 @@ async function schemeFetch (fetchParams) {
753753
// let request be fetchParams’s request
754754
const { request } = fetchParams
755755

756-
const {
757-
protocol: scheme,
758-
pathname: path
759-
} = requestCurrentURL(request)
756+
const { protocol: scheme } = requestCurrentURL(request)
760757

761758
// switch on request’s current URL’s scheme, and run the associated steps:
762759
switch (scheme) {
763760
case 'about:': {
764761
// If request’s current URL’s path is the string "blank", then return a new response
765762
// whose status message is `OK`, header list is « (`Content-Type`, `text/html;charset=utf-8`) »,
766763
// and body is the empty byte sequence.
767-
if (path === 'blank') {
768-
const resp = makeResponse({
769-
statusText: 'OK',
770-
headersList: [
771-
['content-type', 'text/html;charset=utf-8']
772-
]
773-
})
774-
775-
resp.urlList = [new URL('about:blank')]
776-
return resp
777-
}
778764

779765
// Otherwise, return a network error.
780-
return makeNetworkError('invalid path called')
766+
return makeNetworkError('about scheme is not supported')
781767
}
782768
case 'blob:': {
783769
resolveObjectURL = resolveObjectURL || require('buffer').resolveObjectURL

lib/fetch/response.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ const { extractBody, cloneBody, mixinBody } = require('./body')
55
const util = require('../core/util')
66
const { kEnumerableProperty } = util
77
const {
8-
responseURL,
98
isValidReasonPhrase,
109
isCancelled,
1110
isAborted,
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// META: global=window,worker
2+
// META: script=../resources/utils.js
3+
4+
function checkNetworkError(url, method) {
5+
method = method || "GET";
6+
const desc = "Fetching " + url.substring(0, 45) + " with method " + method + " is KO"
7+
promise_test(function(test) {
8+
var promise = fetch(url, { method: method });
9+
return promise_rejects_js(test, TypeError, promise);
10+
}, desc);
11+
}
12+
13+
checkNetworkError("about:blank", "GET");
14+
checkNetworkError("about:blank", "PUT");
15+
checkNetworkError("about:blank", "POST");
16+
checkNetworkError("about:invalid.com");
17+
checkNetworkError("about:config");
18+
checkNetworkError("about:unicorn");
19+
20+
promise_test(function(test) {
21+
var promise = fetch("about:blank", {
22+
"method": "GET",
23+
"Range": "bytes=1-10"
24+
});
25+
return promise_rejects_js(test, TypeError, promise);
26+
}, "Fetching about:blank with range header does not affect behavior");

0 commit comments

Comments
 (0)