-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1452562 [wpt PR 10348] - Allow range headers to pass through a se…
…rvice worker, a=testonly Automatic update from web-platform-testsAllow range headers to pass through a service worker (#10348) Tests for whatwg/fetch#560 -- wpt-commits: fb6d16d92af29262b6137b79e61f0c4b136c6ac1 wpt-pr: 10348 UltraBlame original commit: 8b458f3d30b63afa745527bc31744f4971749224
- Loading branch information
Showing
10 changed files
with
3,929 additions
and
1 deletion.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,398 @@ | ||
function | ||
headersGuardNone | ||
( | ||
fill | ||
) | ||
{ | ||
if | ||
( | ||
fill | ||
) | ||
return | ||
new | ||
Headers | ||
( | ||
fill | ||
) | ||
; | ||
return | ||
new | ||
Headers | ||
( | ||
) | ||
; | ||
} | ||
function | ||
headersGuardResponse | ||
( | ||
fill | ||
) | ||
{ | ||
const | ||
opts | ||
= | ||
{ | ||
} | ||
; | ||
if | ||
( | ||
fill | ||
) | ||
opts | ||
. | ||
headers | ||
= | ||
fill | ||
; | ||
return | ||
new | ||
Response | ||
( | ||
' | ||
' | ||
opts | ||
) | ||
. | ||
headers | ||
; | ||
} | ||
function | ||
headersGuardRequest | ||
( | ||
fill | ||
) | ||
{ | ||
const | ||
opts | ||
= | ||
{ | ||
} | ||
; | ||
if | ||
( | ||
fill | ||
) | ||
opts | ||
. | ||
headers | ||
= | ||
fill | ||
; | ||
return | ||
new | ||
Request | ||
( | ||
' | ||
. | ||
/ | ||
' | ||
opts | ||
) | ||
. | ||
headers | ||
; | ||
} | ||
function | ||
headersGuardRequestNoCors | ||
( | ||
fill | ||
) | ||
{ | ||
const | ||
opts | ||
= | ||
{ | ||
mode | ||
: | ||
' | ||
no | ||
- | ||
cors | ||
' | ||
} | ||
; | ||
if | ||
( | ||
fill | ||
) | ||
opts | ||
. | ||
headers | ||
= | ||
fill | ||
; | ||
return | ||
new | ||
Request | ||
( | ||
' | ||
. | ||
/ | ||
' | ||
opts | ||
) | ||
. | ||
headers | ||
; | ||
} | ||
const | ||
headerGuardTypes | ||
= | ||
[ | ||
[ | ||
' | ||
none | ||
' | ||
headersGuardNone | ||
] | ||
[ | ||
' | ||
response | ||
' | ||
headersGuardResponse | ||
] | ||
[ | ||
' | ||
request | ||
' | ||
headersGuardRequest | ||
] | ||
] | ||
; | ||
for | ||
( | ||
const | ||
[ | ||
guardType | ||
createHeaders | ||
] | ||
of | ||
headerGuardTypes | ||
) | ||
{ | ||
test | ||
( | ||
( | ||
) | ||
= | ||
> | ||
{ | ||
let | ||
headers | ||
= | ||
createHeaders | ||
( | ||
{ | ||
Range | ||
: | ||
' | ||
foo | ||
' | ||
} | ||
) | ||
; | ||
assert_equals | ||
( | ||
headers | ||
. | ||
get | ||
( | ||
' | ||
Range | ||
' | ||
) | ||
' | ||
foo | ||
' | ||
) | ||
; | ||
headers | ||
= | ||
createHeaders | ||
( | ||
) | ||
; | ||
headers | ||
. | ||
append | ||
( | ||
' | ||
Range | ||
' | ||
' | ||
foo | ||
' | ||
) | ||
; | ||
assert_equals | ||
( | ||
headers | ||
. | ||
get | ||
( | ||
' | ||
Range | ||
' | ||
) | ||
' | ||
foo | ||
' | ||
) | ||
; | ||
headers | ||
= | ||
createHeaders | ||
( | ||
) | ||
; | ||
headers | ||
. | ||
set | ||
( | ||
' | ||
Range | ||
' | ||
' | ||
foo | ||
' | ||
) | ||
; | ||
assert_equals | ||
( | ||
headers | ||
. | ||
get | ||
( | ||
' | ||
Range | ||
' | ||
) | ||
' | ||
foo | ||
' | ||
) | ||
; | ||
} | ||
Range | ||
header | ||
setting | ||
allowed | ||
for | ||
guard | ||
type | ||
: | ||
{ | ||
guardType | ||
} | ||
) | ||
; | ||
} | ||
test | ||
( | ||
( | ||
) | ||
= | ||
> | ||
{ | ||
let | ||
headers | ||
= | ||
headersGuardRequestNoCors | ||
( | ||
{ | ||
Range | ||
: | ||
' | ||
foo | ||
' | ||
} | ||
) | ||
; | ||
assert_false | ||
( | ||
headers | ||
. | ||
has | ||
( | ||
' | ||
Range | ||
' | ||
) | ||
) | ||
; | ||
headers | ||
= | ||
headersGuardRequestNoCors | ||
( | ||
) | ||
; | ||
headers | ||
. | ||
append | ||
( | ||
' | ||
Range | ||
' | ||
' | ||
foo | ||
' | ||
) | ||
; | ||
assert_false | ||
( | ||
headers | ||
. | ||
has | ||
( | ||
' | ||
Range | ||
' | ||
) | ||
) | ||
; | ||
headers | ||
= | ||
headersGuardRequestNoCors | ||
( | ||
) | ||
; | ||
headers | ||
. | ||
set | ||
( | ||
' | ||
Range | ||
' | ||
' | ||
foo | ||
' | ||
) | ||
; | ||
assert_false | ||
( | ||
headers | ||
. | ||
has | ||
( | ||
' | ||
Range | ||
' | ||
) | ||
) | ||
; | ||
} | ||
Privileged | ||
header | ||
not | ||
allowed | ||
for | ||
guard | ||
type | ||
: | ||
request | ||
- | ||
no | ||
- | ||
cors | ||
) | ||
; |
Oops, something went wrong.