/** * Execution-context selection inside ONE target (issue #12). Backend-neutral and pure: no I/O, * so the grammar and the pick rules are unit-tested without a browser. The CDP half (collecting * contexts off a live connection, settling, evaluating in each) is src/cdp/contexts.ts. * * WHAT IT IS FOR. A target (a tab, an out-of-process iframe, an Electron webview) can hold many * documents that are NOT targets of their own: every same-process iframe is a frame inside its * parent's renderer, with its own JavaScript realm. CDP calls each realm an execution context, * and Runtime.evaluate without a contextId runs in the target's main frame only, so * `document.querySelector` cannot see an input that lives in a nested frame. The `frame:` target * arm (src/frames.ts) does not help: it picks out-of-process iframe TARGETS, and a same-process * frame is not one. This module names a context INSIDE whatever target was already resolved. * * THE `context` VALUE (a tool parameter, not a target-selector suffix, so none of the three target * resolvers, the endpoint prefix or the lease-key parsing change): * | 'id:' the executionContextId from list_contexts (stable across calls for * the context's life, measured on Chromium 158; a navigation makes a new one) * 'frame:' the frame's id, exact (survives nothing either, but reads better) * 'url:' substring of the frame's url, else of the context's origin * 'name:' substring of the frame's name (the