Skip to content

Commit

Permalink
Bug 1687453 [wpt PR 27240] - Fetch: ensure preflight is required for …
Browse files Browse the repository at this point in the history
…Authorization/Range, a=testonly

Automatic update from web-platform-tests
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.

--

wpt-commits: 56116583e8a403e4b9d410c1429a83fbb96397f4
wpt-pr: 27240
  • Loading branch information
annevk authored and moz-wptsync-bot committed Feb 8, 2021
1 parent 301f185 commit 89c87bb
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
["accept", "012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678"],
["accept-language", "\u0001"],
["accept-language", "@"],
["authorization", "basics"],
["content-language", "\u0001"],
["content-language", "@"],
["content-type", "text/html"],
["content-type", "text/plain; long=0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901"],
["range", "bytes 0-"],
["test", "hi"]
]
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
// META: global=window,worker
// META: script=../resources/utils.js

function basicAuth(desc, user, pass, mode, status) {
promise_test(function(test) {
var headers = { "Authorization": "Basic " + btoa(user + ":" + pass)};
var requestInit = {"credentials": mode, "headers": headers};
return fetch(RESOURCES_DIR + "authentication.py?realm=test", requestInit).then(function(resp) {
return fetch("../resources/authentication.py?realm=test", requestInit).then(function(resp) {
assert_equals(resp.status, status, "HTTP status is " + status);
assert_equals(resp.type , "basic", "Response's type is basic");
});
Expand All @@ -15,3 +14,4 @@ function basicAuth(desc, user, pass, mode, status) {
basicAuth("User-added Authorization header with include mode", "user", "password", "include", 200);
basicAuth("User-added Authorization header with same-origin mode", "user", "password", "same-origin", 200);
basicAuth("User-added Authorization header with omit mode", "user", "password", "omit", 200);
basicAuth("User-added bogus Authorization header with omit mode", "notuser", "notpassword", "omit", 401);
7 changes: 0 additions & 7 deletions testing/web-platform/tests/fetch/api/resources/utils.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
var inWorker = false;
var RESOURCES_DIR = "../resources/";

try {
inWorker = !(self instanceof Window);
} catch (e) {
inWorker = true;
}

function dirname(path) {
return path.replace(/\/[^\/]*$/, '/')
}
Expand Down

0 comments on commit 89c87bb

Please sign in to comment.