From eab601e3767c1c0251fda866bed7acf63dd21076 Mon Sep 17 00:00:00 2001 From: Nathan Nobbe Date: Tue, 10 May 2022 16:18:01 +0000 Subject: [PATCH] Issue-174 - createEnvironment in createHTMLDocument --- src/lib/web-worker/worker-document.ts | 11 ++++++----- src/lib/web-worker/worker-environment.ts | 5 +++-- tests/platform/document/document.spec.ts | 2 +- tests/platform/document/index.html | 6 +++++- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/lib/web-worker/worker-document.ts b/src/lib/web-worker/worker-document.ts index 40aca462..6929b92d 100644 --- a/src/lib/web-worker/worker-document.ts +++ b/src/lib/web-worker/worker-document.ts @@ -178,11 +178,12 @@ export const patchDocument = ( callMethod(this, ['implementation', 'createHTMLDocument'], [title], CallType.Blocking, { $winId$, }); - const docEnv = createWindow( - $winId$, - $winId$, - env.$location$ + '', - 'hidden', + const docEnv = createEnvironment({ + $winId$, + $parentWinId$: $winId$, + $url$: env.$location$ + '', + $visibilityState$: 'hidden', + }, true, true ); diff --git a/src/lib/web-worker/worker-environment.ts b/src/lib/web-worker/worker-environment.ts index d9fee552..d2a39809 100644 --- a/src/lib/web-worker/worker-environment.ts +++ b/src/lib/web-worker/worker-environment.ts @@ -6,7 +6,7 @@ import { logWorker, normalizedWinId } from '../log'; export const createEnvironment = ( { $winId$, $parentWinId$, $url$, $visibilityState$ }: InitializeEnvironmentData, - isIframeWindow?: boolean + isIframeWindow?: boolean, isDocumentImplementation?: boolean ) => { if (!environments[$winId$]) { // create a simulated global environment for this window @@ -16,7 +16,8 @@ export const createEnvironment = ( $parentWinId$, $url$, $visibilityState$, - isIframeWindow + isIframeWindow, + isDocumentImplementation ); if (debug) { diff --git a/tests/platform/document/document.spec.ts b/tests/platform/document/document.spec.ts index 8d229dae..09a298d1 100644 --- a/tests/platform/document/document.spec.ts +++ b/tests/platform/document/document.spec.ts @@ -92,7 +92,7 @@ test('document', async ({ page }) => { await expect(testCreateElementError_).toHaveText('no error'); const testCreateHTMLDocument = page.locator('#testCreateHTMLDocument'); - await expect(testCreateHTMLDocument).toHaveText('88mph hidden'); + await expect(testCreateHTMLDocument).toHaveText('88mph hidden object'); const testVisibilityState = page.locator('#testVisibilityState'); await expect(testVisibilityState).toHaveText('visible'); diff --git a/tests/platform/document/index.html b/tests/platform/document/index.html index 6d220289..457c5c93 100644 --- a/tests/platform/document/index.html +++ b/tests/platform/document/index.html @@ -432,9 +432,13 @@

Document