aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/htmliframeelement.rs
diff options
context:
space:
mode:
authorJim Hoskins <jim@jimhoskins.com>2015-01-09 11:04:38 -0800
committerJim Hoskins <jim@jimhoskins.com>2015-01-09 11:24:41 -0800
commite8036accd6b4c2d5c3e94ca7e304492cc2ec23af (patch)
tree173043bec3f2746234753cbee7d8a701f461ef72 /components/script/dom/htmliframeelement.rs
parent43e34d6d1050227eecc8fa293f9faec066f173a1 (diff)
downloadservo-e8036accd6b4c2d5c3e94ca7e304492cc2ec23af.tar.gz
servo-e8036accd6b4c2d5c3e94ca7e304492cc2ec23af.zip
Store HTMLIFrameElement sandbox attr as TokenList
Fixes #3758 Store the sandbox attribute of HTMLIFrameElement as a TokenList internally. Use .tokens() to iterate over the tokens instead of splitting on the string value. The external interface for sandbox remains a DOMString, which will need to be fixed when DOMSettableTokenList is implemented (#1717).
Diffstat (limited to 'components/script/dom/htmliframeelement.rs')
-rw-r--r--components/script/dom/htmliframeelement.rs24
1 files changed, 13 insertions, 11 deletions
diff --git a/components/script/dom/htmliframeelement.rs b/components/script/dom/htmliframeelement.rs
index aeb480bdfbf..683c18c678a 100644
--- a/components/script/dom/htmliframeelement.rs
+++ b/components/script/dom/htmliframeelement.rs
@@ -167,7 +167,7 @@ impl<'a> HTMLIFrameElementMethods for JSRef<'a, HTMLIFrameElement> {
fn SetSandbox(self, sandbox: DOMString) {
let element: JSRef<Element> = ElementCast::from_ref(self);
- element.set_string_attribute(&atom!("sandbox"), sandbox);
+ element.set_tokenlist_attribute(&atom!("sandbox"), sandbox);
}
fn GetContentWindow(self) -> Option<Temporary<Window>> {
@@ -217,16 +217,18 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLIFrameElement> {
match attr.local_name() {
&atom!("sandbox") => {
let mut modes = SandboxAllowance::AllowNothing as u8;
- for word in attr.value().as_slice().split(' ') {
- modes |= match word.to_ascii_lower().as_slice() {
- "allow-same-origin" => SandboxAllowance::AllowSameOrigin,
- "allow-forms" => SandboxAllowance::AllowForms,
- "allow-pointer-lock" => SandboxAllowance::AllowPointerLock,
- "allow-popups" => SandboxAllowance::AllowPopups,
- "allow-scripts" => SandboxAllowance::AllowScripts,
- "allow-top-navigation" => SandboxAllowance::AllowTopNavigation,
- _ => SandboxAllowance::AllowNothing
- } as u8;
+ if let Some(ref tokens) = attr.value().tokens() {
+ for token in tokens.iter() {
+ modes |= match token.as_slice().to_ascii_lower().as_slice() {
+ "allow-same-origin" => SandboxAllowance::AllowSameOrigin,
+ "allow-forms" => SandboxAllowance::AllowForms,
+ "allow-pointer-lock" => SandboxAllowance::AllowPointerLock,
+ "allow-popups" => SandboxAllowance::AllowPopups,
+ "allow-scripts" => SandboxAllowance::AllowScripts,
+ "allow-top-navigation" => SandboxAllowance::AllowTopNavigation,
+ _ => SandboxAllowance::AllowNothing
+ } as u8;
+ }
}
self.sandbox.set(Some(modes));
},