aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/userscripts.rs
diff options
context:
space:
mode:
authorCYBAI <cyb.ai.815@gmail.com>2020-07-11 22:44:21 +0900
committerCYBAI <cyb.ai.815@gmail.com>2020-07-18 00:43:34 +0900
commitd1715918f058649b3a637a53c2cd920740b2eb37 (patch)
tree6f5754a503b246a0a96b2efe8bcab5e33b95a51b /components/script/dom/userscripts.rs
parent99e832a345ae09cdf78b72fb4e37e64194e4cf42 (diff)
downloadservo-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/dom/userscripts.rs')
-rw-r--r--components/script/dom/userscripts.rs17
1 files changed, 10 insertions, 7 deletions
diff --git a/components/script/dom/userscripts.rs b/components/script/dom/userscripts.rs
index 4e9cc59d27f..a004e0fe6b8 100644
--- a/components/script/dom/userscripts.rs
+++ b/components/script/dom/userscripts.rs
@@ -7,6 +7,7 @@ use crate::dom::bindings::refcounted::Trusted;
use crate::dom::globalscope::GlobalScope;
use crate::dom::htmlheadelement::HTMLHeadElement;
use crate::dom::node::document_from_node;
+use crate::script_module::ScriptFetchOptions;
use js::jsval::UndefinedValue;
use std::fs::{read_dir, File};
use std::io::Read;
@@ -38,13 +39,15 @@ pub fn load_script(head: &HTMLHeadElement) {
let mut contents = vec![];
f.read_to_end(&mut contents).unwrap();
let script_text = String::from_utf8_lossy(&contents);
- win.upcast::<GlobalScope>()
- .evaluate_script_on_global_with_result(
- &script_text,
- &file.to_string_lossy(),
- rval.handle_mut(),
- 1,
- );
+ let global = win.upcast::<GlobalScope>();
+ global.evaluate_script_on_global_with_result(
+ &script_text,
+ &file.to_string_lossy(),
+ rval.handle_mut(),
+ 1,
+ ScriptFetchOptions::default_classic_script(&global),
+ global.api_base_url(),
+ );
}
}));
}