Boot the harness page and wait until the worker is ready to receive eval calls.
(manifest: &Manifest)
| 53 | impl Session { |
| 54 | /// Boot the harness page and wait until the worker is ready to receive eval calls. |
| 55 | pub fn open(manifest: &Manifest) -> Result<Self> { |
| 56 | let packages = serde_json::to_string(manifest)?; |
| 57 | let port = serve(packages)?; |
| 58 | let url = format!("http://127.0.0.1:{port}/"); |
| 59 | |
| 60 | // One spinner covers the whole bring-up: Chromium spawn + page load + worker boot. |
| 61 | let _sp = crate::ui::spinner("starting chromium"); |
| 62 | let browser = launch().context("launching headless Chromium")?; |
| 63 | let tab = browser.new_tab().map_err(|e| anyhow!("opening a tab: {e}"))?; |
| 64 | tab.navigate_to(&url).map_err(|e| anyhow!("navigating to the harness: {e}"))?; |
| 65 | tab.wait_until_navigated().map_err(|e| anyhow!("waiting for page load: {e}"))?; |
| 66 | wait_ready(&tab)?; |
| 67 | Ok(Self { _browser: browser, tab, history: String::new(), history_lines: 0 }) |
| 68 | } |
| 69 | |
| 70 | /// Recompile prior history with `src` so imports and defs persist; only new lines reach `on_line`. |
| 71 | pub fn eval<F: FnMut(&str)>(&mut self, src: &str, mut on_line: F) -> Result<Outcome> { |
no test coverage detected