Implement page.waitForFunction method

The page.waitForFunction method allows to wait for a general predicate.
The predicate will be continiously polled for in page, until
it either returns true or the timeout happens.

The polling parameter could be one of the following:
- 'raf' - to poll on every animation frame
- 'mutation' - to poll on every dom mutation
- <number> - to poll every X milliseconds

References #91
This commit is contained in:
Andrey Lushnikov
2017-07-27 15:17:43 -07:00
parent 47a0366b16
commit ff5ed1c738
5 changed files with 197 additions and 31 deletions

View File

@@ -23,7 +23,7 @@ class Helper {
* @return {string}
*/
static evaluationString(fun, ...args) {
if (typeof fun === 'string') {
if (Helper.isString(fun)) {
console.assert(args.length === 0, 'Cannot evaluate a string with arguments');
return fun;
}
@@ -181,6 +181,22 @@ class Helper {
static recordPublicAPICoverage() {
apiCoverage = new Map();
}
/**
* @param {!Object} obj
* @return {boolean}
*/
static isString(obj) {
return typeof obj === 'string' || obj instanceof String;
}
/**
* @param {!Object} obj
* @return {boolean}
*/
static isNumber(obj) {
return typeof obj === 'number' || obj instanceof Number;
}
}
module.exports = Helper;