mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
fix: consider existing frames when waiting for a frame (#8200)
This commit is contained in:
parent
bdc9671465
commit
0955225b51
@ -2039,7 +2039,7 @@ export class Page extends EventEmitter {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Promise.race([
|
const eventRace = Promise.race([
|
||||||
helper.waitForEvent(
|
helper.waitForEvent(
|
||||||
this._frameManager,
|
this._frameManager,
|
||||||
FrameManagerEmittedEvents.FrameAttached,
|
FrameManagerEmittedEvents.FrameAttached,
|
||||||
@ -2055,6 +2055,18 @@ export class Page extends EventEmitter {
|
|||||||
this._sessionClosePromise()
|
this._sessionClosePromise()
|
||||||
),
|
),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
return Promise.race([
|
||||||
|
eventRace,
|
||||||
|
(async () => {
|
||||||
|
for (const frame of this.frames()) {
|
||||||
|
if (await predicate(frame)) {
|
||||||
|
return frame;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await eventRace;
|
||||||
|
})(),
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -371,6 +371,21 @@ describeChromeOnly('OOPIF', function () {
|
|||||||
await target.page();
|
await target.page();
|
||||||
browser1.disconnect();
|
browser1.disconnect();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('waitForFrame', () => {
|
||||||
|
it('should resolve immediately if the frame already exists', async () => {
|
||||||
|
const { server } = getTestState();
|
||||||
|
|
||||||
|
await page.goto(server.EMPTY_PAGE);
|
||||||
|
await utils.attachFrame(
|
||||||
|
page,
|
||||||
|
'frame2',
|
||||||
|
server.CROSS_PROCESS_PREFIX + '/empty.html'
|
||||||
|
);
|
||||||
|
|
||||||
|
await page.waitForFrame((frame) => frame.url().endsWith('/empty.html'));
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user