mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
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.
This commit is contained in:
parent
99e832a345
commit
d1715918f0
10 changed files with 204 additions and 71 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue