fix implementation of Page.injectFile method
This commit is contained in:
parent
68a24b7336
commit
58ad5dd823
@ -87,8 +87,8 @@ class Page extends EventEmitter {
|
||||
* @return {!Promise}
|
||||
*/
|
||||
async injectFile(filePath) {
|
||||
var scriptContent = fs.readFileSync(filePath, 'utf8');
|
||||
await this.evaluate(scriptContent);
|
||||
var code = fs.readFileSync(filePath, 'utf8');
|
||||
await helpers.evaluateText(this._client, code, false /* awaitPromise */);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -54,8 +54,18 @@ var helpers = module.exports = {
|
||||
*/
|
||||
evaluate: function(client, fun, args, awaitPromise, sourceURL) {
|
||||
var code = helpers.evaluationString(fun, args, awaitPromise, sourceURL);
|
||||
return helpers.evaluateText(client, code, awaitPromise);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {!CDP} client
|
||||
* @param {string} text
|
||||
* @param {boolean} awaitPromise
|
||||
* @return {!Promise<!Object>}
|
||||
*/
|
||||
evaluateText: function(client, text, awaitPromise) {
|
||||
return client.send('Runtime.evaluate', {
|
||||
expression: code,
|
||||
expression: text,
|
||||
awaitPromise: awaitPromise,
|
||||
returnByValue: true
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user