Move inner evaluate helpers into frame class. (#128)

This commit is contained in:
Pavel Feldman 2017-07-25 14:30:04 -07:00 committed by Andrey Lushnikov
parent 4f5f1f6d77
commit 0007809305
3 changed files with 88 additions and 357 deletions

View File

@ -42,9 +42,6 @@ class FrameManager extends EventEmitter {
this._frames = new Map();
this._mainFrame = this._addFramesRecursively(null, frameTree);
/** @type {!Map<string, string>} */
this._frameIdToExecutionContextId = new Map();
this._client.on('Page.frameAttached', event => this._onFrameAttached(event.frameId, event.parentFrameId));
this._client.on('Page.frameNavigated', event => this._onFrameNavigated(event.frame));
this._client.on('Page.frameDetached', event => this._onFrameDetached(event.frameId));
@ -73,14 +70,9 @@ class FrameManager extends EventEmitter {
_onFrameAttached(frameId, parentFrameId) {
if (this._frames.has(frameId))
return;
if (!parentFrameId) {
// Navigation to the new backend process.
this._navigateFrame(this._mainFrame, frameId, null);
return;
}
console.assert(parentFrameId);
let parentFrame = this._frames.get(parentFrameId);
let frame = new Frame(this, parentFrame, frameId, null);
let frame = new Frame(this._client, this._mouse, parentFrame, frameId, null);
this._frames.set(frame._id, frame);
this.emit(FrameManager.Events.FrameAttached, frame);
}
@ -108,8 +100,11 @@ class FrameManager extends EventEmitter {
}
_onExecutionContextCreated(context) {
if (context.auxData && context.auxData.isDefault && context.auxData.frameId)
this._frameIdToExecutionContextId.set(context.auxData.frameId, context.id);
const frameId = context.auxData && context.auxData.isDefault ? context.auxData.frameId : null;
const frame = this._frames.get(frameId);
if (!frame)
return;
frame._defaultContextId = context.id;
}
/**
@ -122,7 +117,6 @@ class FrameManager extends EventEmitter {
for (let child of frame.childFrames())
this._removeFramesRecursively(child);
this._frames.delete(frame._id, frame);
this._frameIdToExecutionContextId.delete(frame._id);
frame._id = newFrameId;
frame._adoptPayload(newFramePayload);
this._frames.set(newFrameId, frame);
@ -136,7 +130,7 @@ class FrameManager extends EventEmitter {
*/
_addFramesRecursively(parentFrame, frameTreePayload) {
let framePayload = frameTreePayload.frame;
let frame = new Frame(this, parentFrame, framePayload.id, framePayload);
let frame = new Frame(this._client, this._mouse, parentFrame, framePayload.id, framePayload);
this._frames.set(frame._id, frame);
for (let i = 0; frameTreePayload.childFrames && i < frameTreePayload.childFrames.length; ++i)
@ -152,49 +146,8 @@ class FrameManager extends EventEmitter {
this._removeFramesRecursively(child);
frame._detach();
this._frames.delete(frame._id);
this._frameIdToExecutionContextId.delete(frame._id);
this.emit(FrameManager.Events.FrameDetached, frame);
}
/**
* @param {!Frame} frame
* @return {number}
*/
_contextIdForFrame(frame) {
let contextId = undefined;
if (frame !== this._mainFrame) {
contextId = this._frameIdToExecutionContextId.get(frame._id);
console.assert(contextId, 'Frame does not have default context to evaluate in!');
}
return contextId;
}
/**
* @param {!Frame} frame
* @param {string} expression
* @return {!Promise<(!Object|undefined)>}
*/
async _evaluateOnFrame(frame, expression) {
let contextId = this._contextIdForFrame(frame);
expression = `Promise.resolve(${expression})`;
let { exceptionDetails, result: remoteObject } = await this._client.send('Runtime.evaluate', { expression, contextId, returnByValue: false, awaitPromise: true });
if (exceptionDetails)
throw new Error('Evaluation failed: ' + helper.getExceptionMessage(exceptionDetails));
return await helper.serializeRemoteObject(this._client, remoteObject);
}
/**
* @param {!Frame} frame
* @param {string} expression
* @return {!Promise<(!Object|undefined)>}
*/
async _rawEvaluateOnFrame(frame, expression) {
let contextId = this._contextIdForFrame(frame);
let { exceptionDetails, result: remoteObject } = await this._client.send('Runtime.evaluate', { expression, contextId, returnByValue: false });
if (exceptionDetails)
throw new Error('Evaluation failed: ' + helper.getExceptionMessage(exceptionDetails));
return await helper.serializeRemoteObject(this._client, remoteObject);
}
}
/** @enum {string} */
@ -209,16 +162,19 @@ FrameManager.Events = {
*/
class Frame {
/**
* @param {!FrameManager} frameManager
* @param {!Connection} client
* @param {!Mouse} mouse
* @param {?Frame} parentFrame
* @param {string} frameId
* @param {?Object} payload
*/
constructor(frameManager, parentFrame, frameId, payload) {
this._frameManager = frameManager;
constructor(client, mouse, parentFrame, frameId, payload) {
this._client = client;
this._mouse = mouse;
this._parentFrame = parentFrame;
this._url = '';
this._id = frameId;
this._defaultContextId = '<not-initialized>';
/** @type {!Set<!WaitTask>} */
this._waitTasks = new Set();
@ -236,7 +192,22 @@ class Frame {
* @return {!Promise<(!Object|undefined)>}
*/
async evaluate(pageFunction, ...args) {
return this._frameManager._evaluateOnFrame(this, helper.evaluationString(pageFunction, ...args));
return this._evaluateExpression(helper.evaluationString(pageFunction, ...args), true);
}
/**
* @param {string} expression
* @param {boolean} awaitPromise
* @return {!Promise<(!Object|undefined)>}
*/
async _evaluateExpression(expression, awaitPromise) {
const contextId = this._defaultContextId;
if (awaitPromise)
expression = `Promise.resolve(${expression})`;
let { exceptionDetails, result: remoteObject } = await this._client.send('Runtime.evaluate', { expression, contextId, returnByValue: false, awaitPromise});
if (exceptionDetails)
throw new Error('Evaluation failed: ' + helper.getExceptionMessage(exceptionDetails));
return await helper.serializeRemoteObject(this._client, remoteObject);
}
/**
@ -286,7 +257,7 @@ class Frame {
});
});
contents += `//# sourceURL=` + filePath.replace(/\n/g,'');
return this._frameManager._rawEvaluateOnFrame(this, contents);
return this._evaluateExpression(contents, false);
}
/**
@ -330,7 +301,7 @@ class Frame {
const timeout = options.timeout || 30000;
const waitForVisible = !!options.visible;
const pageScript = helper.evaluationString(waitForSelectorPageFunction, selector, waitForVisible, timeout);
const waitTask = new WaitTask(this._frameManager, this, pageScript, timeout);
const waitTask = new WaitTask(this, pageScript, timeout);
this._waitTasks.add(waitTask);
let cleanup = () => this._waitTasks.delete(waitTask);
@ -352,7 +323,7 @@ class Frame {
return null;
return (${pageFunction})(${argsString});
})()`;
return this._frameManager._evaluateOnFrame(this, expression);
return this._evaluateExpression(expression, true);
}
/**
@ -367,7 +338,7 @@ class Frame {
let nodes = document.querySelectorAll(${JSON.stringify(selector)});
return Array.prototype.map.call(nodes, (node, index) => (${pageFunction})(${argsString}));
})()`;
return this._frameManager._evaluateOnFrame(this, expression);
return this._evaluateExpression(expression, true);
}
/**
@ -395,7 +366,7 @@ class Frame {
}, selector);
if (!center)
throw new Error('No node found for selector: ' + selector);
await this._frameManager._mouse.move(center.x, center.y);
await this._mouse.move(center.x, center.y);
}
/**
@ -405,7 +376,7 @@ class Frame {
*/
async click(selector, options) {
await this.hover(selector);
await this._frameManager._mouse.press(options);
await this._mouse.press(options);
// This is a hack for now, to make clicking less race-prone
await this.evaluate(() => new Promise(f => requestAnimationFrame(f)));
}
@ -453,13 +424,11 @@ helper.tracePublicAPI(Frame);
class WaitTask {
/**
* @param {!FrameManager} frameManager
* @param {!Frame} frame
* @param {string} pageScript
* @param {number} timeout
*/
constructor(frameManager, frame, pageScript, timeout) {
this._frameManager = frameManager;
constructor(frame, pageScript, timeout) {
this._frame = frame;
this._pageScript = pageScript;
this._runningTask = null;
@ -482,7 +451,7 @@ class WaitTask {
}
run() {
let runningTask = this._frameManager._evaluateOnFrame(this._frame, this._pageScript).then(finish.bind(this), finish.bind(this, false));
let runningTask = this._frame._evaluateExpression(this._pageScript, true).then(finish.bind(this), finish.bind(this, false));
this._runningTask = runningTask;
/**

331
package-lock.json generated
View File

@ -2,7 +2,6 @@
"name": "puppeteer",
"version": "0.0.1",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"acorn": {
"version": "5.1.1",
@ -53,10 +52,7 @@
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/ansi-red/-/ansi-red-0.1.1.tgz",
"integrity": "sha1-jGOPnRCAgAo1PJwoyKgcpHBdlGw=",
"dev": true,
"requires": {
"ansi-wrap": "0.1.0"
}
"dev": true
},
"ansi-regex": {
"version": "2.1.1",
@ -137,11 +133,7 @@
"brace-expansion": {
"version": "1.1.8",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.8.tgz",
"integrity": "sha1-wHshHHyVLsH479Uad+8NHTmQopI=",
"requires": {
"balanced-match": "1.0.0",
"concat-map": "0.0.1"
}
"integrity": "sha1-wHshHHyVLsH479Uad+8NHTmQopI="
},
"caller-path": {
"version": "0.1.0",
@ -208,13 +200,7 @@
"version": "0.27.0",
"resolved": "https://registry.npmjs.org/commonmark/-/commonmark-0.27.0.tgz",
"integrity": "sha1-2GwmK5YoIelIPGnFR7xYhAwEezQ=",
"dev": true,
"requires": {
"entities": "1.1.1",
"mdurl": "1.0.1",
"minimist": "1.2.0",
"string.prototype.repeat": "0.2.0"
}
"dev": true
},
"concat-map": {
"version": "0.0.1",
@ -224,12 +210,7 @@
"concat-stream": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.0.tgz",
"integrity": "sha1-CqxmL9Ur54lk1VMvaUeE5wEQrPc=",
"requires": {
"inherits": "2.0.3",
"readable-stream": "2.3.3",
"typedarray": "0.0.6"
}
"integrity": "sha1-CqxmL9Ur54lk1VMvaUeE5wEQrPc="
},
"core-util-is": {
"version": "1.0.2",
@ -240,19 +221,12 @@
"version": "0.1.10",
"resolved": "https://registry.npmjs.org/deasync/-/deasync-0.1.10.tgz",
"integrity": "sha1-TkpoNvvgR3vV+Qgwi9KpZVfV1/4=",
"dev": true,
"requires": {
"bindings": "1.2.1",
"nan": "2.6.2"
}
"dev": true
},
"debug": {
"version": "2.6.8",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.8.tgz",
"integrity": "sha1-5zFTHKLt4n0YgiJCfaF4IdaP9Pw=",
"requires": {
"ms": "2.0.0"
}
"integrity": "sha1-5zFTHKLt4n0YgiJCfaF4IdaP9Pw="
},
"deep-is": {
"version": "0.1.3",
@ -308,50 +282,12 @@
"resolved": "https://registry.npmjs.org/eslint/-/eslint-4.1.1.tgz",
"integrity": "sha1-+svfz+Pg+s06i4DcmMTmwTrlgt8=",
"dev": true,
"requires": {
"babel-code-frame": "6.22.0",
"chalk": "1.1.3",
"concat-stream": "1.6.0",
"debug": "2.6.8",
"doctrine": "2.0.0",
"eslint-scope": "3.7.1",
"espree": "3.4.3",
"esquery": "1.0.0",
"estraverse": "4.2.0",
"esutils": "2.0.2",
"file-entry-cache": "2.0.0",
"glob": "7.1.2",
"globals": "9.18.0",
"ignore": "3.3.3",
"imurmurhash": "0.1.4",
"inquirer": "3.1.1",
"is-my-json-valid": "2.16.0",
"is-resolvable": "1.0.0",
"js-yaml": "3.8.4",
"json-stable-stringify": "1.0.1",
"levn": "0.3.0",
"lodash": "4.17.4",
"minimatch": "3.0.4",
"mkdirp": "0.5.1",
"natural-compare": "1.4.0",
"optionator": "0.8.2",
"path-is-inside": "1.0.2",
"pluralize": "4.0.0",
"progress": "2.0.0",
"require-uncached": "1.0.3",
"strip-json-comments": "2.0.1",
"table": "4.0.1",
"text-table": "0.2.0"
},
"dependencies": {
"debug": {
"version": "2.6.8",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.8.tgz",
"integrity": "sha1-5zFTHKLt4n0YgiJCfaF4IdaP9Pw=",
"dev": true,
"requires": {
"ms": "2.0.0"
}
"dev": true
},
"minimist": {
"version": "0.0.8",
@ -363,10 +299,7 @@
"version": "0.5.1",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
"integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
"dev": true,
"requires": {
"minimist": "0.0.8"
}
"dev": true
},
"ms": {
"version": "2.0.0",
@ -399,7 +332,7 @@
"esprima": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz",
"integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw==",
"integrity": "sha1-RJnt3NERDgshi6zy+n9/WfVcqAQ=",
"dev": true
},
"esquery": {
@ -443,19 +376,13 @@
"version": "1.8.2",
"resolved": "https://registry.npmjs.org/expand-range/-/expand-range-1.8.2.tgz",
"integrity": "sha1-opnv/TNf4nIeuujiV+x5ZE/IUzc=",
"dev": true,
"requires": {
"fill-range": "2.2.3"
}
"dev": true
},
"extend-shallow": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz",
"integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=",
"dev": true,
"requires": {
"is-extendable": "0.1.1"
}
"dev": true
},
"external-editor": {
"version": "2.0.4",
@ -472,20 +399,11 @@
"version": "1.6.5",
"resolved": "https://registry.npmjs.org/extract-zip/-/extract-zip-1.6.5.tgz",
"integrity": "sha1-maBnNbbqIOqbcF13ms/8yHz/BEA=",
"requires": {
"concat-stream": "1.6.0",
"debug": "2.2.0",
"mkdirp": "0.5.0",
"yauzl": "2.4.1"
},
"dependencies": {
"debug": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz",
"integrity": "sha1-+HBX6ZWxofauaklgZkE3vFbwOdo=",
"requires": {
"ms": "0.7.1"
}
"integrity": "sha1-+HBX6ZWxofauaklgZkE3vFbwOdo="
},
"ms": {
"version": "0.7.1",
@ -503,10 +421,7 @@
"fd-slicer": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.0.1.tgz",
"integrity": "sha1-i1vL2ewyfFBBv5qwI/1nUPEXfmU=",
"requires": {
"pend": "1.2.0"
}
"integrity": "sha1-i1vL2ewyfFBBv5qwI/1nUPEXfmU="
},
"figures": {
"version": "2.0.0",
@ -531,14 +446,7 @@
"version": "2.2.3",
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-2.2.3.tgz",
"integrity": "sha1-ULd9/X5Gm8dJJHCWNpn+eoSFpyM=",
"dev": true,
"requires": {
"is-number": "2.1.0",
"isobject": "2.1.0",
"randomatic": "1.1.7",
"repeat-element": "1.1.2",
"repeat-string": "1.6.1"
}
"dev": true
},
"flat-cache": {
"version": "1.2.2",
@ -573,23 +481,12 @@
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/generate-object-property/-/generate-object-property-1.2.0.tgz",
"integrity": "sha1-nA4cQDCM6AT0eDYYuTf6iPmdUNA=",
"dev": true,
"requires": {
"is-property": "1.0.2"
}
"dev": true
},
"glob": {
"version": "7.1.2",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz",
"integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==",
"requires": {
"fs.realpath": "1.0.0",
"inflight": "1.0.6",
"inherits": "2.0.3",
"minimatch": "3.0.4",
"once": "1.4.0",
"path-is-absolute": "1.0.1"
}
"integrity": "sha1-wZyd+aAocC1nhhI4SmVSQExjbRU="
},
"globals": {
"version": "9.18.0",
@ -621,14 +518,7 @@
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/gray-matter/-/gray-matter-2.1.1.tgz",
"integrity": "sha1-MELZrewqHe1qdwep7SOA+KF6Qw4=",
"dev": true,
"requires": {
"ansi-red": "0.1.1",
"coffee-script": "1.12.6",
"extend-shallow": "2.0.1",
"js-yaml": "3.8.4",
"toml": "2.3.2"
}
"dev": true
},
"has-ansi": {
"version": "2.0.0",
@ -660,11 +550,7 @@
"inflight": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
"integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=",
"requires": {
"once": "1.4.0",
"wrappy": "1.0.2"
}
"integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk="
},
"inherits": {
"version": "2.0.3",
@ -675,23 +561,7 @@
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/inquirer/-/inquirer-3.1.1.tgz",
"integrity": "sha512-H50sHQwgvvaTBd3HpKMVtL/u6LoHDvYym51gd7bGQe/+9HkCE+J0/3N5FJLfd6O6oz44hHewC2Pc2LodzWVafQ==",
"dev": true,
"requires": {
"ansi-escapes": "2.0.0",
"chalk": "1.1.3",
"cli-cursor": "2.1.0",
"cli-width": "2.1.0",
"external-editor": "2.0.4",
"figures": "2.0.0",
"lodash": "4.17.4",
"mute-stream": "0.0.7",
"run-async": "2.3.0",
"rx-lite": "4.0.8",
"rx-lite-aggregates": "4.0.8",
"string-width": "2.1.0",
"strip-ansi": "3.0.1",
"through": "2.3.8"
}
"dev": true
},
"is-buffer": {
"version": "1.1.5",
@ -715,22 +585,13 @@
"version": "2.16.0",
"resolved": "https://registry.npmjs.org/is-my-json-valid/-/is-my-json-valid-2.16.0.tgz",
"integrity": "sha1-8Hndm/2uZe4gOKrorLyGqxCeNpM=",
"dev": true,
"requires": {
"generate-function": "2.0.0",
"generate-object-property": "1.2.0",
"jsonpointer": "4.0.1",
"xtend": "4.0.1"
}
"dev": true
},
"is-number": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/is-number/-/is-number-2.1.0.tgz",
"integrity": "sha1-Afy7s5NGOlSPL0ZszhbezknbkI8=",
"dev": true,
"requires": {
"kind-of": "3.2.2"
}
"dev": true
},
"is-path-cwd": {
"version": "1.0.0",
@ -786,21 +647,13 @@
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz",
"integrity": "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=",
"dev": true,
"requires": {
"isarray": "1.0.0"
}
"dev": true
},
"jasmine": {
"version": "2.6.0",
"resolved": "https://registry.npmjs.org/jasmine/-/jasmine-2.6.0.tgz",
"integrity": "sha1-ayLnCIPo5YnUVjRhU7TSBt2+IX8=",
"dev": true,
"requires": {
"exit": "0.1.2",
"glob": "7.1.2",
"jasmine-core": "2.6.4"
}
"dev": true
},
"jasmine-core": {
"version": "2.6.4",
@ -819,10 +672,6 @@
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.8.4.tgz",
"integrity": "sha1-UgtFZPhlc7qWZir4Woyvp7S1pvY=",
"dev": true,
"requires": {
"argparse": "1.0.9",
"esprima": "3.1.3"
},
"dependencies": {
"esprima": {
"version": "3.1.3",
@ -863,19 +712,13 @@
"version": "3.2.2",
"resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz",
"integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=",
"dev": true,
"requires": {
"is-buffer": "1.1.5"
}
"dev": true
},
"lazy-cache": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/lazy-cache/-/lazy-cache-2.0.2.tgz",
"integrity": "sha1-uRkKT5EzVGlIQIWfio9whNiCImQ=",
"dev": true,
"requires": {
"set-getter": "0.1.0"
}
"dev": true
},
"levn": {
"version": "0.3.0",
@ -891,13 +734,7 @@
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/list-item/-/list-item-1.1.1.tgz",
"integrity": "sha1-DGXQDih8tmPMs8s4Sad+iewmilY=",
"dev": true,
"requires": {
"expand-range": "1.8.2",
"extend-shallow": "2.0.1",
"is-number": "2.1.0",
"repeat-string": "1.6.1"
}
"dev": true
},
"lodash": {
"version": "4.17.4",
@ -915,21 +752,7 @@
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/markdown-toc/-/markdown-toc-1.1.0.tgz",
"integrity": "sha1-GORyN9iVSelEcSHmniyoU8otdSo=",
"dev": true,
"requires": {
"concat-stream": "1.6.0",
"diacritics-map": "0.1.0",
"gray-matter": "2.1.1",
"lazy-cache": "2.0.2",
"list-item": "1.1.1",
"markdown-link": "0.1.1",
"minimist": "1.2.0",
"mixin-deep": "1.2.0",
"object.pick": "1.2.0",
"remarkable": "1.7.1",
"repeat-string": "1.6.1",
"strip-color": "0.1.0"
}
"dev": true
},
"mdurl": {
"version": "1.0.1",
@ -951,10 +774,7 @@
"minimatch": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
"requires": {
"brace-expansion": "1.1.8"
}
"integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM="
},
"minimist": {
"version": "1.2.0",
@ -966,19 +786,12 @@
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.2.0.tgz",
"integrity": "sha1-0CuMb4ttS49ZgtP9AJxJGYUcP+I=",
"dev": true,
"requires": {
"for-in": "1.0.2",
"is-extendable": "0.1.1"
}
"dev": true
},
"mkdirp": {
"version": "0.5.0",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.0.tgz",
"integrity": "sha1-HXMHam35hs2TROFecfzAWkyavxI=",
"requires": {
"minimist": "0.0.8"
},
"dependencies": {
"minimist": {
"version": "0.0.8",
@ -1026,18 +839,12 @@
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/object.pick/-/object.pick-1.2.0.tgz",
"integrity": "sha1-tTkr7peC2m2ft9avr1OXefEjTCs=",
"dev": true,
"requires": {
"isobject": "2.1.0"
}
"dev": true
},
"once": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
"integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
"requires": {
"wrappy": "1.0.2"
}
"integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E="
},
"onetime": {
"version": "2.0.1",
@ -1109,10 +916,7 @@
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/pixelmatch/-/pixelmatch-4.0.2.tgz",
"integrity": "sha1-j0fc7FARtHe2fbA8JDvB8wheiFQ=",
"dev": true,
"requires": {
"pngjs": "3.2.0"
}
"dev": true
},
"pluralize": {
"version": "4.0.0",
@ -1145,30 +949,20 @@
"randomatic": {
"version": "1.1.7",
"resolved": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.7.tgz",
"integrity": "sha512-D5JUjPyJbaJDkuAazpVnSfVkLlpeO3wDlPROTMLGKG1zMFNFRgrciKo1ltz/AzNTkqE0HzDx655QOL51N06how==",
"integrity": "sha1-x6vpzIuHwLqodrGf3oP9RkeX44w=",
"dev": true,
"requires": {
"is-number": "3.0.0",
"kind-of": "4.0.0"
},
"dependencies": {
"is-number": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz",
"integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=",
"dev": true,
"requires": {
"kind-of": "3.2.2"
},
"dependencies": {
"kind-of": {
"version": "3.2.2",
"resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz",
"integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=",
"dev": true,
"requires": {
"is-buffer": "1.1.5"
}
"dev": true
}
}
},
@ -1176,46 +970,26 @@
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/kind-of/-/kind-of-4.0.0.tgz",
"integrity": "sha1-IIE989cSkosgc3hpGkUGb65y3Vc=",
"dev": true,
"requires": {
"is-buffer": "1.1.5"
}
"dev": true
}
}
},
"readable-stream": {
"version": "2.3.3",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz",
"integrity": "sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ==",
"requires": {
"core-util-is": "1.0.2",
"inherits": "2.0.3",
"isarray": "1.0.0",
"process-nextick-args": "1.0.7",
"safe-buffer": "5.1.1",
"string_decoder": "1.0.3",
"util-deprecate": "1.0.2"
}
"integrity": "sha1-No8lEtefnUb9/HE0mueHi7weuVw="
},
"remarkable": {
"version": "1.7.1",
"resolved": "https://registry.npmjs.org/remarkable/-/remarkable-1.7.1.tgz",
"integrity": "sha1-qspJchALZqZCpjoQIcpLrBvjv/Y=",
"dev": true,
"requires": {
"argparse": "0.1.16",
"autolinker": "0.15.3"
},
"dependencies": {
"argparse": {
"version": "0.1.16",
"resolved": "https://registry.npmjs.org/argparse/-/argparse-0.1.16.tgz",
"integrity": "sha1-z9AeD7uj1srtBJ+9dY1A9lGW9Xw=",
"dev": true,
"requires": {
"underscore": "1.7.0",
"underscore.string": "2.4.0"
}
"dev": true
}
}
},
@ -1260,10 +1034,7 @@
"rimraf": {
"version": "2.6.1",
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.1.tgz",
"integrity": "sha1-wjOOxkPfeht/5cVPqG9XQopV8z0=",
"requires": {
"glob": "7.1.2"
}
"integrity": "sha1-wjOOxkPfeht/5cVPqG9XQopV8z0="
},
"run-async": {
"version": "2.3.0",
@ -1292,16 +1063,13 @@
"safe-buffer": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz",
"integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg=="
"integrity": "sha1-iTMSr2myEj3vcfV4iQAWce6yyFM="
},
"set-getter": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/set-getter/-/set-getter-0.1.0.tgz",
"integrity": "sha1-12nBgsnVpR9AkUXy+6guXoboA3Y=",
"dev": true,
"requires": {
"to-object-path": "0.3.0"
}
"dev": true
},
"signal-exit": {
"version": "3.0.2",
@ -1324,10 +1092,7 @@
"string_decoder": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz",
"integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==",
"requires": {
"safe-buffer": "5.1.1"
}
"integrity": "sha1-D8Z9fBQYJd6UKC3VNr7GubzoYKs="
},
"string-width": {
"version": "2.1.0",
@ -1434,10 +1199,7 @@
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/to-object-path/-/to-object-path-0.3.0.tgz",
"integrity": "sha1-KXWIt7Dn4KwI4E5nL4XB9JmeF68=",
"dev": true,
"requires": {
"kind-of": "3.2.2"
}
"dev": true
},
"toml": {
"version": "2.3.2",
@ -1528,10 +1290,6 @@
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/ws/-/ws-3.0.0.tgz",
"integrity": "sha1-mN2wAFbIOQy3Ued4h4hJf5kQO2w=",
"requires": {
"safe-buffer": "5.0.1",
"ultron": "1.1.0"
},
"dependencies": {
"safe-buffer": {
"version": "5.0.1",
@ -1549,10 +1307,7 @@
"yauzl": {
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.4.1.tgz",
"integrity": "sha1-lSj0QtqxsihOWLQ3m7GU4i4MQAU=",
"requires": {
"fd-slicer": "1.0.1"
}
"integrity": "sha1-lSj0QtqxsihOWLQ3m7GU4i4MQAU="
}
}
}

View File

@ -166,6 +166,13 @@ describe('Puppeteer', function() {
expect(await frame1.evaluate(() => window.FOO)).toBe('foo');
expect(await frame2.evaluate(() => window.FOO)).toBe('bar');
}));
it('should execute after cross-site navigation', SX(async function() {
await page.navigate(EMPTY_PAGE);
let mainFrame = page.mainFrame();
expect(await mainFrame.evaluate(() => window.location.href)).toContain('localhost');
await page.navigate('http://127.0.0.1:' + PORT + '/empty.html');
expect(await mainFrame.evaluate(() => window.location.href)).toContain('127');
}));
});
describe('Frame.waitForSelector', function() {