-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
api(popup): introduce BrowserContext.exposeFunction #1176
Conversation
docs/api.md
Outdated
- `playwrightFunction` <[function]> Callback function which will be called in Playwright's context. | ||
- returns: <[Promise]> | ||
|
||
The method adds a function called `name` on the `window` object of every page in the context. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mention iframes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
docs/api.md
Outdated
); | ||
const page = await context.newPage(); | ||
page.on('console', msg => console.log(msg.text())); | ||
await page.evaluate(async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice if md5 was used in a page context snippet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
src/page.ts
Outdated
@@ -598,3 +556,67 @@ export class Worker extends platform.EventEmitter { | |||
return (await this._executionContextPromise).evaluateHandle(pageFunction, ...args as any); | |||
} | |||
} | |||
|
|||
export class PageBindng { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Binding
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
test/evaluation.spec.js
Outdated
@@ -274,7 +274,15 @@ module.exports.describe = function({testRunner, expect, FFOX, CHROMIUM, WEBKIT}) | |||
await page.evaluate(() => { window.JSON.stringify = null; window.JSON = null; }); | |||
const result = await page.evaluate(() => ({abc: 123})); | |||
expect(result).toEqual({abc: 123}); | |||
}) | |||
}); | |||
it.skip(WEBKIT)('should await promise from popup', async function({page, server}) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it.fail
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
test/page.spec.js
Outdated
@@ -385,6 +385,31 @@ module.exports.describe = function({testRunner, expect, headless, playwright, FF | |||
}); | |||
expect(result).toBe(36); | |||
}); | |||
it.skip(CHROMIUM || FFOX)('should work with browser context', async({browser, server}) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move this to browsercontext.spec.js
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All done.
docs/api.md
Outdated
- `playwrightFunction` <[function]> Callback function which will be called in Playwright's context. | ||
- returns: <[Promise]> | ||
|
||
The method adds a function called `name` on the `window` object of every page in the context. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
docs/api.md
Outdated
); | ||
const page = await context.newPage(); | ||
page.on('console', msg => console.log(msg.text())); | ||
await page.evaluate(async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
src/page.ts
Outdated
@@ -598,3 +556,67 @@ export class Worker extends platform.EventEmitter { | |||
return (await this._executionContextPromise).evaluateHandle(pageFunction, ...args as any); | |||
} | |||
} | |||
|
|||
export class PageBindng { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
test/evaluation.spec.js
Outdated
@@ -274,7 +274,15 @@ module.exports.describe = function({testRunner, expect, FFOX, CHROMIUM, WEBKIT}) | |||
await page.evaluate(() => { window.JSON.stringify = null; window.JSON = null; }); | |||
const result = await page.evaluate(() => ({abc: 123})); | |||
expect(result).toEqual({abc: 123}); | |||
}) | |||
}); | |||
it.skip(WEBKIT)('should await promise from popup', async function({page, server}) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
test/page.spec.js
Outdated
@@ -385,6 +385,31 @@ module.exports.describe = function({testRunner, expect, headless, playwright, FF | |||
}); | |||
expect(result).toBe(36); | |||
}); | |||
it.skip(CHROMIUM || FFOX)('should work with browser context', async({browser, server}) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
No description provided.