From 29a075de2b625e1c893f6fad163a6d6937894a7a Mon Sep 17 00:00:00 2001 From: ud2 Date: Wed, 5 Jun 2024 07:09:13 +0800 Subject: chore(ext/web): use `Error.captureStackTrace` in `DOMException` constructor (#23986) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This makes `DOMException`'s `stack` property behave the same as native errors' – `stack` is now an own accessor property on every instance, and the getter calls `Error.prepareStackTrace`. Upgrades `deno_core` to 0.284.0. --------- Co-authored-by: Bartek Iwańczuk --- tests/testdata/run/eval_context_throw_dom_exception.js.out | 3 +-- tests/unit/dom_exception_test.ts | 8 +++++--- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/testdata/run/eval_context_throw_dom_exception.js.out b/tests/testdata/run/eval_context_throw_dom_exception.js.out index 39f5a8174..24ea0cffc 100644 --- a/tests/testdata/run/eval_context_throw_dom_exception.js.out +++ b/tests/testdata/run/eval_context_throw_dom_exception.js.out @@ -1,6 +1,5 @@ { - thrown: DOMException: foo - at new DOMException (ext:deno_web/01_dom_exception.js:[WILDCARD]) + thrown: Error: foo at [WILDCARD] at Object.evalContext (ext:core/01_core.js:[WILDCARD]) at file:///[WILDCARD]/eval_context_throw_dom_exception.js:1:48, diff --git a/tests/unit/dom_exception_test.ts b/tests/unit/dom_exception_test.ts index 806248caa..4e894f5fc 100644 --- a/tests/unit/dom_exception_test.ts +++ b/tests/unit/dom_exception_test.ts @@ -23,8 +23,10 @@ Deno.test(function nameToCodeMappingPrototypeAccess() { Reflect.deleteProperty(objectPrototype, "pollution"); }); -Deno.test(function callSitesEvalsDoesntThrow() { +Deno.test(function hasStackAccessor() { const e2 = new DOMException("asdf"); - // @ts-ignore no types for `__callSiteEvals` but it's observable. - assert(Array.isArray(e2.__callSiteEvals)); + const desc = Object.getOwnPropertyDescriptor(e2, "stack"); + assert(desc); + assert(typeof desc.get === "function"); + assert(typeof desc.set === "function"); }); -- cgit v1.2.3