Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebIDL brand checks incorrectly throw when using getters/methods on makeSafed WebIDL classes #28438

Open
easrng opened this issue Mar 9, 2025 · 0 comments

Comments

@easrng
Copy link

easrng commented Mar 9, 2025

Version: Deno 2.1.9

I was making a SafeURL class with makeSafe from primordials when I ran into this error:

const SafeURL = makeSafe(URL, class SafeURL extends URL {});

let safeUrl=new SafeURL("https://example.com")
console.log(safeUrl.href)
// throws TypeError: Illegal invocation
//    at Module.assertBranded (ext:deno_webidl/00_webidl.js:1142:11)
//    at URL.get href (ext:deno_url/00_url.js:594:12)

Here's a version that doesn't rely on the primordials:

class SafeURL extends URL {}
Object.defineProperties(SafeURL.prototype, Object.getOwnPropertyDescriptors(URL.prototype))
Object.setPrototypeOf(SafeURL.prototype, null)
Object.freeze(SafeURL.prototype)
Object.freeze(SafeURL)

let safeUrl=new SafeURL("https://example.com")
console.log(safeUrl.href)

No other runtime I tested throws with this code, and throwing seems incorrect (though I haven't read the WebIDL spec lol)
Would also be nice if the brand checks stopped using symbols, though I don't think that'll be an issue for me here

@easrng easrng changed the title Deno WebIDL brand checks incorrectly throw when using getters/methods on makeSafed WebIDL classes WebIDL brand checks incorrectly throw when using getters/methods on makeSafed WebIDL classes Mar 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant