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:
CYBAI 2020-07-11 22:44:21 +09:00
parent 99e832a345
commit d1715918f0
10 changed files with 204 additions and 71 deletions

View file

@ -12,6 +12,7 @@ use crate::dom::eventsource::EventSourceTimeoutCallback;
use crate::dom::globalscope::GlobalScope;
use crate::dom::testbinding::TestBindingCallback;
use crate::dom::xmlhttprequest::XHRTimeoutCallback;
use crate::script_module::ScriptFetchOptions;
use crate::script_thread::ScriptThread;
use euclid::Length;
use ipc_channel::ipc::IpcSender;
@ -541,7 +542,13 @@ impl JsTimerTask {
let global = this.global();
let cx = global.get_cx();
rooted!(in(*cx) let mut rval = UndefinedValue());
global.evaluate_js_on_global_with_result(code_str, rval.handle_mut());
// FIXME(cybai): Use base url properly by saving private reference for timers (#27260)
global.evaluate_js_on_global_with_result(
code_str,
rval.handle_mut(),
ScriptFetchOptions::default_classic_script(&global),
global.api_base_url(),
);
},
InternalTimerCallback::FunctionTimerCallback(ref function, ref arguments) => {
let arguments = self.collect_heap_args(arguments);