aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/htmlscriptelement.rs
diff options
context:
space:
mode:
authorKeith Yeung <kungfukeith11@gmail.com>2016-06-24 14:31:00 +0800
committerKeith Yeung <kungfukeith11@gmail.com>2016-09-21 11:50:51 -0700
commit4c616dad9093b5320ee27629c89c57da038d6705 (patch)
tree28befb00702c955f06f9ee45a52857282c53b6c9 /components/script/dom/htmlscriptelement.rs
parentf566a8d44f4f39b4cd085ce791c113ddf434dd22 (diff)
downloadservo-4c616dad9093b5320ee27629c89c57da038d6705.tar.gz
servo-4c616dad9093b5320ee27629c89c57da038d6705.zip
Add crossorigin attribute and implement step 14 of prepare a script
Add WPT test for HTMLScriptElement crossOrigin IDL attribute
Diffstat (limited to 'components/script/dom/htmlscriptelement.rs')
-rw-r--r--components/script/dom/htmlscriptelement.rs29
1 files changed, 29 insertions, 0 deletions
diff --git a/components/script/dom/htmlscriptelement.rs b/components/script/dom/htmlscriptelement.rs
index 11f4451ad50..a583ddc2137 100644
--- a/components/script/dom/htmlscriptelement.rs
+++ b/components/script/dom/htmlscriptelement.rs
@@ -5,6 +5,7 @@
use document_loader::LoadType;
use dom::attr::Attr;
use dom::bindings::cell::DOMRefCell;
+use dom::bindings::codegen::Bindings::AttrBinding::AttrMethods;
use dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods;
use dom::bindings::codegen::Bindings::HTMLScriptElementBinding;
use dom::bindings::codegen::Bindings::HTMLScriptElementBinding::HTMLScriptElementMethods;
@@ -30,6 +31,7 @@ use ipc_channel::ipc;
use ipc_channel::router::ROUTER;
use js::jsval::UndefinedValue;
use net_traits::{AsyncResponseListener, AsyncResponseTarget, Metadata, NetworkError};
+use net_traits::request::CORSSettings;
use network_listener::{NetworkListener, PreInvoke};
use std::ascii::AsciiExt;
use std::cell::Cell;
@@ -358,6 +360,7 @@ impl HTMLScriptElement {
true
},
+ // TODO: Step 19.
None => false,
};
@@ -652,6 +655,32 @@ impl HTMLScriptElementMethods for HTMLScriptElement {
// https://html.spec.whatwg.org/multipage/#dom-script-htmlfor
make_setter!(SetHtmlFor, "for");
+ // https://html.spec.whatwg.org/multipage/#dom-script-crossorigin
+ fn GetCrossOrigin(&self) -> Option<DOMString> {
+ let element = self.upcast::<Element>();
+ let attr = element.get_attribute(&ns!(), &atom!("crossorigin"));
+
+ if let Some(mut val) = attr.map(|v| v.Value()) {
+ val.make_ascii_lowercase();
+ if val == "anonymous" || val == "use-credentials" {
+ return Some(val);
+ }
+ return Some(DOMString::from("anonymous"));
+ }
+ None
+ }
+
+ // https://html.spec.whatwg.org/multipage/#dom-script-crossorigin
+ fn SetCrossOrigin(&self, value: Option<DOMString>) {
+ let element = self.upcast::<Element>();
+ match value {
+ Some(val) => element.set_string_attribute(&atom!("crossorigin"), val),
+ None => {
+ element.remove_attribute(&ns!(), &atom!("crossorigin"));
+ }
+ }
+ }
+
// https://html.spec.whatwg.org/multipage/#dom-script-text
fn Text(&self) -> DOMString {
Node::collect_text_contents(self.upcast::<Node>().children())