mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
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:
committed by
Andrey Lushnikov
parent
8c9332b62e
commit
3cb0f1af34
24
test/test.js
24
test/test.js
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user