diff options
Diffstat (limited to 'runtime/web_worker.rs')
-rw-r--r-- | runtime/web_worker.rs | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/runtime/web_worker.rs b/runtime/web_worker.rs index 8bd5cf21e..4be40c9b0 100644 --- a/runtime/web_worker.rs +++ b/runtime/web_worker.rs @@ -9,6 +9,7 @@ use crate::BootstrapOptions; use deno_broadcast_channel::InMemoryBroadcastChannel; use deno_cache::CreateCache; use deno_cache::SqliteBackedCache; +use deno_core::ascii_str; use deno_core::error::AnyError; use deno_core::error::JsError; use deno_core::futures::channel::mpsc; @@ -572,11 +573,13 @@ impl WebWorker { // TODO(bartlomieju): this could be done using V8 API, without calling `execute_script`. // Save a reference to function that will start polling for messages // from a worker host; it will be called after the user code is loaded. - let script = r#" + let script = ascii_str!( + r#" const pollForMessages = globalThis.pollForMessages; delete globalThis.pollForMessages; pollForMessages - "#; + "# + ); let poll_for_messages_fn = self .js_runtime .execute_script(located_script_name!(), script) @@ -585,10 +588,10 @@ impl WebWorker { } /// See [JsRuntime::execute_script](deno_core::JsRuntime::execute_script) - pub fn execute_script<S: Into<ModuleCode>>( + pub fn execute_script( &mut self, name: &'static str, - source_code: S, + source_code: ModuleCode, ) -> Result<(), AnyError> { self.js_runtime.execute_script(name, source_code)?; Ok(()) @@ -777,7 +780,7 @@ pub fn run_web_worker( // Execute provided source code immediately let result = if let Some(source_code) = maybe_source_code.take() { - let r = worker.execute_script(located_script_name!(), source_code); + let r = worker.execute_script(located_script_name!(), source_code.into()); worker.start_polling_for_messages(); r } else { |