mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
parent
a033b1b7ac
commit
a66480a416
@ -12,5 +12,5 @@ install:
|
|||||||
# puppeteer's install script downloads Chrome
|
# puppeteer's install script downloads Chrome
|
||||||
script:
|
script:
|
||||||
- yarn run lint
|
- yarn run lint
|
||||||
- yarn run test-puppeteer
|
- yarn run unit
|
||||||
- yarn run test-phantom
|
- yarn run test-phantom
|
||||||
|
14
lib/Page.js
14
lib/Page.js
@ -123,7 +123,7 @@ class Page extends EventEmitter {
|
|||||||
await this._client.send('Runtime.evaluate', { expression, returnByValue: true });
|
await this._client.send('Runtime.evaluate', { expression, returnByValue: true });
|
||||||
|
|
||||||
function inPageCallback(callbackName) {
|
function inPageCallback(callbackName) {
|
||||||
window[callbackName] = async (...args) => {
|
window[callbackName] = async(...args) => {
|
||||||
const me = window[callbackName];
|
const me = window[callbackName];
|
||||||
let callbacks = me['callbacks'];
|
let callbacks = me['callbacks'];
|
||||||
if (!callbacks) {
|
if (!callbacks) {
|
||||||
@ -133,6 +133,7 @@ class Page extends EventEmitter {
|
|||||||
const seq = (me['lastSeq'] || 0) + 1;
|
const seq = (me['lastSeq'] || 0) + 1;
|
||||||
me['lastSeq'] = seq;
|
me['lastSeq'] = seq;
|
||||||
const promise = new Promise(fulfill => callbacks.set(seq, fulfill));
|
const promise = new Promise(fulfill => callbacks.set(seq, fulfill));
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
console.debug('driver:InPageCallback', JSON.stringify({name: callbackName, seq, args}));
|
console.debug('driver:InPageCallback', JSON.stringify({name: callbackName, seq, args}));
|
||||||
return promise;
|
return promise;
|
||||||
};
|
};
|
||||||
@ -523,17 +524,6 @@ class Page extends EventEmitter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class InPageCallback {
|
|
||||||
/**
|
|
||||||
* @param {string} name
|
|
||||||
* @param {function(?):?} callback
|
|
||||||
*/
|
|
||||||
constructor(name, callback) {
|
|
||||||
this.name = name;
|
|
||||||
this.callback = callback;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @enum {string} */
|
/** @enum {string} */
|
||||||
Page.PaperFormats = {
|
Page.PaperFormats = {
|
||||||
Letter: {width: 8.5, height: 11},
|
Letter: {width: 8.5, height: 11},
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var helpers = module.exports = {
|
module.exports = {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {function()} fun
|
* @param {function()} fun
|
||||||
|
@ -7,9 +7,9 @@
|
|||||||
"node": ">=7.10.0"
|
"node": ">=7.10.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test-puppeteer": "jasmine test/test.js",
|
"unit": "jasmine test/test.js",
|
||||||
"test-phantom": "python third_party/phantomjs/test/run-tests.py",
|
"test-phantom": "python third_party/phantomjs/test/run-tests.py",
|
||||||
"test": "npm run lint --silent && npm run test-puppeteer && npm run test-phantom",
|
"test": "npm run lint --silent && npm run unit && npm run test-phantom",
|
||||||
"install": "node install.js",
|
"install": "node install.js",
|
||||||
"lint": "[ \"$CI\" = true ] && eslint --quiet -f codeframe . || eslint ."
|
"lint": "[ \"$CI\" = true ] && eslint --quiet -f codeframe . || eslint ."
|
||||||
},
|
},
|
||||||
|
@ -30,6 +30,8 @@ var GOLDEN_DIR = path.join(__dirname, 'golden');
|
|||||||
var OUTPUT_DIR = path.join(__dirname, 'output');
|
var OUTPUT_DIR = path.join(__dirname, 'output');
|
||||||
var PROJECT_DIR = path.join(__dirname, '..');
|
var PROJECT_DIR = path.join(__dirname, '..');
|
||||||
|
|
||||||
|
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10 * 1000;
|
||||||
|
|
||||||
describe('Puppeteer', function() {
|
describe('Puppeteer', function() {
|
||||||
var browser;
|
var browser;
|
||||||
var staticServer;
|
var staticServer;
|
||||||
|
Loading…
Reference in New Issue
Block a user