LibWeb: Use ByteString arguments for XMLHttpRequest.setRequestHeader()
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-15, macOS, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Push notes / build (push) Waiting to run
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-15, macOS, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Push notes / build (push) Waiting to run
This commit is contained in:
parent
2aee5d7f62
commit
00f6a2b744
Notes:
github-actions[bot]
2024-11-21 20:50:48 +00:00
Author: https://github.com/tcl3 Commit: https://github.com/LadybirdBrowser/ladybird/commit/00f6a2b7446 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2485 Reviewed-by: https://github.com/trflynn89 ✅
5 changed files with 192 additions and 1 deletions
|
@ -33,7 +33,7 @@ interface XMLHttpRequest : XMLHttpRequestEventTarget {
|
|||
// request
|
||||
undefined open(DOMString method, DOMString url);
|
||||
undefined open(ByteString method, USVString url, boolean async, optional USVString? username = null, optional USVString? password = null);
|
||||
undefined setRequestHeader(DOMString name, DOMString value);
|
||||
undefined setRequestHeader(ByteString name, ByteString value);
|
||||
attribute unsigned long timeout;
|
||||
attribute boolean withCredentials;
|
||||
[SameObject] readonly attribute XMLHttpRequestUpload upload;
|
||||
|
|
|
@ -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-テスト".
|
|
@ -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
|
|
@ -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>
|
|
@ -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>
|
Loading…
Add table
Reference in a new issue