diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index af64181..dbe2465 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,7 +20,7 @@ jobs: steps: - name: Check out repository - uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5 + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false @@ -61,6 +61,7 @@ jobs: run: | npm install --prefix "$RUNNER_TEMP/acp-browser" --no-save --ignore-scripts playwright@1.63.0 jquery@3.7.1 "$RUNNER_TEMP/acp-browser/node_modules/.bin/playwright" install --with-deps chromium + ACP_BROWSER_MODULES="$RUNNER_TEMP/acp-browser/node_modules" node tests/browser_fixture_test.cjs ACP_BROWSER_MODULES="$RUNNER_TEMP/acp-browser/node_modules" node tests/theme_ui.cjs ACP_BROWSER_MODULES="$RUNNER_TEMP/acp-browser/node_modules" node tests/maintenance_ui.cjs diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 8aa06ab..cceddf4 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -23,7 +23,7 @@ jobs: steps: - name: Check out repository - uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5 + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false diff --git a/.github/workflows/pr-test-package.yml b/.github/workflows/pr-test-package.yml index f1750f1..ee4f9e5 100644 --- a/.github/workflows/pr-test-package.yml +++ b/.github/workflows/pr-test-package.yml @@ -18,7 +18,7 @@ jobs: if: github.event.label.name == 'test-build' runs-on: ubuntu-latest steps: - - uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: ref: ${{ github.event.pull_request.head.sha }} persist-credentials: false diff --git a/.github/workflows/validate-workflows.yml b/.github/workflows/validate-workflows.yml index 0b0cc02..a0139eb 100644 --- a/.github/workflows/validate-workflows.yml +++ b/.github/workflows/validate-workflows.yml @@ -15,7 +15,7 @@ jobs: actionlint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - name: Install verified actionlint diff --git a/tests/browser_fixture.cjs b/tests/browser_fixture.cjs new file mode 100644 index 0000000..770d3bc --- /dev/null +++ b/tests/browser_fixture.cjs @@ -0,0 +1,12 @@ +// Prepare trusted repository fixtures, not arbitrary/untrusted HTML. Preserve +// inline configuration while loading external scripts and styles explicitly. +async function setFixtureContent(page, html) { + const documentHtml = await page.evaluate(markup => { + const doc = new DOMParser().parseFromString(markup, 'text/html'); + doc.querySelectorAll('script[src], link').forEach(element => element.remove()); + return '' + doc.documentElement.outerHTML; + }, html); + await page.setContent(documentHtml); +} + +module.exports = {setFixtureContent}; diff --git a/tests/browser_fixture_test.cjs b/tests/browser_fixture_test.cjs new file mode 100644 index 0000000..9e645dd --- /dev/null +++ b/tests/browser_fixture_test.cjs @@ -0,0 +1,26 @@ +const assert = require('node:assert/strict'); +const path = require('node:path'); +const dependency = name => process.env.ACP_BROWSER_MODULES ? path.join(process.env.ACP_BROWSER_MODULES, name) : name; +const {chromium} = require(dependency('playwright')); +const {setFixtureContent} = require('./browser_fixture.cjs'); + +(async () => { + const browser = await chromium.launch({headless:true}); + try { + const page = await browser.newPage(); + const requests = []; + await page.route('**/*', route => { requests.push(route.request().url()); return route.abort(); }); + await setFixtureContent(page, `
+ + + + +