Skip to content

Commit 125950d

Browse files
Raphael Kubo da Costaannevk
authored andcommitted
URL: passing DOMException.prototype to URLSearchParams now throws
As of whatwg/webidl#378, both new URLSearchParams(DOMException.prototype) DOMException.prototype.toString() are supposed to throw an exception due to brand checks in properties such as "name" and "message", which meant compliant implementations were always failing one of the tests here. Fix it by passing a `DOMException` instead: it has all the constants we need and passes the required property checks. Also assert that the previous behavior throws a TypeError.
1 parent 25581e4 commit 125950d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

url/urlsearchparams-constructor.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@
2323
}, "URLSearchParams constructor, no arguments")
2424

2525
test(() => {
26-
params = new URLSearchParams(DOMException.prototype);
26+
params = new URLSearchParams(DOMException);
2727
assert_equals(params.toString(), "INDEX_SIZE_ERR=1&DOMSTRING_SIZE_ERR=2&HIERARCHY_REQUEST_ERR=3&WRONG_DOCUMENT_ERR=4&INVALID_CHARACTER_ERR=5&NO_DATA_ALLOWED_ERR=6&NO_MODIFICATION_ALLOWED_ERR=7&NOT_FOUND_ERR=8&NOT_SUPPORTED_ERR=9&INUSE_ATTRIBUTE_ERR=10&INVALID_STATE_ERR=11&SYNTAX_ERR=12&INVALID_MODIFICATION_ERR=13&NAMESPACE_ERR=14&INVALID_ACCESS_ERR=15&VALIDATION_ERR=16&TYPE_MISMATCH_ERR=17&SECURITY_ERR=18&NETWORK_ERR=19&ABORT_ERR=20&URL_MISMATCH_ERR=21&QUOTA_EXCEEDED_ERR=22&TIMEOUT_ERR=23&INVALID_NODE_TYPE_ERR=24&DATA_CLONE_ERR=25")
28-
}, "URLSearchParams constructor, DOMException.prototype as argument")
28+
assert_throws(new TypeError(), () => new URLSearchParams(DOMException.prototype),
29+
"Constructing a URLSearchParams from DOMException.prototype should throw due to branding checks");
30+
}, "URLSearchParams constructor, DOMException as argument")
2931

3032
test(() => {
3133
params = new URLSearchParams('');

0 commit comments

Comments
 (0)