mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
fix: retain stale main frame for longer (#12225)
This commit is contained in:
parent
2821970485
commit
aa5b1824a5
@ -21,6 +21,7 @@ export class FrameTree<FrameType extends Frame> {
|
|||||||
// frameID -> childFrameIDs
|
// frameID -> childFrameIDs
|
||||||
#childIds = new Map<string, Set<string>>();
|
#childIds = new Map<string, Set<string>>();
|
||||||
#mainFrame?: FrameType;
|
#mainFrame?: FrameType;
|
||||||
|
#isMainFrameStale = false;
|
||||||
#waitRequests = new Map<string, Set<Deferred<FrameType>>>();
|
#waitRequests = new Map<string, Set<Deferred<FrameType>>>();
|
||||||
|
|
||||||
getMainFrame(): FrameType | undefined {
|
getMainFrame(): FrameType | undefined {
|
||||||
@ -59,8 +60,9 @@ export class FrameTree<FrameType extends Frame> {
|
|||||||
this.#childIds.set(frame._parentId, new Set());
|
this.#childIds.set(frame._parentId, new Set());
|
||||||
}
|
}
|
||||||
this.#childIds.get(frame._parentId)!.add(frame._id);
|
this.#childIds.get(frame._parentId)!.add(frame._id);
|
||||||
} else if (!this.#mainFrame) {
|
} else if (!this.#mainFrame || this.#isMainFrameStale) {
|
||||||
this.#mainFrame = frame;
|
this.#mainFrame = frame;
|
||||||
|
this.#isMainFrameStale = false;
|
||||||
}
|
}
|
||||||
this.#waitRequests.get(frame._id)?.forEach(request => {
|
this.#waitRequests.get(frame._id)?.forEach(request => {
|
||||||
return request.resolve(frame);
|
return request.resolve(frame);
|
||||||
@ -73,7 +75,7 @@ export class FrameTree<FrameType extends Frame> {
|
|||||||
if (frame._parentId) {
|
if (frame._parentId) {
|
||||||
this.#childIds.get(frame._parentId)?.delete(frame._id);
|
this.#childIds.get(frame._parentId)?.delete(frame._id);
|
||||||
} else {
|
} else {
|
||||||
this.#mainFrame = undefined;
|
this.#isMainFrameStale = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user