New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

chrome-page-eval

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chrome-page-eval - npm Package Compare versions

Comparing version

to
1.1.0

test/sampleJSTrigger.html

7

lib/eval.js

@@ -67,2 +67,4 @@ 'use strict'

args = [],
waitForJS = false,
waitForJSVarName = 'CHROME_PAGE_EVAL_READY',
waitUntil,

@@ -150,2 +152,7 @@ // use the same default value of puppeteer

if (waitForJS === true) {
debugMe('Chrome will wait for JS trigger..')
await page.waitForFunction(`window.${waitForJSVarName} === true`, { timeout })
}
debugMe('evaluating scriptFn with args:', args)

@@ -152,0 +159,0 @@

2

package.json
{
"name": "chrome-page-eval",
"version": "1.0.1",
"version": "1.1.0",
"description": "Evaluate a script function on a page with Chrome",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -71,2 +71,53 @@ 'use strict'

it('should wait for JS trigger to start to eval', async () => {
const result = await chromeEval({
html: path.join(__dirname, 'sampleJSTrigger.html'),
waitForJS: true,
scriptFn: `
function () {
let title = document.title
let content = Array.from(document.querySelectorAll('.content'), (node) => {
return node.textContent
})
return {
title,
content
}
}
`
})
should(result).be.Object()
should(result.title).be.eql('Test page')
should(result.content).have.length(5)
})
it('should wait for JS trigger to start to eval (custom var name)', async () => {
const result = await chromeEval({
html: path.join(__dirname, 'sampleJSTrigger2.html'),
waitForJS: true,
waitForJSVarName: 'READY_TO_START',
scriptFn: `
function () {
let title = document.title
let content = Array.from(document.querySelectorAll('.content'), (node) => {
return node.textContent
})
return {
title,
content
}
}
`
})
should(result).be.Object()
should(result.title).be.eql('Test page')
should(result.content).have.length(5)
})
it('should pass custom args to script', async () => {

@@ -73,0 +124,0 @@ const result = await chromeEval({