mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
fix(webkit): make frames detect their initial load state (#690)
This commit is contained in:
parent
19da86b4c9
commit
324874962c
@ -10,7 +10,7 @@
|
|||||||
"playwright": {
|
"playwright": {
|
||||||
"chromium_revision": "733125",
|
"chromium_revision": "733125",
|
||||||
"firefox_revision": "1018",
|
"firefox_revision": "1018",
|
||||||
"webkit_revision": "1113"
|
"webkit_revision": "1119"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"unit": "node test/test.js",
|
"unit": "node test/test.js",
|
||||||
|
@ -235,17 +235,27 @@ export class WKPage implements PageDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _handleFrameTree(frameTree: Protocol.Page.FrameResourceTree) {
|
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);
|
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)
|
if (!frameTree.childFrames)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (const child of frameTree.childFrames)
|
for (const child of frameTree.childFrames)
|
||||||
this._handleFrameTree(child);
|
this._handleFrameTree(child);
|
||||||
}
|
}
|
||||||
|
|
||||||
_onFrameAttached(frameId: string, parentFrameId: string | null) {
|
_onFrameAttached(frameId: string, parentFrameId: string | null): frames.Frame {
|
||||||
this._page._frameManager.frameAttached(frameId, parentFrameId);
|
return this._page._frameManager.frameAttached(frameId, parentFrameId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private _onFrameNavigated(framePayload: Protocol.Page.Frame, initial: boolean) {
|
private _onFrameNavigated(framePayload: Protocol.Page.Frame, initial: boolean) {
|
||||||
|
@ -759,15 +759,21 @@ module.exports.describe = function({testRunner, expect, playwright, FFOX, CHROMI
|
|||||||
response.end('Not found');
|
response.end('Not found');
|
||||||
await navigationPromise;
|
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.goto(server.EMPTY_PAGE);
|
||||||
await page.evaluate(async () => {
|
await page.evaluate(async () => {
|
||||||
const child = window.open(document.location.href);
|
const child = window.open(document.location.href);
|
||||||
while(child.document.readyState !== 'complete' || child.document.location.href === 'about:blank')
|
while (child.document.readyState !== 'complete' || child.document.location.href === 'about:blank')
|
||||||
await new Promise(setTimeout);
|
await new Promise(f => setTimeout(f, 100));
|
||||||
});
|
});
|
||||||
const [, childPage] = await context.pages();
|
const pages = await context.pages();
|
||||||
await childPage.waitForLoadState();
|
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);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user