mirror of
https://github.com/microsoft/playwright.git
synced 2025-01-05 19:04:43 +03:00
fix(chromium): install binding function during initialization (#1320)
This commit is contained in:
parent
65d10a5d5d
commit
3dd49459bb
@ -92,11 +92,16 @@ export class CRPage implements PageDelegate {
|
||||
helper.addEventListener(this._client, 'Target.attachedToTarget', event => this._onAttachedToTarget(event)),
|
||||
helper.addEventListener(this._client, 'Target.detachedFromTarget', event => this._onDetachedFromTarget(event)),
|
||||
];
|
||||
this._page.frames().map(frame => this._client.send('Page.createIsolatedWorld', {
|
||||
frameId: frame._id,
|
||||
grantUniveralAccess: true,
|
||||
worldName: UTILITY_WORLD_NAME,
|
||||
}).catch(debugError)); // frames might be removed before we send this.
|
||||
for (const frame of this._page.frames()) {
|
||||
// Note: frames might be removed before we send these.
|
||||
this._client.send('Page.createIsolatedWorld', {
|
||||
frameId: frame._id,
|
||||
grantUniveralAccess: true,
|
||||
worldName: UTILITY_WORLD_NAME,
|
||||
}).catch(debugError);
|
||||
for (const binding of this._browserContext._pageBindings.values())
|
||||
frame.evaluate(binding.source).catch(debugError);
|
||||
}
|
||||
}),
|
||||
this._client.send('Log.enable', {}),
|
||||
this._client.send('Page.setLifecycleEventsEnabled', { enabled: true }),
|
||||
|
@ -612,6 +612,8 @@ export class PageBinding {
|
||||
|
||||
function addPageBinding(bindingName: string) {
|
||||
const binding = (window as any)[bindingName];
|
||||
if (binding.__installed)
|
||||
return;
|
||||
(window as any)[bindingName] = (...args: any[]) => {
|
||||
const me = (window as any)[bindingName];
|
||||
let callbacks = me['callbacks'];
|
||||
@ -625,4 +627,5 @@ function addPageBinding(bindingName: string) {
|
||||
binding(JSON.stringify({name: bindingName, seq, args}));
|
||||
return promise;
|
||||
};
|
||||
(window as any)[bindingName].__installed = true;
|
||||
}
|
||||
|
@ -326,7 +326,7 @@ module.exports.describe = function({testRunner, expect, playwright, CHROMIUM, FF
|
||||
});
|
||||
|
||||
describe('BrowserContext.exposeFunction', () => {
|
||||
it.fail(CHROMIUM || FFOX)('should work', async({browser, server}) => {
|
||||
it.fail(FFOX)('should work', async({browser, server}) => {
|
||||
const context = await browser.newContext();
|
||||
await context.exposeFunction('add', (a, b) => a + b);
|
||||
const page = await context.newPage();
|
||||
|
Loading…
Reference in New Issue
Block a user