diff options
author | Alan Jeffrey <ajeffrey@mozilla.com> | 2017-02-09 14:28:37 -0600 |
---|---|---|
committer | Alan Jeffrey <ajeffrey@mozilla.com> | 2017-03-14 14:36:03 -0500 |
commit | 1f61a549a35ae317479f914c454fbee3580869d6 (patch) | |
tree | 1bdfd0d2c1da680af0ffd21278fe439558417061 /components/script/dom/htmliframeelement.rs | |
parent | 628cd7de6d6229af61d44b586da74176c21cc2ae (diff) | |
download | servo-1f61a549a35ae317479f914c454fbee3580869d6.tar.gz servo-1f61a549a35ae317479f914c454fbee3580869d6.zip |
Added some same-origin-domain checks.
Diffstat (limited to 'components/script/dom/htmliframeelement.rs')
-rw-r--r-- | components/script/dom/htmliframeelement.rs | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/components/script/dom/htmliframeelement.rs b/components/script/dom/htmliframeelement.rs index dd8c13de449..5e9891bdcc4 100644 --- a/components/script/dom/htmliframeelement.rs +++ b/components/script/dom/htmliframeelement.rs @@ -327,20 +327,6 @@ impl HTMLIFrameElement { false } } - - pub fn get_content_window(&self) -> Option<Root<Window>> { - self.pipeline_id.get() - .and_then(|pipeline_id| ScriptThread::find_document(pipeline_id)) - .and_then(|document| { - let current_global = GlobalScope::current(); - let current_document = current_global.as_window().Document(); - if document.origin().same_origin(current_document.origin()) { - Some(Root::from_ref(document.window())) - } else { - None - } - }) - } } pub trait HTMLIFrameElementLayoutMethods { @@ -512,15 +498,33 @@ impl HTMLIFrameElementMethods for HTMLIFrameElement { // https://html.spec.whatwg.org/multipage/#dom-iframe-contentwindow fn GetContentWindow(&self) -> Option<Root<BrowsingContext>> { - match self.get_content_window() { - Some(ref window) => Some(window.browsing_context()), - None => None + if self.pipeline_id.get().is_some() { + ScriptThread::find_browsing_context(self.frame_id) + } else { + None } } // https://html.spec.whatwg.org/multipage/#dom-iframe-contentdocument + // https://html.spec.whatwg.org/multipage/#concept-bcc-content-document fn GetContentDocument(&self) -> Option<Root<Document>> { - self.get_content_window().map(|window| window.Document()) + // Step 1. + let pipeline_id = match self.pipeline_id.get() { + None => return None, + Some(pipeline_id) => pipeline_id, + }; + // Step 2-3. + let document = match ScriptThread::find_document(pipeline_id) { + None => return None, + Some(document) => document, + }; + // Step 4. + let current = GlobalScope::current().as_window().Document(); + if !current.origin().same_origin_domain(document.origin()) { + return None; + } + // Step 5. + Some(document) } // Experimental mozbrowser implementation is based on the webidl |