Skip to content

Commit

Permalink
fix(webkit): initialize popups on start (#693)
Browse files Browse the repository at this point in the history
  • Loading branch information
yury-s authored and aslushnikov committed Jan 28, 2020
1 parent a64fc0e commit 2ddc987
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
9 changes: 7 additions & 2 deletions src/webkit/wkPageProxy.ts
Expand Up @@ -144,8 +144,13 @@ export class WKPageProxy {
(session as any)[isPovisionalSymbol] = true;
if (targetInfo.isProvisional && this._wkPage)
this._wkPage.onProvisionalLoadStarted(session);
if (targetInfo.isPaused)
this._pageProxySession.send('Target.resume', { targetId: targetInfo.targetId }).catch(debugError);
if (targetInfo.isPaused) {
const resume = () => this._pageProxySession.send('Target.resume', { targetId: targetInfo.targetId }).catch(debugError);
if (targetInfo.isProvisional || !this._pagePromise)
resume();
else
this._pagePromise.then(resume);
}
}

private _onTargetDestroyed(event: Protocol.Target.targetDestroyedPayload) {
Expand Down
6 changes: 3 additions & 3 deletions test/page.spec.js
Expand Up @@ -154,7 +154,7 @@ module.exports.describe = function({testRunner, expect, headless, playwright, FF
await page.goto(server.EMPTY_PAGE);
await page.setContent('<a target=_blank rel=noopener href="/one-style.html">yo</a>');
const [popup] = await Promise.all([
page.waitForEvent('popup'),
page.waitForEvent('popup').then(async popup => { await popup.waitForLoadState(); return popup; }),
page.$eval('a', a => a.click()),
]);
expect(await page.evaluate(() => !!window.opener)).toBe(false);
Expand All @@ -166,13 +166,13 @@ module.exports.describe = function({testRunner, expect, headless, playwright, FF
await page.goto(server.EMPTY_PAGE);
await page.setContent('<a target=_blank rel=noopener href="/one-style.html">yo</a>');
const [popup] = await Promise.all([
new Promise(x => page.once('popup', x)),
page.waitForEvent('popup').then(async popup => { await popup.waitForLoadState(); return popup; }),
page.click('a'),
]);
expect(await page.evaluate(() => !!window.opener)).toBe(false);
expect(await popup.evaluate(() => !!window.opener)).toBe(false);
});
it.skip(WEBKIT || FFOX)('should not treat navigations as new popups', async({page, server}) => {
it.skip(FFOX)('should not treat navigations as new popups', async({page, server}) => {
await page.goto(server.EMPTY_PAGE);
await page.setContent('<a target=_blank rel=noopener href="/one-style.html">yo</a>');
const [popup] = await Promise.all([
Expand Down

0 comments on commit 2ddc987

Please sign in to comment.