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:
Feng Yu 2024-12-09 11:47:14 -08:00 committed by Tim Flynn
commit f2eaf3381f
Notes: github-actions[bot] 2024-12-10 14:47:27 +00:00
7 changed files with 717 additions and 3 deletions

View file

@ -0,0 +1,28 @@
Harness status: OK
Found 23 tests
23 Pass
Pass Create headers from no parameter
Pass Create headers from undefined parameter
Pass Create headers from empty object
Pass Create headers with null should throw
Pass Create headers with 1 should throw
Pass Create headers with sequence
Pass Create headers with record
Pass Create headers with existing headers
Pass Create headers with existing headers with custom iterator
Pass Check append method
Pass Check set method
Pass Check has method
Pass Check delete method
Pass Check get method
Pass Check keys method
Pass Check values method
Pass Check entries method
Pass Check Symbol.iterator method
Pass Check forEach method
Pass Iteration skips elements removed while iterating
Pass Removing elements already iterated over causes an element to be skipped during iteration
Pass Appending a value pair during iteration causes it to be reached during iteration
Pass Prepending a value pair before the current element position causes it to be skipped during iteration and adds the current element a second time

View file

@ -0,0 +1,18 @@
Harness status: OK
Found 13 tests
13 Pass
Pass Passing nothing to Headers constructor
Pass Passing undefined to Headers constructor
Pass Passing null to Headers constructor
Pass Basic operation with one property
Pass Basic operation with one property and a proto
Pass Correct operation ordering with two properties
Pass Correct operation ordering with two properties one of which has an invalid name
Pass Correct operation ordering with two properties one of which has an invalid value
Pass Correct operation ordering with non-enumerable properties
Pass Correct operation ordering with undefined descriptors
Pass Correct operation ordering with repeated keys
Pass Basic operation with Symbol keys
Pass Operation with non-enumerable Symbol keys