From ea89f050cdb3a2fd9de1b008c3a0f6c7ef8ba9f8 Mon Sep 17 00:00:00 2001 From: Marc Bachmann Date: Fri, 29 May 2026 20:20:46 +0200 Subject: [PATCH] Fix puppeteer `exposeFunction` end-to-end: real bindings, preload timing, URL coercion (#166) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(js): coerce URL constructor input/base to string The polyfill at bootstrap.js called `base.match(...)` directly, which threw `TypeError: base.match is not a function` whenever callers passed a Location object (e.g. `new URL(href, window.location)`), a URL instance, or any other non-string with a sensible toString. Per the WHATWG URL Standard both `url` and `base` are stringified before parsing. Coerce explicitly so the existing regex paths keep working and the constructor matches real-browser behaviour. AngularJS, jQuery, and anything that resolves a relative URL against `window.location` now loads under Obscura. * fix(browser,cdp): run preload scripts before page scripts `Page.addScriptToEvaluateOnNewDocument` was executed AFTER the page's own scripts (and even after the load event), which silently broke every CDP contract that depends on early injection — most visibly puppeteer's `page.exposeFunction`, whose user-facing wrapper has to override `globalThis[name]` before any `