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, []); 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 @@