browser: split page start from page navigate

This commit is contained in:
Pierre Tachoire
2024-12-19 10:00:49 +01:00
parent 8e2cb36597
commit 2fed239ece
4 changed files with 29 additions and 14 deletions

View File

@@ -344,6 +344,14 @@ fn createTarget(
ctx.state.loaderID = LoaderID;
ctx.state.sessionID = msg.sessionId;
// TODO stop the previous page instead?
if (ctx.browser.session.page != null) return error.pageAlreadyExists;
// create the page
const p = try ctx.browser.session.createPage();
// start the js env
try p.start();
// send targetCreated event
const created = TargetCreated{
.sessionId = cdp.ContextSessionID,
@@ -440,6 +448,8 @@ fn closeTarget(
null,
);
if (ctx.browser.session.page != null) ctx.browser.session.page.?.end();
return "";
}