Skip to main content

register_worker_scope_callback_native

Function register_worker_scope_callback_native 

Source
pub fn register_worker_scope_callback_native(profile: Option<StealthProfile>)
Expand description

Register a servo-native Worker scope callback via the vendor patch servo::register_worker_scope_callback (DEC-WK-001 / TASK-1).

The callback is queued in servo’s global EMBEDDER_WORKER_SCOPE_CALLBACKS vector and drained once per Worker scope creation inside DedicatedWorkerGlobalScope::run_worker_scope — after the Worker’s global is built but before the event loop starts. It runs on the Worker thread (the same thread that owns the Worker’s JSContext), so it is safe to dereference the raw cx/global pointers there (per BCE-20260621-001: DOM↔Node interop must happen on the owning thread).

What the callback does (mirrors worker_scope_init_native for the bypass):

  • Install stealth profile inheritance keyed by the Worker global’s address (DEC-WK-007 / CRIT-STL-WK: Worker navigator/Canvas/WebGL/Audio match parent page).
  • Install DedicatedWorkerGlobalScope Web APIs (fetch/timers/crypto/ performance/etc., criterion #8).

Note: lifecycle natives (self.close/importScripts) are installed by servo upstream’s DedicatedWorkerGlobalScope binding for native Workers, so the bao bypass’s install_worker_lifecycle_natives is NOT needed here — it is only needed for bao_engine::WebWorker (DEC-WK-003 dual-track).

@trace DEC-WK-001 servo-native Worker path (vendor patch) @trace DEC-WK-003 dual-track isolation (bypass not abandoned) @trace REQ-BRW-004 [entity:DedicatedWorkerGlobalScope] [criterion:8,12..17]