diff options
author | CYBAI <cyb.ai.815@gmail.com> | 2020-07-11 22:44:21 +0900 |
---|---|---|
committer | CYBAI <cyb.ai.815@gmail.com> | 2020-07-18 00:43:34 +0900 |
commit | d1715918f058649b3a637a53c2cd920740b2eb37 (patch) | |
tree | 6f5754a503b246a0a96b2efe8bcab5e33b95a51b /components/script/webdriver_handlers.rs | |
parent | 99e832a345ae09cdf78b72fb4e37e64194e4cf42 (diff) | |
download | servo-d1715918f058649b3a637a53c2cd920740b2eb37.tar.gz servo-d1715918f058649b3a637a53c2cd920740b2eb37.zip |
Set private reference for classic script
Web developers can use `Dynamic Import` in a classic script; thus, we
need to save the script's private reference so that we can reuse it when
we're going to fetch a dynamic import module for a classic script.
Besides, because it's possible to use different executing context for a
dynamic import module (like `dynamic-import/string-compilation-other-document.html` WPT test),
we can't initialize a module owner at the timing of `SetScriptPrivate`;
thus, if the private module script doesn't hold an owner, we'll use a
DynamicImport owner for it.
Diffstat (limited to 'components/script/webdriver_handlers.rs')
-rw-r--r-- | components/script/webdriver_handlers.rs | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/components/script/webdriver_handlers.rs b/components/script/webdriver_handlers.rs index 1e094ec086c..1d36337f5eb 100644 --- a/components/script/webdriver_handlers.rs +++ b/components/script/webdriver_handlers.rs @@ -38,6 +38,7 @@ use crate::dom::nodelist::NodeList; use crate::dom::window::Window; use crate::dom::xmlserializer::XMLSerializer; use crate::realms::enter_realm; +use crate::script_module::ScriptFetchOptions; use crate::script_runtime::JSContext as SafeJSContext; use crate::script_thread::{Documents, ScriptThread}; use cookie::Cookie; @@ -297,9 +298,13 @@ pub fn handle_execute_script( let result = unsafe { let cx = window.get_cx(); rooted!(in(*cx) let mut rval = UndefinedValue()); - window - .upcast::<GlobalScope>() - .evaluate_js_on_global_with_result(&eval, rval.handle_mut()); + let global = window.upcast::<GlobalScope>(); + global.evaluate_js_on_global_with_result( + &eval, + rval.handle_mut(), + ScriptFetchOptions::default_classic_script(&global), + global.api_base_url(), + ); jsval_to_webdriver(*cx, &window.upcast::<GlobalScope>(), rval.handle()) }; @@ -323,9 +328,13 @@ pub fn handle_execute_async_script( let cx = window.get_cx(); window.set_webdriver_script_chan(Some(reply)); rooted!(in(*cx) let mut rval = UndefinedValue()); - window - .upcast::<GlobalScope>() - .evaluate_js_on_global_with_result(&eval, rval.handle_mut()); + let global = window.upcast::<GlobalScope>(); + global.evaluate_js_on_global_with_result( + &eval, + rval.handle_mut(), + ScriptFetchOptions::default_classic_script(&global), + global.api_base_url(), + ); }, None => { reply |