summaryrefslogtreecommitdiff
path: root/runtime/worker.rs
diff options
context:
space:
mode:
authorFenix <zhuzhenfeng1993@hotmail.com>2022-12-19 04:34:33 +0800
committerGitHub <noreply@github.com>2022-12-18 21:34:33 +0100
commit97f280eb9b28f1b7743eb73cea817f3a5d122b83 (patch)
tree0f4b543244c361508cde636a73f454c52363f9c2 /runtime/worker.rs
parent7b212bc5741ea0cfb6bd87c280be0c864cb32813 (diff)
refactor(runtime): "Worker::execute_script" returns value (#17092)
This commit changes "Worker::execute_script" to return a global handle to "v8::Value".
Diffstat (limited to 'runtime/worker.rs')
-rw-r--r--runtime/worker.rs12
1 files changed, 7 insertions, 5 deletions
diff --git a/runtime/worker.rs b/runtime/worker.rs
index b184ac3fa..41da8588b 100644
--- a/runtime/worker.rs
+++ b/runtime/worker.rs
@@ -13,6 +13,7 @@ use deno_core::error::AnyError;
use deno_core::error::JsError;
use deno_core::futures::Future;
use deno_core::located_script_name;
+use deno_core::v8;
use deno_core::CompiledWasmModuleStore;
use deno_core::Extension;
use deno_core::FsModuleLoader;
@@ -288,9 +289,8 @@ impl MainWorker {
&mut self,
script_name: &str,
source_code: &str,
- ) -> Result<(), AnyError> {
- self.js_runtime.execute_script(script_name, source_code)?;
- Ok(())
+ ) -> Result<v8::Global<v8::Value>, AnyError> {
+ self.js_runtime.execute_script(script_name, source_code)
}
/// Loads and instantiates specified JavaScript module as "main" module.
@@ -431,7 +431,8 @@ impl MainWorker {
// it. Instead we're using global `dispatchEvent` function which will
// used a saved reference to global scope.
"dispatchEvent(new Event('load'))",
- )
+ )?;
+ Ok(())
}
/// Dispatches "unload" event to the JavaScript runtime.
@@ -447,7 +448,8 @@ impl MainWorker {
// it. Instead we're using global `dispatchEvent` function which will
// used a saved reference to global scope.
"dispatchEvent(new Event('unload'))",
- )
+ )?;
+ Ok(())
}
/// Dispatches "beforeunload" event to the JavaScript runtime. Returns a boolean