mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-18 08:20:44 +00:00
LibWeb: Throw TypeError for new Headers(null)
The WebIDL for the `Headers` constructor specifies that the `init` parameter is optional and must be of type `HeadersInit`. While the parameter can be omitted (or explicitly set to `undefined`), `null` is not a valid value. This change fixes at least 2 "Create headers with null should throw" WPT subtests which I have imported in this patch.
This commit is contained in:
parent
023c3aa5b0
commit
f2eaf3381f
Notes:
github-actions[bot]
2024-12-10 14:47:27 +00:00
Author: https://github.com/F3n67u
Commit: f2eaf3381f
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2855
7 changed files with 717 additions and 3 deletions
|
@ -1550,14 +1550,20 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
|
|||
@union_type@ @cpp_name@ = TRY(@js_name@@js_suffix@_to_variant(@js_name@@js_suffix@));
|
||||
)~~~");
|
||||
} else {
|
||||
if (!optional_default_value.has_value() || optional_default_value == "null"sv) {
|
||||
if (!optional_default_value.has_value()) {
|
||||
union_generator.append(R"~~~(
|
||||
Optional<@union_type@> @cpp_name@;
|
||||
if (!@js_name@@js_suffix@.is_undefined())
|
||||
@cpp_name@ = TRY(@js_name@@js_suffix@_to_variant(@js_name@@js_suffix@));
|
||||
)~~~");
|
||||
} else {
|
||||
if (optional_default_value == "null"sv) {
|
||||
union_generator.append(R"~~~(
|
||||
Optional<@union_type@> @cpp_name@;
|
||||
if (!@js_name@@js_suffix@.is_nullish())
|
||||
@cpp_name@ = TRY(@js_name@@js_suffix@_to_variant(@js_name@@js_suffix@));
|
||||
)~~~");
|
||||
} else {
|
||||
if (optional_default_value == "\"\"") {
|
||||
} else if (optional_default_value == "\"\"") {
|
||||
union_generator.append(R"~~~(
|
||||
@union_type@ @cpp_name@ = @js_name@@js_suffix@.is_undefined() ? String {} : TRY(@js_name@@js_suffix@_to_variant(@js_name@@js_suffix@));
|
||||
)~~~");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue