fix: make exposeFunction work for frames (#1295)

This patch fixes page.exposeFunction method so that it
adds exposed binding to all existing frames.

Fixes #690
This commit is contained in:
JoelEinbinder
2017-11-07 13:26:23 -08:00
committed by Andrey Lushnikov
parent 8c9332b62e
commit 3cb0f1af34
2 changed files with 27 additions and 3 deletions

View File

@@ -1188,6 +1188,30 @@ describe('Page', function() {
});
expect(result).toBe(15);
}));
it('should work on frames', SX(async function() {
await page.exposeFunction('compute', function(a, b) {
return Promise.resolve(a * b);
});
await page.goto(PREFIX + '/frames/nested-frames.html');
const frame = page.frames()[1];
const result = await frame.evaluate(async function() {
return await compute(3, 5);
});
expect(result).toBe(15);
}));
it('should work on frames before navigation', SX(async function() {
await page.goto(PREFIX + '/frames/nested-frames.html');
await page.exposeFunction('compute', function(a, b) {
return Promise.resolve(a * b);
});
const frame = page.frames()[1];
const result = await frame.evaluate(async function() {
return await compute(3, 5);
});
expect(result).toBe(15);
}));
});
describe('Page.setRequestInterception', function() {