Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue-174 - createEnvironment in createHTMLDocument #177

Merged
merged 1 commit into from
Jun 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/lib/web-worker/worker-document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
Expand Down
5 changes: 3 additions & 2 deletions src/lib/web-worker/worker-environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -16,7 +16,8 @@ export const createEnvironment = (
$parentWinId$,
$url$,
$visibilityState$,
isIframeWindow
isIframeWindow,
isDocumentImplementation
);

if (debug) {
Expand Down
2 changes: 1 addition & 1 deletion tests/platform/document/document.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adamdbradley this is where I added the test from #174 Comment


const testVisibilityState = page.locator('#testVisibilityState');
await expect(testVisibilityState).toHaveText('visible');
Expand Down
6 changes: 5 additions & 1 deletion tests/platform/document/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -432,9 +432,13 @@ <h1 class="title">Document</h1>
<script type="text/partytown">
(function () {
const doc = document.implementation.createHTMLDocument();
doc.body.textContent = '88mph ' + doc.visibilityState;

const elm = document.getElementById('testCreateHTMLDocument');

const addlElm = doc.createElement('base');
const addlElmType = typeof addlElm;

doc.body.textContent = '88mph ' + doc.visibilityState + ' ' + addlElmType;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adamdbradley this is where I added the test from #174 Comment

elm.textContent = doc.body.textContent;
})();
</script>
Expand Down