aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/userscripts.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/dom/userscripts.rs')
-rw-r--r--components/script/dom/userscripts.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/components/script/dom/userscripts.rs b/components/script/dom/userscripts.rs
index a004e0fe6b8..047b3345b0c 100644
--- a/components/script/dom/userscripts.rs
+++ b/components/script/dom/userscripts.rs
@@ -4,14 +4,17 @@
use crate::dom::bindings::inheritance::Castable;
use crate::dom::bindings::refcounted::Trusted;
+use crate::dom::bindings::str::DOMString;
use crate::dom::globalscope::GlobalScope;
use crate::dom::htmlheadelement::HTMLHeadElement;
+use crate::dom::htmlscriptelement::SourceCode;
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;
use std::path::PathBuf;
+use std::rc::Rc;
pub fn load_script(head: &HTMLHeadElement) {
let doc = document_from_node(head);
@@ -38,7 +41,9 @@ pub fn load_script(head: &HTMLHeadElement) {
let mut f = File::open(&file).unwrap();
let mut contents = vec![];
f.read_to_end(&mut contents).unwrap();
- let script_text = String::from_utf8_lossy(&contents);
+ let script_text = SourceCode::Text(
+ Rc::new(DOMString::from_string(String::from_utf8_lossy(&contents).to_string()))
+ );
let global = win.upcast::<GlobalScope>();
global.evaluate_script_on_global_with_result(
&script_text,