Lightpanda: the headless browser designed for AI and automation
webapi: fix `DOMString` type confusion
Halil Durakc652d8e674f7
diff --git a/src/browser/tests/domexception.html b/src/browser/tests/domexception.htmlindex 2f11552f8..627ba68a6 100644--- a/src/browser/tests/domexception.html+++ b/src/browser/tests/domexception.html@@ -36,6 +36,29 @@}</script>+<script id=domstring_argument_coercion>+ {+ // message/name are WebIDL DOMStrings: a non-string argument is stringified+ // (ToString), never adopted as raw bytes. A TypedArray stringifies via its+ // Array-inherited toString, so its contents are joined, not read as bytes.+ const ex = new DOMException(new Uint8Array([65, 66, 67]), 'NotFoundError');+ testing.expectEqual('65,66,67', ex.message);+ testing.expectEqual('NotFoundError', ex.name);++ const ex2 = new DOMException('msg', new Uint8Array([0x7f, 0x45, 0x4c, 0x46]));+ testing.expectEqual('127,69,76,70', ex2.name);+ testing.expectEqual(0, ex2.code);++ const ex3 = new DOMException({});+ testing.expectEqual('[object Object]', ex3.message);++ // null stringifies to "null"; a missing/undefined argument uses the default.+ testing.expectEqual('null', new DOMException(null).message);+ testing.expectEqual('', new DOMException(undefined).message);+ testing.expectEqual('Error', new DOMException(undefined, undefined).name);+ }+</script>+<script id=legacy_error_codes>{// Test standard errors with legacy codesdiff --git a/src/browser/webapi/DOMException.zig b/src/browser/webapi/DOMException.zigindex 36b024452..8ee23eaee 100644--- a/src/browser/webapi/DOMException.zig+++ b/src/browser/webapi/DOMException.zig@@ -261,10 +261,10 @@ pub const JsApi = struct {};pub const constructor = bridge.constructor(struct {- fn constructor(m_: ?[]const u8, n_: ?[]const u8, exec: *const js.Execution) !DOMException {+ fn constructor(m_: ?js.NullableString, n_: ?js.NullableString, exec: *const js.Execution) !DOMException {return init(- if (m_) |m| try exec.dupeString(m) else null,- if (n_) |n| try exec.dupeString(n) else null,+ if (m_) |m| try exec.dupeString(m.value) else null,+ if (n_) |n| try exec.dupeString(n.value) else null,);}}.constructor, .{});