({sessionId, targetInfo, waitingForDebugger})
| 427 | } |
| 428 | |
| 429 | async function installForSession({sessionId, targetInfo, waitingForDebugger}) { |
| 430 | if ( waitingForDebugger ) { |
| 431 | console.warn(targetInfo); |
| 432 | throw new TypeError(`Target not ready for install`); |
| 433 | } |
| 434 | if ( ! sessionId ) { |
| 435 | throw new TypeError(`installForSession needs a sessionId`); |
| 436 | } |
| 437 | |
| 438 | const {targetId, url} = targetInfo; |
| 439 | |
| 440 | const installUneeded = dontInstall(targetInfo) || |
| 441 | State.Installations.has(sessionId) |
| 442 | ; |
| 443 | |
| 444 | if ( installUneeded ) return; |
| 445 | |
| 446 | DEBUG.verboseSlow && console.log("installForSession running on target " + targetId); |
| 447 | |
| 448 | State.Sessions.set(targetId, sessionId); |
| 449 | Targets.set(sessionId, clone(targetInfo)); |
| 450 | |
| 451 | if ( Mode == 'save' || Mode == 'select' ) { |
| 452 | send("Network.setCacheDisabled", {cacheDisabled:true}, sessionId); |
| 453 | send("Network.setBypassServiceWorker", {bypass:true}, sessionId); |
| 454 | |
| 455 | await send("Runtime.enable", {}, sessionId); |
| 456 | await send("Page.enable", {}, sessionId); |
| 457 | await send("Page.setAdBlockingEnabled", {enabled: true}, sessionId); |
| 458 | await send("DOMSnapshot.enable", {}, sessionId); |
| 459 | |
| 460 | on("Page.frameNavigated", updateFrameNode); |
| 461 | on("Page.frameAttached", addFrameNode); |
| 462 | // on("Page.frameDetached", updateFrameNodes); // necessary? maybe not |
| 463 | |
| 464 | await send("Page.addScriptToEvaluateOnNewDocument", { |
| 465 | source: getInjection({sessionId}), |
| 466 | worldName: "Context-22120-Indexing", |
| 467 | runImmediately: true |
| 468 | }, sessionId); |
| 469 | |
| 470 | DEBUG.verboseSlow && console.log("Just request install", targetId, url); |
| 471 | } |
| 472 | |
| 473 | State.Installations.add(sessionId); |
| 474 | |
| 475 | DEBUG.verboseSlow && console.log('Installed sessionId', sessionId); |
| 476 | if ( Mode == 'save' ) { |
| 477 | indexURL({targetInfo}); |
| 478 | } |
| 479 | } |
| 480 | |
| 481 | async function indexURL({targetInfo:info = {}, sessionId, waitingForDebugger} = {}) { |
| 482 | if ( waitingForDebugger ) { |
nothing calls this directly
no test coverage detected