test: expect current behavior for cross-frame js handles (#833)

This commit is contained in:
Dmitry Gozman 2020-02-04 19:34:54 -08:00 committed by GitHub
parent 6dc88bcb85
commit 4b761f4485
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -352,9 +352,10 @@ module.exports.describe = function({testRunner, expect, FFOX, CHROMIUM, WEBKIT})
await page.goto(server.CROSS_PROCESS_PREFIX + '/empty.html'); await page.goto(server.CROSS_PROCESS_PREFIX + '/empty.html');
expect(await mainFrame.evaluate(() => window.location.href)).toContain('127'); expect(await mainFrame.evaluate(() => window.location.href)).toContain('127');
}); });
xit('should allow cross-frame js handles', async({page, server}) => { it('should not allow cross-frame js handles', async({page, server}) => {
// TODO: this should be possible because frames script each other, but // TODO: this should actually be possible because frames script each other,
// protocol implementations do not support this. // but protocol implementations do not support this. For now, assume current
// behavior.
await page.goto(server.PREFIX + '/frames/one-frame.html'); await page.goto(server.PREFIX + '/frames/one-frame.html');
const handle = await page.evaluateHandle(() => { const handle = await page.evaluateHandle(() => {
const iframe = document.querySelector('iframe'); const iframe = document.querySelector('iframe');
@ -365,8 +366,8 @@ module.exports.describe = function({testRunner, expect, FFOX, CHROMIUM, WEBKIT})
const childFrame = page.mainFrame().childFrames()[0]; const childFrame = page.mainFrame().childFrames()[0];
const childResult = await childFrame.evaluate(() => window.__foo); const childResult = await childFrame.evaluate(() => window.__foo);
expect(childResult).toEqual({ bar: 'baz' }); expect(childResult).toEqual({ bar: 'baz' });
const result = await childFrame.evaluate(foo => foo.bar, handle); const error = await childFrame.evaluate(foo => foo.bar, handle).catch(e => e);
expect(result).toBe('baz'); expect(error.message).toBe('JSHandles can be evaluated only in the context they were created!');
}); });
it('should allow cross-frame element handles', async({page, server}) => { it('should allow cross-frame element handles', async({page, server}) => {
await page.goto(server.PREFIX + '/frames/one-frame.html'); await page.goto(server.PREFIX + '/frames/one-frame.html');