diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 361f2c2..136ff9e 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -22,7 +22,10 @@ jobs: uses: actions/setup-node@v4 - name: Install dependencies - run: yarn install + run: | + yarn install + yarn playwright install + yarn playwright install-deps - name: Lint run: yarn lint diff --git a/CHANGELOG.md b/CHANGELOG.md index 14c136c..34c7e10 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,11 @@ All notable changes to this add-on will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). +## Unreleased + +### Changed +- Report index of the forms. + ## 0.0.9 - 2024-11-28 ### Added diff --git a/package.json b/package.json index 754b17a..c311f56 100644 --- a/package.json +++ b/package.json @@ -91,8 +91,8 @@ "json-server": "^0.17.3", "mini-css-extract-plugin": "^1.6.0", "optimize-css-assets-webpack-plugin": "^6.0.1", - "playwright": "^1.33.0", - "playwright-webextext": "^0.0.3", + "playwright": "^1.49.0", + "playwright-webextext": "^0.0.4", "postcss": "^8.4.31", "postcss-loader": "^4.3.0", "prettier": "^2.3.0", diff --git a/source/types/ReportedModel.ts b/source/types/ReportedModel.ts index e28de8c..3b5baa2 100644 --- a/source/types/ReportedModel.ts +++ b/source/types/ReportedModel.ts @@ -113,6 +113,8 @@ class ReportedElement extends ReportedObject { // This gets the full URL rather than a relative one const a: HTMLAnchorElement = element as HTMLAnchorElement; this.href = a.toString(); + } else if (element.tagName === 'FORM') { + this.formId = Array.prototype.slice.call(document.forms).indexOf(element); } else if (element.tagName === 'INPUT') { // Capture extra useful info for input elements const input: HTMLInputElement = element as HTMLInputElement; diff --git a/test/ContentScript/unitTests.test.ts b/test/ContentScript/unitTests.test.ts index eae39bd..b784eec 100644 --- a/test/ContentScript/unitTests.test.ts +++ b/test/ContentScript/unitTests.test.ts @@ -169,10 +169,10 @@ test('Report page forms', () => { // Then expect(mockFn.mock.calls.length).toBe(2); expect(mockFn.mock.calls[0][0].toNonTimestampString()).toBe( - '{"type":"nodeAdded","tagName":"FORM","id":"form1","nodeName":"FORM","url":"http://localhost/","text":"Content1"}' + '{"type":"nodeAdded","tagName":"FORM","id":"form1","nodeName":"FORM","url":"http://localhost/","text":"Content1","formId":-1}' ); expect(mockFn.mock.calls[1][0].toNonTimestampString()).toBe( - '{"type":"nodeAdded","tagName":"FORM","id":"form2","nodeName":"FORM","url":"http://localhost/","text":"Content2"}' + '{"type":"nodeAdded","tagName":"FORM","id":"form2","nodeName":"FORM","url":"http://localhost/","text":"Content2","formId":-1}' ); }); @@ -263,7 +263,7 @@ test('Reported page loaded', () => { '{"type":"nodeAdded","tagName":"AREA","id":"","nodeName":"AREA","url":"http://localhost/","href":"https://www.example.com/1","text":""}' ); expect(mockFn.mock.calls[2][0].toNonTimestampString()).toBe( - '{"type":"nodeAdded","tagName":"FORM","id":"form1","nodeName":"FORM","url":"http://localhost/","text":"FormContent"}' + '{"type":"nodeAdded","tagName":"FORM","id":"form1","nodeName":"FORM","url":"http://localhost/","text":"FormContent","formId":-1}' ); expect(mockFn.mock.calls[3][0].toNonTimestampString()).toBe( '{"type":"nodeAdded","tagName":"INPUT","id":"input1","nodeName":"INPUT","url":"http://localhost/","text":"default","tagType":"text"}' diff --git a/yarn.lock b/yarn.lock index db8b87e..1bf2bb3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6741,17 +6741,24 @@ playwright-core@1.33.0: resolved "https://registry.yarnpkg.com/playwright-core/-/playwright-core-1.33.0.tgz#269efe29a927cd6d144d05f3c2d2f72bd72447a1" integrity sha512-aizyPE1Cj62vAECdph1iaMILpT0WUDCq3E6rW6I+dleSbBoGbktvJtzS6VHkZ4DKNEOG9qJpiom/ZxO+S15LAw== -playwright-webextext@^0.0.3: - version "0.0.3" - resolved "https://registry.yarnpkg.com/playwright-webextext/-/playwright-webextext-0.0.3.tgz#8f809a439c976dd71a7a4d2f711b01a10d910a8a" - integrity sha512-qcnMZES3vbnEfCrOobsaFrT+BBlRgCmKBCzhoRxPkdC9C5KSOYdROikuTHRoe/ez5v1Eh02szQjwRBStOkDF6g== - -playwright@^1.33.0: - version "1.33.0" - resolved "https://registry.yarnpkg.com/playwright/-/playwright-1.33.0.tgz#88df1cffe97718ab8a02303e12c9133681ec7fab" - integrity sha512-+zzU3V2TslRX2ETBRgQKsKytYBkJeLZ2xzUj4JohnZnxQnivoUvOvNbRBYWSYykQTO0Y4zb8NwZTYFUO+EpPBQ== - dependencies: - playwright-core "1.33.0" +playwright-core@1.49.1: + version "1.49.1" + resolved "https://registry.yarnpkg.com/playwright-core/-/playwright-core-1.49.1.tgz#32c62f046e950f586ff9e35ed490a424f2248015" + integrity sha512-BzmpVcs4kE2CH15rWfzpjzVGhWERJfmnXmniSyKeRZUs9Ws65m+RGIi7mjJK/euCegfn3i7jvqWeWyHe9y3Vgg== + +playwright-webextext@^0.0.4: + version "0.0.4" + resolved "https://registry.yarnpkg.com/playwright-webextext/-/playwright-webextext-0.0.4.tgz#84ec8b7999aac758a5dccc34c01353bad2d9c5d8" + integrity sha512-B5uIZSRtH6wi5HPhEwbEkZxEoAY5bUKCjqVW2qCsAYWQTQZ4ULOfsyglI+gfiohxrAzHT+mtkZMXZvHTtunsDg== + +playwright@^1.49.0: + version "1.49.1" + resolved "https://registry.yarnpkg.com/playwright/-/playwright-1.49.1.tgz#830266dbca3008022afa7b4783565db9944ded7c" + integrity sha512-VYL8zLoNTBxVOrJBbDuRgDWa3i+mfQgDTrL8Ah9QXZ7ax4Dsj0MSq5bYgytRnDVVe+njoKnfsYkH3HzqVj5UZA== + dependencies: + playwright-core "1.49.1" + optionalDependencies: + fsevents "2.3.2" please-upgrade-node@^3.2.0: version "3.2.0"