diff --git a/src/webkit/wkPageProxy.ts b/src/webkit/wkPageProxy.ts
index c1cda05b96..37dd5d410d 100644
--- a/src/webkit/wkPageProxy.ts
+++ b/src/webkit/wkPageProxy.ts
@@ -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) {
diff --git a/test/page.spec.js b/test/page.spec.js
index f5597bdb19..b6b515c2e7 100644
--- a/test/page.spec.js
+++ b/test/page.spec.js
@@ -154,7 +154,7 @@ module.exports.describe = function({testRunner, expect, headless, playwright, FF
await page.goto(server.EMPTY_PAGE);
await page.setContent('yo');
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);
@@ -166,13 +166,13 @@ module.exports.describe = function({testRunner, expect, headless, playwright, FF
await page.goto(server.EMPTY_PAGE);
await page.setContent('yo');
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('yo');
const [popup] = await Promise.all([