Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ repository = "https://github.com/denoland/deno"

[workspace.dependencies]
deno_ast = { version = "=0.50.3", features = ["transpiling"] }
deno_core = { version = "0.363.0" }
deno_core = { path = "../deno_core/core" } # version = "0.363.0" }

deno_cache_dir = "=0.25.0"
deno_doc = "=0.186.0"
Expand Down
6 changes: 5 additions & 1 deletion ext/web/01_dom_exception.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/// <reference path="../web/internal.d.ts" />
/// <reference path="../../cli/tsc/dts/lib.deno_web.d.ts" />

import { primordials } from "ext:core/mod.js";
import { core, primordials } from "ext:core/mod.js";
const {
Error,
ErrorPrototype,
Expand Down Expand Up @@ -94,6 +94,10 @@ class DOMException {
[_name];
[_code];

[core.hostObjectBrand]() {
return { type: "DOMException", message: this.message, name: this.name };
}

// https://webidl.spec.whatwg.org/#dom-domexception-domexception
constructor(message = "", name = "Error") {
message = webidl.converters.DOMString(
Expand Down
7 changes: 6 additions & 1 deletion ext/web/13_message_port.js
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,10 @@ function opCreateEntangledMessagePort() {
return op_message_port_create_entangled();
}

const CURSED_DESERIALIZERS = {
DOMException: (obj) => new DOMException(obj.message, obj.name),
};

/**
* @param {messagePort.MessageData} messageData
* @returns {[any, object[]]}
Expand Down Expand Up @@ -386,6 +390,7 @@ function deserializeJsMessageData(messageData) {
options = {
hostObjects,
transferredArrayBuffers,
deserializers: CURSED_DESERIALIZERS,
};
}

Expand Down Expand Up @@ -501,7 +506,7 @@ function structuredClone(value, options) {
// Fast-path, avoiding round-trip serialization and deserialization
if (options.transfer.length === 0) {
try {
return core.structuredClone(value);
return core.structuredClone(value, CURSED_DESERIALIZERS);
} catch (e) {
if (ObjectPrototypeIsPrototypeOf(TypeErrorPrototype, e)) {
throw new DOMException(e.message, "DataCloneError");
Expand Down
5 changes: 5 additions & 0 deletions tests/unit/structured_clone_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,9 @@ Deno.test("correct DataCloneError message", () => {

// ab2 should not be detached after above failure
structuredClone(ab2, { transfer: [ab2] });

const de = structuredClone(new DOMException("message", "SomeError"));
assert(de instanceof DOMException);
assertEquals(de.message, "message");
assertEquals(de.name, "SomeError");
});
Loading