aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/userscripts.rs
diff options
context:
space:
mode:
authorAbhishekSharma102 <20724848+AbhishekSharma102@users.noreply.github.com>2020-07-13 06:04:00 +0000
committerJosh Matthews <josh@joshmatthews.net>2020-07-21 16:20:51 -0400
commit1119dd119ed335b6d6e448290b56e0eeab6de25f (patch)
treec1d2ae2b369a20923cfe8e24496193896c4ad473 /components/script/dom/userscripts.rs
parentbfb7bea704340e19583b04fb02b444fadd35e9e1 (diff)
downloadservo-1119dd119ed335b6d6e448290b56e0eeab6de25f.tar.gz
servo-1119dd119ed335b6d6e448290b56e0eeab6de25f.zip
Added off thread compilation
Co-authored-by: Gregory Terzian <2792687+gterzian@users.noreply.github.com> Co-authored-by: Abhishek Sharma <20724848+AbhishekSharma102@users.noreply.github.com>
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,