From bc2eeb3772d65107d2dd5defad26528a3b7c5307 Mon Sep 17 00:00:00 2001 From: Filip Skokan Date: Thu, 23 Feb 2023 17:55:45 +0100 Subject: [PATCH 1/2] lib: fix DOMException property descriptors after being lazy loaded --- lib/internal/bootstrap/browser.js | 5 ++++- test/common/wpt.js | 1 + test/wpt/test-domexception.js | 11 +---------- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/lib/internal/bootstrap/browser.js b/lib/internal/bootstrap/browser.js index b94ac9891a399c..74f911049b6653 100644 --- a/lib/internal/bootstrap/browser.js +++ b/lib/internal/bootstrap/browser.js @@ -26,7 +26,10 @@ exposeInterface(globalThis, 'URL', URL); exposeInterface(globalThis, 'URLSearchParams', URLSearchParams); exposeGetterAndSetter(globalThis, 'DOMException', - lazyDOMExceptionClass, + () => { + exposeInterface(globalThis, 'DOMException', lazyDOMExceptionClass()); + return globalThis.DOMException; + }, (value) => { exposeInterface(globalThis, 'DOMException', value); }); diff --git a/test/common/wpt.js b/test/common/wpt.js index 964862248c91c9..d96a2ff4c4128d 100644 --- a/test/common/wpt.js +++ b/test/common/wpt.js @@ -503,6 +503,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 09018a25ac58d8..5341732fe69e25 100644 --- a/test/wpt/test-domexception.js +++ b/test/wpt/test-domexception.js @@ -5,15 +5,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(); From 50d510ab2e8d0ebb45c4a1f94bfb4521d759bf82 Mon Sep 17 00:00:00 2001 From: Filip Skokan Date: Fri, 24 Feb 2023 13:55:23 +0100 Subject: [PATCH 2/2] Update lib/internal/bootstrap/browser.js Co-authored-by: Joyee Cheung --- lib/internal/bootstrap/browser.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/internal/bootstrap/browser.js b/lib/internal/bootstrap/browser.js index 74f911049b6653..e1f3d775c6ac13 100644 --- a/lib/internal/bootstrap/browser.js +++ b/lib/internal/bootstrap/browser.js @@ -27,8 +27,9 @@ exposeInterface(globalThis, 'URLSearchParams', URLSearchParams); exposeGetterAndSetter(globalThis, 'DOMException', () => { - exposeInterface(globalThis, 'DOMException', lazyDOMExceptionClass()); - return globalThis.DOMException; + const DOMException = lazyDOMExceptionClass(); + exposeInterface(globalThis, 'DOMException', DOMException); + return DOMException; }, (value) => { exposeInterface(globalThis, 'DOMException', value);