From 6dac51e246457bee4d7cf914c81341ead7581131 Mon Sep 17 00:00:00 2001 From: Gregg Tavares Date: Tue, 2 Jul 2024 13:27:32 -0700 Subject: [PATCH] cleanup injected js --- test/puppeteer.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/test/puppeteer.js b/test/puppeteer.js index ff95f8ad..3ec417cc 100755 --- a/test/puppeteer.js +++ b/test/puppeteer.js @@ -73,9 +73,9 @@ async function test(port) { for (const {url, js, screenshot} of testPages) { waitingPromiseInfo = makePromiseInfo(); console.log(`===== [ ${url} ] =====`); - if (js) { - await page.evaluateOnNewDocument(js); - } + const id = js + ? await page.evaluateOnNewDocument(js) + : undefined; await page.goto(url); await page.waitForNetworkIdle(); if (js) { @@ -93,6 +93,9 @@ async function test(port) { const path = `${dir}/${name}.png`; await page.screenshot({path}); } + if (id) { + await page.removeScriptToEvaluateOnNewDocument(id.identifier); + } } await browser.close();