diff --git a/package.json b/package.json index a5ac1ccb584d9..68322a76ff490 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "playwright": { "chromium_revision": "733125", "firefox_revision": "1018", - "webkit_revision": "1113" + "webkit_revision": "1119" }, "scripts": { "unit": "node test/test.js", diff --git a/src/webkit/wkPage.ts b/src/webkit/wkPage.ts index 730ff3301a596..7638df4933002 100644 --- a/src/webkit/wkPage.ts +++ b/src/webkit/wkPage.ts @@ -234,17 +234,27 @@ export class WKPage implements PageDelegate { } private _handleFrameTree(frameTree: Protocol.Page.FrameResourceTree) { - this._onFrameAttached(frameTree.frame.id, frameTree.frame.parentId || null); + const frame = this._onFrameAttached(frameTree.frame.id, frameTree.frame.parentId || null); this._onFrameNavigated(frameTree.frame, true); + + frame._utilityContext().then(async context => { + const readyState = await context.evaluate(() => document.readyState).catch(e => 'loading'); + if (frame.isDetached()) + return; + if (readyState === 'interactive' || readyState === 'complete') + this._page._frameManager.frameLifecycleEvent(frame._id, 'domcontentloaded'); + if (readyState === 'complete') + this._page._frameManager.frameLifecycleEvent(frame._id, 'load'); + }); + if (!frameTree.childFrames) return; - for (const child of frameTree.childFrames) this._handleFrameTree(child); } - _onFrameAttached(frameId: string, parentFrameId: string | null) { - this._page._frameManager.frameAttached(frameId, parentFrameId); + _onFrameAttached(frameId: string, parentFrameId: string | null): frames.Frame { + return this._page._frameManager.frameAttached(frameId, parentFrameId); } private _onFrameNavigated(framePayload: Protocol.Page.Frame, initial: boolean) { diff --git a/test/navigation.spec.js b/test/navigation.spec.js index a02d9ebf11c1f..0213d2b17fa34 100644 --- a/test/navigation.spec.js +++ b/test/navigation.spec.js @@ -759,15 +759,21 @@ module.exports.describe = function({testRunner, expect, playwright, FFOX, CHROMI response.end('Not found'); await navigationPromise; }); - it.skip(WEBKIT || FFOX)('should work with pages that have loaded before being connected to', async({page, context, server}) => { + it.skip(FFOX)('should work with pages that have loaded before being connected to', async({page, context, server}) => { await page.goto(server.EMPTY_PAGE); await page.evaluate(async () => { const child = window.open(document.location.href); - while(child.document.readyState !== 'complete' || child.document.location.href === 'about:blank') - await new Promise(setTimeout); + while (child.document.readyState !== 'complete' || child.document.location.href === 'about:blank') + await new Promise(f => setTimeout(f, 100)); }); - const [, childPage] = await context.pages(); - await childPage.waitForLoadState(); + const pages = await context.pages(); + expect(pages.length).toBe(2); + expect(pages[0]).toBe(page); + expect(pages[0].url()).toBe(server.EMPTY_PAGE); + + expect(pages[1].url()).toBe(server.EMPTY_PAGE); + await pages[1].waitForLoadState(); + expect(pages[1].url()).toBe(server.EMPTY_PAGE); }); }); diff --git a/test/page.spec.js b/test/page.spec.js index 5c0bf4513dfd1..1658c23fbd8e0 100644 --- a/test/page.spec.js +++ b/test/page.spec.js @@ -172,7 +172,7 @@ module.exports.describe = function({testRunner, expect, headless, playwright, FF 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([