Socket
Socket
Sign inDemoInstall

puppeteer

Package Overview
Dependencies
Maintainers
3
Versions
900
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

puppeteer - npm Package Compare versions

Comparing version 1.0.0-next.1515102886297 to 1.0.0-next.1515107202232

87

lib/FrameManager.js

@@ -586,3 +586,3 @@ /**

* @param {boolean} waitForHidden
* @return {boolean}
* @return {?Node|boolean}
*/

@@ -594,6 +594,7 @@ function predicate(selector, waitForVisible, waitForHidden) {

if (!waitForVisible && !waitForHidden)
return true;
return node;
const style = window.getComputedStyle(node);
const isVisible = style && style.visibility !== 'hidden' && hasVisibleBoundingBox();
return (waitForVisible === isVisible || waitForHidden === !isVisible);
const success = (waitForVisible === isVisible || waitForHidden === !isVisible);
return success ? node : null;

@@ -611,3 +612,3 @@ /**

/**
* @param {Function} pageFunction
* @param {Function|string} pageFunction
* @param {!Object=} options

@@ -619,4 +620,3 @@ * @return {!Promise}

const polling = options.polling || 'raf';
const predicateCode = 'return ' + helper.evaluationString(pageFunction, ...args);
return new WaitTask(this, predicateCode, polling, timeout).promise;
return new WaitTask(this, pageFunction, polling, timeout, ...args).promise;
}

@@ -665,7 +665,8 @@

* @param {!Frame} frame
* @param {string} predicateBody
* @param {Function|string} predicateBody
* @param {string|number} polling
* @param {number} timeout
* @param {!Array<*>} args
*/
constructor(frame, predicateBody, polling, timeout) {
constructor(frame, predicateBody, polling, timeout, ...args) {
if (helper.isString(polling))

@@ -679,3 +680,6 @@ console.assert(polling === 'raf' || polling === 'mutation', 'Unknown polling option: ' + polling);

this._frame = frame;
this._pageScript = helper.evaluationString(waitForPredicatePageFunction, predicateBody, polling, timeout);
this._polling = polling;
this._timeout = timeout;
this._predicateBody = helper.isString(predicateBody) ? 'return ' + predicateBody : 'return (' + predicateBody + ')(...args)';
this._args = args;
this._runCount = 0;

@@ -704,6 +708,7 @@ frame._waitTasks.add(this);

const runCount = ++this._runCount;
let success = false;
/** @type {?JSHandle} */
let success = null;
let error = null;
try {
success = await this._frame.evaluate(this._pageScript);
success = await (await this._frame.executionContext()).evaluateHandle(waitForPredicatePageFunction, this._predicateBody, this._polling, this._timeout, ...this._args);
} catch (e) {

@@ -713,8 +718,13 @@ error = e;

if (this._terminated || runCount !== this._runCount)
if (this._terminated || runCount !== this._runCount) {
if (success)
await success.dispose();
return;
}
// Ignore timeouts in pageScript - we track timeouts ourselves.
if (!success && !error)
if (!error && !(await success.jsonValue())) {
await success.dispose();
return;
}

@@ -734,3 +744,3 @@ // When the page is navigated, the promise is rejected.

else
this._resolve();
this._resolve(success);

@@ -751,22 +761,22 @@ this._cleanup();

* @param {number} timeout
* @return {!Promise<boolean>}
* @return {!Promise<*>}
*/
async function waitForPredicatePageFunction(predicateBody, polling, timeout) {
const predicate = new Function(predicateBody);
async function waitForPredicatePageFunction(predicateBody, polling, timeout, ...args) {
const predicate = new Function('...args', predicateBody);
let timedOut = false;
setTimeout(() => timedOut = true, timeout);
if (polling === 'raf')
await pollRaf();
else if (polling === 'mutation')
await pollMutation();
else if (typeof polling === 'number')
await pollInterval(polling);
return !timedOut;
return await pollRaf();
if (polling === 'mutation')
return await pollMutation();
if (typeof polling === 'number')
return await pollInterval(polling);
/**
* @return {!Promise}
* @return {!Promise<*>}
*/
function pollMutation() {
if (predicate())
return Promise.resolve();
const success = predicate.apply(null, args);
if (success)
return Promise.resolve(success);

@@ -776,6 +786,11 @@ let fulfill;

const observer = new MutationObserver(mutations => {
if (timedOut || predicate()) {
if (timedOut) {
observer.disconnect();
fulfill();
}
const success = predicate.apply(null, args);
if (success) {
observer.disconnect();
fulfill(success);
}
});

@@ -791,3 +806,3 @@ observer.observe(document, {

/**
* @return {!Promise}
* @return {!Promise<*>}
*/

@@ -801,4 +816,9 @@ function pollRaf() {

function onRaf() {
if (timedOut || predicate())
if (timedOut) {
fulfill();
return;
}
const success = predicate.apply(null, args);
if (success)
fulfill(success);
else

@@ -811,3 +831,3 @@ requestAnimationFrame(onRaf);

* @param {number} pollInterval
* @return {!Promise}
* @return {!Promise<*>}
*/

@@ -821,4 +841,9 @@ function pollInterval(pollInterval) {

function onTimeout() {
if (timedOut || predicate())
if (timedOut) {
fulfill();
return;
}
const success = predicate.apply(null, args);
if (success)
fulfill(success);
else

@@ -825,0 +850,0 @@ setTimeout(onTimeout, pollInterval);

{
"name": "puppeteer",
"version": "1.0.0-next.1515102886297",
"version": "1.0.0-next.1515107202232",
"description": "A high-level API to control headless Chrome over the DevTools Protocol",

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc