forked from LadybirdBrowser/ladybird
-
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.
LibWeb: Use ByteString arguments for
XMLHttpRequest.setRequestHeader()
- Loading branch information
Showing
5 changed files
with
192 additions
and
1 deletion.
There are no files selected for viewing
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
81 changes: 81 additions & 0 deletions
81
Tests/LibWeb/Text/expected/wpt-import/xhr/setrequestheader-bogus-name.txt
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,81 @@ | ||
Summary | ||
|
||
Harness status: OK | ||
|
||
Rerun | ||
|
||
Found 71 tests | ||
|
||
71 Pass | ||
Details | ||
Result Test Name MessagePass setRequestHeader should throw with header name "(". | ||
Pass setRequestHeader should throw with header name ")". | ||
Pass setRequestHeader should throw with header name "<". | ||
Pass setRequestHeader should throw with header name ">". | ||
Pass setRequestHeader should throw with header name "@". | ||
Pass setRequestHeader should throw with header name ",". | ||
Pass setRequestHeader should throw with header name ";". | ||
Pass setRequestHeader should throw with header name ":". | ||
Pass setRequestHeader should throw with header name "\\". | ||
Pass setRequestHeader should throw with header name "\"". | ||
Pass setRequestHeader should throw with header name "/". | ||
Pass setRequestHeader should throw with header name "[". | ||
Pass setRequestHeader should throw with header name "]". | ||
Pass setRequestHeader should throw with header name "?". | ||
Pass setRequestHeader should throw with header name "=". | ||
Pass setRequestHeader should throw with header name "{". | ||
Pass setRequestHeader should throw with header name "}". | ||
Pass setRequestHeader should throw with header name " ". | ||
Pass setRequestHeader should throw with header name "". | ||
Pass setRequestHeader should throw with header name "". | ||
Pass setRequestHeader should throw with header name "t\rt". | ||
Pass setRequestHeader should throw with header name "t\nt". | ||
Pass setRequestHeader should throw with header name "t: t". | ||
Pass setRequestHeader should throw with header name "t:t". | ||
Pass setRequestHeader should throw with header name "t<t". | ||
Pass setRequestHeader should throw with header name "t t". | ||
Pass setRequestHeader should throw with header name " tt". | ||
Pass setRequestHeader should throw with header name ":tt". | ||
Pass setRequestHeader should throw with header name "\ttt". | ||
Pass setRequestHeader should throw with header name "\vtt". | ||
Pass setRequestHeader should throw with header name "t\0t". | ||
Pass setRequestHeader should throw with header name "t\"t". | ||
Pass setRequestHeader should throw with header name "t,t". | ||
Pass setRequestHeader should throw with header name "t;t". | ||
Pass setRequestHeader should throw with header name "()[]{}". | ||
Pass setRequestHeader should throw with header name "a?B". | ||
Pass setRequestHeader should throw with header name "a=B". | ||
Pass setRequestHeader should throw with header name "\0". | ||
Pass setRequestHeader should throw with header name "\x01". | ||
Pass setRequestHeader should throw with header name "\x02". | ||
Pass setRequestHeader should throw with header name "\x03". | ||
Pass setRequestHeader should throw with header name "\x04". | ||
Pass setRequestHeader should throw with header name "\x05". | ||
Pass setRequestHeader should throw with header name "\x06". | ||
Pass setRequestHeader should throw with header name "\x07". | ||
Pass setRequestHeader should throw with header name "\b". | ||
Pass setRequestHeader should throw with header name "\t". | ||
Pass setRequestHeader should throw with header name "\n". | ||
Pass setRequestHeader should throw with header name "\v". | ||
Pass setRequestHeader should throw with header name "\f". | ||
Pass setRequestHeader should throw with header name "\r". | ||
Pass setRequestHeader should throw with header name "\x0e". | ||
Pass setRequestHeader should throw with header name "\x0f". | ||
Pass setRequestHeader should throw with header name "\x10". | ||
Pass setRequestHeader should throw with header name "\x11". | ||
Pass setRequestHeader should throw with header name "\x12". | ||
Pass setRequestHeader should throw with header name "\x13". | ||
Pass setRequestHeader should throw with header name "\x14". | ||
Pass setRequestHeader should throw with header name "\x15". | ||
Pass setRequestHeader should throw with header name "\x16". | ||
Pass setRequestHeader should throw with header name "\x17". | ||
Pass setRequestHeader should throw with header name "\x18". | ||
Pass setRequestHeader should throw with header name "\x19". | ||
Pass setRequestHeader should throw with header name "\x1a". | ||
Pass setRequestHeader should throw with header name "\x1b". | ||
Pass setRequestHeader should throw with header name "\x1c". | ||
Pass setRequestHeader should throw with header name "\x1d". | ||
Pass setRequestHeader should throw with header name "\x1e". | ||
Pass setRequestHeader should throw with header name "\x1f". | ||
Pass setRequestHeader should throw with header name "テスト". | ||
Pass setRequestHeader should throw with header name "X-テスト". |
15 changes: 15 additions & 0 deletions
15
Tests/LibWeb/Text/expected/wpt-import/xhr/setrequestheader-bogus-value.txt
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,15 @@ | ||
Summary | ||
|
||
Harness status: OK | ||
|
||
Rerun | ||
|
||
Found 5 tests | ||
|
||
5 Pass | ||
Details | ||
Result Test Name MessagePass XMLHttpRequest: setRequestHeader() value argument checks | ||
Pass XMLHttpRequest: setRequestHeader() value argument checks 1 | ||
Pass XMLHttpRequest: setRequestHeader() value argument checks 2 | ||
Pass XMLHttpRequest: setRequestHeader() value argument checks 3 | ||
Pass Omitted value argument |
59 changes: 59 additions & 0 deletions
59
Tests/LibWeb/Text/input/wpt-import/xhr/setrequestheader-bogus-name.htm
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,59 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<title>XMLHttpRequest: setRequestHeader() name argument checks</title> | ||
<meta charset="utf-8"> | ||
<script src="../resources/testharness.js"></script> | ||
<script src="../resources/testharnessreport.js"></script> | ||
<link rel="help" href="https://xhr.spec.whatwg.org/#the-setrequestheader()-method" data-tested-assertations="/following::ol/li[3]" /> | ||
</head> | ||
<body> | ||
<div id="log"></div> | ||
<!-- | ||
CHAR = <any US-ASCII character (octets 0 - 127)> | ||
CTL = <any US-ASCII control character | ||
(octets 0 - 31) and DEL (127)> | ||
SP = <US-ASCII SP, space (32)> | ||
HT = <US-ASCII HT, horizontal-tab (9)> | ||
token = 1*<any CHAR except CTLs or separators> | ||
separators = "(" | ")" | "<" | ">" | "@" | ||
| "," | ";" | ":" | "\" | <"> | ||
| "/" | "[" | "]" | "?" | "=" | ||
| "{" | "}" | SP | HT | ||
field-name = token | ||
--> | ||
<script> | ||
function try_name(name) { | ||
test(function() { | ||
var client = new XMLHttpRequest() | ||
client.open("GET", "...") | ||
assert_throws_dom("SyntaxError", function() { client.setRequestHeader(name, 'x-value') }) | ||
}, "setRequestHeader should throw with header name " + format_value(invalid_headers[i]) + ".") | ||
} | ||
function try_byte_string(name) { | ||
test(function() { | ||
var client = new XMLHttpRequest() | ||
client.open("GET", "...") | ||
assert_throws_js(TypeError, function() { client.setRequestHeader(name, 'x-value') }) | ||
}, "setRequestHeader should throw with header name " + format_value(invalid_byte_strings[i]) + ".") | ||
} | ||
var invalid_headers = ["(", ")", "<", ">", "@", ",", ";", ":", "\\", | ||
"\"", "/", "[", "]", "?", "=", "{", "}", " ", | ||
/* HT already tested in the loop below */ | ||
"\u007f", "", "t\rt", "t\nt", "t: t", "t:t", | ||
"t<t", "t t", " tt", ":tt", "\ttt", "\vtt", "t\0t", | ||
"t\"t", "t,t", "t;t", "()[]{}", "a?B", "a=B"] | ||
var invalid_byte_strings = ["テスト", "X-テスト"] | ||
for (var i = 0; i < 32; ++i) { | ||
invalid_headers.push(String.fromCharCode(i)) | ||
} | ||
for (var i = 0; i < invalid_headers.length; ++i) { | ||
try_name(invalid_headers[i]) | ||
} | ||
for (var i = 0; i < invalid_byte_strings.length; ++i) { | ||
try_byte_string(invalid_byte_strings[i]) | ||
} | ||
|
||
</script> | ||
</body> | ||
</html> |
36 changes: 36 additions & 0 deletions
36
Tests/LibWeb/Text/input/wpt-import/xhr/setrequestheader-bogus-value.htm
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,36 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>XMLHttpRequest: setRequestHeader() value argument checks</title> | ||
<script src="../resources/testharness.js"></script> | ||
<script src="../resources/testharnessreport.js"></script> | ||
<link rel="help" href="https://xhr.spec.whatwg.org/#the-setrequestheader()-method" data-tested-assertations="/following::ol/li[4]" /> | ||
</head> | ||
<body> | ||
<div id="log"></div> | ||
<script> | ||
function try_value(value) { | ||
test(function() { | ||
var client = new XMLHttpRequest(); | ||
client.open("GET", "..."); | ||
assert_throws_dom("SyntaxError", function() { client.setRequestHeader("x-test", value) }, ' given value ' + value+', '); | ||
}); | ||
} | ||
try_value("t\x00t"); | ||
try_value("t\rt"); | ||
try_value("t\nt"); | ||
test(function() { | ||
var client = new XMLHttpRequest(); | ||
client.open("GET", "..."); | ||
assert_throws_js(TypeError, function() { client.setRequestHeader("x-test", "テスト") }, ' given value テスト,'); | ||
}); | ||
|
||
test(function() { | ||
var client = new XMLHttpRequest() | ||
client.open("GET", "...") | ||
assert_throws_js(TypeError, function() { client.setRequestHeader("x-test") }) | ||
}, 'Omitted value argument') | ||
</script> | ||
</body> | ||
</html> |