Implement Frame.evaluate

This patch implements Frame.evaluate method.

References #4.
This commit is contained in:
Andrey Lushnikov
2017-06-27 12:40:46 -07:00
parent 4b0b3b5ff5
commit 3d90ea38a9
5 changed files with 143 additions and 59 deletions

View File

@@ -81,6 +81,21 @@ describe('Puppeteer', function() {
}));
});
describe('Frame.evaluate', function() {
let FrameUtils = require('./frame-utils');
it('should have different execution contexts', SX(async function() {
await page.navigate(EMPTY_PAGE);
await FrameUtils.attachFrame(page, 'frame1', EMPTY_PAGE);
expect(page.frames().length).toBe(2);
let frame1 = page.frames()[0];
let frame2 = page.frames()[1];
await frame1.evaluate(() => window.FOO = 'foo');
await frame2.evaluate(() => window.FOO = 'bar');
expect(await frame1.evaluate(() => window.FOO)).toBe('foo');
expect(await frame2.evaluate(() => window.FOO)).toBe('bar');
}));
});
it('Page Events: ConsoleMessage', SX(async function() {
let msgs = [];
page.on('consolemessage', msg => msgs.push(msg));