From ca9d9a0cf1365661c88642dd83f43a585f35e9e5 Mon Sep 17 00:00:00 2001 From: Julian Jandl Date: Tue, 25 Jun 2024 12:43:44 +0200 Subject: [PATCH 1/4] fix: make sure unknown is mapped to HTMLUnknownElement cstr --- src/lib/sandbox/read-main-platform.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/lib/sandbox/read-main-platform.ts b/src/lib/sandbox/read-main-platform.ts index bc4c85f1..a8bea4b7 100644 --- a/src/lib/sandbox/read-main-platform.ts +++ b/src/lib/sandbox/read-main-platform.ts @@ -79,7 +79,15 @@ export const readMainInterfaces = () => { // and create each element to get their implementation const elms = Object.getOwnPropertyNames(mainWindow) .map((interfaceName) => createElementFromConstructor(docImpl, interfaceName)) - .filter((elm) => elm) + .filter((elm) => { + if (!elm) { + return false; + } + const constructorName = getConstructorName(elm); + return !( + constructorName === 'HTMLUnknownElement' && elm.nodeName.toUpperCase() !== 'UNKNOWN' + ); + }) .map((elm) => [elm]); return readImplementations(elms, []); From 13b4e5e90da711f141b4a3618f1c251e2efcde8f Mon Sep 17 00:00:00 2001 From: gioboa Date: Wed, 11 Dec 2024 21:42:06 +0100 Subject: [PATCH 2/4] chore: change filter logic --- src/lib/sandbox/read-main-platform.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/lib/sandbox/read-main-platform.ts b/src/lib/sandbox/read-main-platform.ts index a8bea4b7..a76fba7e 100644 --- a/src/lib/sandbox/read-main-platform.ts +++ b/src/lib/sandbox/read-main-platform.ts @@ -84,9 +84,7 @@ export const readMainInterfaces = () => { return false; } const constructorName = getConstructorName(elm); - return !( - constructorName === 'HTMLUnknownElement' && elm.nodeName.toUpperCase() !== 'UNKNOWN' - ); + return (constructorName !== 'HTMLUnknownElement' || elm.nodeName.toUpperCase() !== 'UNKNOWN'); }) .map((elm) => [elm]); From 3f9a342a30f47375dc1e28373c2610781f4e0a71 Mon Sep 17 00:00:00 2001 From: Julian Jandl Date: Thu, 12 Dec 2024 15:36:10 +0100 Subject: [PATCH 3/4] Revert "chore: change filter logic" This reverts commit 13b4e5e90da711f141b4a3618f1c251e2efcde8f. --- src/lib/sandbox/read-main-platform.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lib/sandbox/read-main-platform.ts b/src/lib/sandbox/read-main-platform.ts index a76fba7e..a8bea4b7 100644 --- a/src/lib/sandbox/read-main-platform.ts +++ b/src/lib/sandbox/read-main-platform.ts @@ -84,7 +84,9 @@ export const readMainInterfaces = () => { return false; } const constructorName = getConstructorName(elm); - return (constructorName !== 'HTMLUnknownElement' || elm.nodeName.toUpperCase() !== 'UNKNOWN'); + return !( + constructorName === 'HTMLUnknownElement' && elm.nodeName.toUpperCase() !== 'UNKNOWN' + ); }) .map((elm) => [elm]); From 8342963445a422ad720c5285c7846717ec23a9b7 Mon Sep 17 00:00:00 2001 From: Julian Jandl Date: Thu, 12 Dec 2024 15:37:32 +0100 Subject: [PATCH 4/4] test: custom-element testing unknown elements access for the worker --- .../custom-element/custom-element.spec.ts | 4 ++++ tests/platform/custom-element/index.html | 17 +++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/tests/platform/custom-element/custom-element.spec.ts b/tests/platform/custom-element/custom-element.spec.ts index 320c72ca..da544c95 100644 --- a/tests/platform/custom-element/custom-element.spec.ts +++ b/tests/platform/custom-element/custom-element.spec.ts @@ -7,6 +7,10 @@ test('custom-element', async ({ page }) => { const testDefine = page.locator('#testDefine'); await expect(testDefine).toHaveText('TestDefineElement'); + await page.waitForSelector('.testDefineOnMainAccessOnWorker'); + const testDefineOnMainAccessOnWorker = page.locator('#testDefineOnMainAccessOnWorker'); + await expect(testDefineOnMainAccessOnWorker).toHaveText('it works'); + await page.waitForSelector('.testNoReDefine'); const testNoReDefine = page.locator('#testNoReDefine'); await expect(testNoReDefine).toHaveText('TestNoReDefineElement'); diff --git a/tests/platform/custom-element/index.html b/tests/platform/custom-element/index.html index f93ea1ce..6eb11bf6 100644 --- a/tests/platform/custom-element/index.html +++ b/tests/platform/custom-element/index.html @@ -57,6 +57,10 @@ logScriptExecution: true, }; + @@ -79,6 +83,19 @@

Custom Element

+
  • + define on main, access on worker + + + +
  • +
  • no worker re-define