Skip to content

Commit 42837d7

Browse files
committed
Fetch: ensure preflight is required for Authorization/Range
Plus some minor cleanup. We will likely have to treat Range as a special case for media elements (see whatwg/fetch#145) so creating this to ensure that only happens when Range is set by the user agent.
1 parent 0f74915 commit 42837d7

File tree

3 files changed

+4
-9
lines changed

3 files changed

+4
-9
lines changed

fetch/api/cors/resources/not-cors-safelisted.json

+2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
["accept", "012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678"],
44
["accept-language", "\u0001"],
55
["accept-language", "@"],
6+
["authorization", "basics"],
67
["content-language", "\u0001"],
78
["content-language", "@"],
89
["content-type", "text/html"],
910
["content-type", "text/plain; long=0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901"],
11+
["range", "bytes 0-"],
1012
["test", "hi"]
1113
]
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
// META: global=window,worker
2-
// META: script=../resources/utils.js
32

43
function basicAuth(desc, user, pass, mode, status) {
54
promise_test(function(test) {
65
var headers = { "Authorization": "Basic " + btoa(user + ":" + pass)};
76
var requestInit = {"credentials": mode, "headers": headers};
8-
return fetch(RESOURCES_DIR + "authentication.py?realm=test", requestInit).then(function(resp) {
7+
return fetch("../resources/authentication.py?realm=test", requestInit).then(function(resp) {
98
assert_equals(resp.status, status, "HTTP status is " + status);
109
assert_equals(resp.type , "basic", "Response's type is basic");
1110
});
@@ -15,3 +14,4 @@ function basicAuth(desc, user, pass, mode, status) {
1514
basicAuth("User-added Authorization header with include mode", "user", "password", "include", 200);
1615
basicAuth("User-added Authorization header with same-origin mode", "user", "password", "same-origin", 200);
1716
basicAuth("User-added Authorization header with omit mode", "user", "password", "omit", 200);
17+
basicAuth("User-added bogus Authorization header with omit mode", "notuser", "notpassword", "omit", 401);

fetch/api/resources/utils.js

-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
1-
var inWorker = false;
21
var RESOURCES_DIR = "../resources/";
32

4-
try {
5-
inWorker = !(self instanceof Window);
6-
} catch (e) {
7-
inWorker = true;
8-
}
9-
103
function dirname(path) {
114
return path.replace(/\/[^\/]*$/, '/')
125
}

0 commit comments

Comments
 (0)