From b82957bd5458214ecd4f84273817c6d21bd24857 Mon Sep 17 00:00:00 2001 From: Vladimir Panov Date: Wed, 15 Nov 2023 16:30:44 +0200 Subject: [PATCH] Add missing implementation for document.scripts --- src/lib/web-worker/worker-document.ts | 6 ++++++ tests/platform/document/document.spec.ts | 6 ++++++ tests/platform/document/index.html | 19 +++++++++++++++++++ 3 files changed, 31 insertions(+) diff --git a/src/lib/web-worker/worker-document.ts b/src/lib/web-worker/worker-document.ts index 6db5a18f..f05d4414 100644 --- a/src/lib/web-worker/worker-document.ts +++ b/src/lib/web-worker/worker-document.ts @@ -175,6 +175,12 @@ export const patchDocument = ( }, }, + scripts: { + get() { + return getter(this, ['scripts']); + }, + }, + implementation: { get() { return { diff --git a/tests/platform/document/document.spec.ts b/tests/platform/document/document.spec.ts index 92501917..b0102e18 100644 --- a/tests/platform/document/document.spec.ts +++ b/tests/platform/document/document.spec.ts @@ -100,4 +100,10 @@ test('document', async ({ page }) => { const testImages = page.locator('#testDocumentImages'); const pageUrl = new URL(page.url()); await expect(testImages).toHaveText(`${pageUrl.origin}/fake.jpg`); + + const testDocumentScriptsInitial = page.locator('#testDocumentScriptsInitial'); + await expect(+(await testDocumentScriptsInitial.innerText())).toBeGreaterThan(0); + const value = +(await testDocumentScriptsInitial.innerText()); + const testDocumentScriptsAfter = page.locator('#testDocumentScriptsAfter'); + await expect(+(await testDocumentScriptsAfter.innerText())).toEqual(value + 1); }); diff --git a/tests/platform/document/index.html b/tests/platform/document/index.html index a7bff8f0..5d9df46b 100644 --- a/tests/platform/document/index.html +++ b/tests/platform/document/index.html @@ -464,6 +464,25 @@

Document

+
  • + document.scripts + + + + + +
  • +