-
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 1455613 [wpt PR 10548] - Parsing Content-Length, a=testonly
Automatic update from web-platform-tests Fetch: parsing Content-Length For whatwg/fetch#1183. -- wpt-commits: 3a48a22074a41e7817a17dfbf5cb6c61277f8877 wpt-pr: 10548 UltraBlame original commit: 5c299636aa6340c1499f89538f61c57c9ea2c615
- Loading branch information
Showing
4 changed files
with
1,023 additions
and
0 deletions.
There are no files selected for viewing
161 changes: 161 additions & 0 deletions
161
testing/web-platform/tests/fetch/content-length/parsing.window.js
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,161 @@ | ||
promise_test | ||
( | ||
( | ||
) | ||
= | ||
> | ||
{ | ||
return | ||
fetch | ||
( | ||
" | ||
resources | ||
/ | ||
content | ||
- | ||
lengths | ||
. | ||
json | ||
" | ||
) | ||
. | ||
then | ||
( | ||
res | ||
= | ||
> | ||
res | ||
. | ||
json | ||
( | ||
) | ||
) | ||
. | ||
then | ||
( | ||
runTests | ||
) | ||
; | ||
} | ||
" | ||
Loading | ||
JSON | ||
" | ||
) | ||
; | ||
function | ||
runTests | ||
( | ||
testUnits | ||
) | ||
{ | ||
testUnits | ||
. | ||
forEach | ||
( | ||
testUnit | ||
= | ||
> | ||
{ | ||
const | ||
input | ||
= | ||
encodeURIComponent | ||
( | ||
testUnit | ||
. | ||
input | ||
) | ||
; | ||
promise_test | ||
( | ||
t | ||
= | ||
> | ||
{ | ||
const | ||
result | ||
= | ||
fetch | ||
( | ||
" | ||
resources | ||
/ | ||
content | ||
- | ||
length | ||
. | ||
py | ||
? | ||
length | ||
= | ||
" | ||
+ | ||
input | ||
) | ||
; | ||
if | ||
( | ||
testUnit | ||
. | ||
output | ||
= | ||
= | ||
= | ||
null | ||
) | ||
{ | ||
return | ||
promise_rejects_js | ||
( | ||
t | ||
TypeError | ||
result | ||
) | ||
; | ||
} | ||
else | ||
{ | ||
return | ||
result | ||
. | ||
then | ||
( | ||
res | ||
= | ||
> | ||
res | ||
. | ||
text | ||
( | ||
) | ||
) | ||
. | ||
then | ||
( | ||
text | ||
= | ||
> | ||
{ | ||
assert_equals | ||
( | ||
text | ||
. | ||
length | ||
testUnit | ||
. | ||
output | ||
) | ||
; | ||
} | ||
) | ||
; | ||
} | ||
} | ||
input | ||
) | ||
; | ||
} | ||
) | ||
; | ||
} |
121 changes: 121 additions & 0 deletions
121
testing/web-platform/tests/fetch/content-length/resources/content-length.py
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,121 @@ | ||
def | ||
main | ||
( | ||
request | ||
response | ||
) | ||
: | ||
|
||
response | ||
. | ||
add_required_headers | ||
= | ||
False | ||
|
||
output | ||
= | ||
b | ||
" | ||
HTTP | ||
/ | ||
1 | ||
. | ||
1 | ||
200 | ||
OK | ||
\ | ||
r | ||
\ | ||
n | ||
" | ||
|
||
output | ||
+ | ||
= | ||
b | ||
" | ||
Content | ||
- | ||
Type | ||
: | ||
text | ||
/ | ||
plain | ||
; | ||
charset | ||
= | ||
UTF | ||
- | ||
8 | ||
\ | ||
r | ||
\ | ||
n | ||
" | ||
|
||
output | ||
+ | ||
= | ||
request | ||
. | ||
GET | ||
. | ||
first | ||
( | ||
b | ||
" | ||
length | ||
" | ||
) | ||
+ | ||
b | ||
" | ||
\ | ||
r | ||
\ | ||
n | ||
" | ||
|
||
output | ||
+ | ||
= | ||
b | ||
" | ||
\ | ||
r | ||
\ | ||
n | ||
" | ||
|
||
output | ||
+ | ||
= | ||
b | ||
" | ||
Fact | ||
: | ||
this | ||
is | ||
really | ||
forty | ||
- | ||
two | ||
bytes | ||
long | ||
. | ||
" | ||
|
||
response | ||
. | ||
writer | ||
. | ||
write | ||
( | ||
output | ||
) | ||
|
||
response | ||
. | ||
close_connection | ||
= | ||
True |
Oops, something went wrong.