aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCYBAI <cyb.ai.815@gmail.com>2020-07-19 16:24:24 +0900
committerCYBAI <cyb.ai.815@gmail.com>2020-07-19 16:24:24 +0900
commit419cd53561e4abaadc78b2cfea55e0bf0edfb36c (patch)
tree85ffa96bf834dacffc5b654d5910c0de0b9d9e11
parent08723b0e37a83c705810a17f8923882689171345 (diff)
downloadservo-419cd53561e4abaadc78b2cfea55e0bf0edfb36c.tar.gz
servo-419cd53561e4abaadc78b2cfea55e0bf0edfb36c.zip
Use JS_GetScriptPrivate to get a mutated return value
Because MSVC uses a different calling conventions for functions that return non-POD values, we need to use the new exposed wrapper function so that `GetScriptPrivate` can be handled correctly on Windows.
-rw-r--r--Cargo.lock2
-rw-r--r--components/script/dom/globalscope.rs9
2 files changed, 7 insertions, 4 deletions
diff --git a/Cargo.lock b/Cargo.lock
index a9eed9e4f66..62b67c207fb 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -3572,7 +3572,7 @@ dependencies = [
[[package]]
name = "mozjs"
version = "0.13.0"
-source = "git+https://github.com/servo/rust-mozjs#0caf5549cddbb34ad16abf35fb6bfbff824a4d14"
+source = "git+https://github.com/servo/rust-mozjs#716dede8811ed525d9aab1e44cea392609b35d0a"
dependencies = [
"cc",
"lazy_static",
diff --git a/components/script/dom/globalscope.rs b/components/script/dom/globalscope.rs
index 2ee5de75c7c..d20f9084fcc 100644
--- a/components/script/dom/globalscope.rs
+++ b/components/script/dom/globalscope.rs
@@ -79,15 +79,15 @@ use ipc_channel::ipc::{self, IpcSender};
use ipc_channel::router::ROUTER;
use js::glue::{IsWrapper, UnwrapObjectDynamic};
use js::jsapi::Compile1;
+use js::jsapi::SetScriptPrivate;
use js::jsapi::{CurrentGlobalOrNull, GetNonCCWObjectGlobal};
-use js::jsapi::{GetScriptPrivate, SetScriptPrivate};
use js::jsapi::{HandleObject, Heap};
use js::jsapi::{JSContext, JSObject};
use js::jsval::PrivateValue;
use js::jsval::{JSVal, UndefinedValue};
use js::panic::maybe_resume_unwind;
use js::rust::transform_str_to_source_text;
-use js::rust::wrappers::JS_ExecuteScript;
+use js::rust::wrappers::{JS_ExecuteScript, JS_GetScriptPrivate};
use js::rust::{get_object_class, CompileOptionsWrapper, ParentRuntime, Runtime};
use js::rust::{HandleValue, MutableHandleValue};
use js::{JSCLASS_IS_DOMJSCLASS, JSCLASS_IS_GLOBAL};
@@ -2603,9 +2603,12 @@ impl GlobalScope {
return false;
}
+ rooted!(in(*cx) let mut script_private = UndefinedValue());
+ JS_GetScriptPrivate(*compiled_script, script_private.handle_mut());
+
// When `ScriptPrivate` for the compiled script is undefined,
// we need to set it so that it can be used in dynamic import context.
- if GetScriptPrivate(*compiled_script).is_undefined() {
+ if script_private.is_undefined() {
debug!("Set script private for {}", script_base_url);
let module_script_data = Rc::new(ModuleScript::new(