From 281f176ba44a4a939e1825c4cc1f7fbf7d2d6453 Mon Sep 17 00:00:00 2001 From: Filip Skokan Date: Sat, 25 Feb 2023 18:02:59 +0100 Subject: [PATCH] lib: fix DOMException property descriptors after being lazy loaded MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/46799 Reviewed-By: James M Snell Reviewed-By: Chengzhong Wu Reviewed-By: Joyee Cheung Reviewed-By: Tobias Nießen --- lib/internal/bootstrap/browser.js | 6 +++++- test/common/wpt.js | 1 + test/wpt/test-domexception.js | 11 +---------- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/lib/internal/bootstrap/browser.js b/lib/internal/bootstrap/browser.js index b94ac9891a399c..e1f3d775c6ac13 100644 --- a/lib/internal/bootstrap/browser.js +++ b/lib/internal/bootstrap/browser.js @@ -26,7 +26,11 @@ exposeInterface(globalThis, 'URL', URL); exposeInterface(globalThis, 'URLSearchParams', URLSearchParams); exposeGetterAndSetter(globalThis, 'DOMException', - lazyDOMExceptionClass, + () => { + const DOMException = lazyDOMExceptionClass(); + exposeInterface(globalThis, 'DOMException', DOMException); + return DOMException; + }, (value) => { exposeInterface(globalThis, 'DOMException', value); }); diff --git a/test/common/wpt.js b/test/common/wpt.js index 085df82befeddc..f693c96b1ff9d4 100644 --- a/test/common/wpt.js +++ b/test/common/wpt.js @@ -501,6 +501,7 @@ class WPTRunner { loadLazyGlobals() { const lazyProperties = [ + 'DOMException', 'Performance', 'PerformanceEntry', 'PerformanceMark', 'PerformanceMeasure', 'PerformanceObserver', 'PerformanceObserverEntryList', 'PerformanceResourceTiming', 'Blob', 'atob', 'btoa', diff --git a/test/wpt/test-domexception.js b/test/wpt/test-domexception.js index ea68c8562aea57..7900d1ca9a79c6 100644 --- a/test/wpt/test-domexception.js +++ b/test/wpt/test-domexception.js @@ -4,15 +4,6 @@ const { WPTRunner } = require('../common/wpt'); const runner = new WPTRunner('webidl/ecmascript-binding/es-exceptions'); -runner.setFlags(['--expose-internals']); -runner.setInitScript(` - const { internalBinding } = require('internal/test/binding'); - const { DOMException } = internalBinding('messaging'); - Object.defineProperty(global, 'DOMException', { - writable: true, - configurable: true, - value: DOMException, - }); -`); +runner.loadLazyGlobals(); runner.runJsTests();