MCPcopy
hub / github.com/garrytan/gstack / setTabContent

Method setTabContent

browse/src/tab-session.ts:189–197  ·  view source on GitHub ↗

* Load HTML content into the tab AND store it for replay after context recreation * (e.g. viewport --scale). Unlike page.setContent() alone, this rehydrates * TabSession.loadedHtml so the next saveState()/restoreState() round-trip preserves * the content.

(html: string, opts: { waitUntil?: SetContentWaitUntil } = {})

Source from the content-addressed store, hash-verified

187 * the content.
188 */
189 async setTabContent(html: string, opts: { waitUntil?: SetContentWaitUntil } = {}): Promise<void> {
190 const waitUntil = opts.waitUntil ?? 'domcontentloaded';
191 // Call setContent FIRST — only record the replay metadata after a successful load.
192 // If setContent throws (timeout, crash), we must not leave phantom HTML that a
193 // later viewport --scale would replay.
194 await this.page.setContent(html, { waitUntil, timeout: 15000 });
195 this.loadedHtml = html;
196 this.loadedHtmlWaitUntil = waitUntil;
197 }
198
199 /** Get stored HTML + waitUntil for state replay. Returns null if no load-html happened. */
200 getLoadedHtml(): { html: string; waitUntil?: SetContentWaitUntil } | null {

Callers 2

restoreStateMethod · 0.95
handleWriteCommandFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected