Auto merge of #10969 - servo:iframe, r=KiChjang

Iframe improvements.

<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10969)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-05-02 05:32:25 -07:00
commit d32648172c
2 changed files with 14 additions and 14 deletions

View file

@ -990,11 +990,12 @@ impl<LTF: LayoutThreadFactory, STF: ScriptThreadFactory> Constellation<LTF, STF>
// then reuse the script thread in creating the new pipeline // then reuse the script thread in creating the new pipeline
let source_url = &source_pipeline.url; let source_url = &source_pipeline.url;
// FIXME(#10968): this should probably match the origin check in
// HTMLIFrameElement::contentDocument.
let same_script = source_url.host() == new_url.host() && let same_script = source_url.host() == new_url.host() &&
source_url.port() == new_url.port() && source_url.port() == new_url.port() &&
load_info.sandbox == IFrameSandboxState::IFrameUnsandboxed; load_info.sandbox == IFrameSandboxState::IFrameUnsandboxed;
// FIXME(tkuehn): Need to follow the standardized spec for checking same-origin
// Reuse the script thread if the URL is same-origin // Reuse the script thread if the URL is same-origin
let script_chan = if same_script { let script_chan = if same_script {
debug!("Constellation: loading same-origin iframe, \ debug!("Constellation: loading same-origin iframe, \

View file

@ -76,7 +76,9 @@ impl HTMLIFrameElement {
self.sandbox.get().is_some() self.sandbox.get().is_some()
} }
pub fn get_url(&self) -> Option<Url> { /// <https://html.spec.whatwg.org/multipage/#otherwise-steps-for-iframe-or-frame-elements>,
/// step 1.
fn get_url(&self) -> Url {
let element = self.upcast::<Element>(); let element = self.upcast::<Element>();
element.get_attribute(&ns!(), &atom!("src")).and_then(|src| { element.get_attribute(&ns!(), &atom!("src")).and_then(|src| {
let url = src.value(); let url = src.value();
@ -85,7 +87,7 @@ impl HTMLIFrameElement {
} else { } else {
document_from_node(self).base_url().join(&url).ok() document_from_node(self).base_url().join(&url).ok()
} }
}) }).unwrap_or_else(|| Url::parse("about:blank").unwrap())
} }
pub fn generate_new_subpage_id(&self) -> (SubpageId, Option<SubpageId>) { pub fn generate_new_subpage_id(&self) -> (SubpageId, Option<SubpageId>) {
@ -144,10 +146,7 @@ impl HTMLIFrameElement {
} }
pub fn process_the_iframe_attributes(&self) { pub fn process_the_iframe_attributes(&self) {
let url = match self.get_url() { let url = self.get_url();
Some(url) => url,
None => Url::parse("about:blank").unwrap(),
};
// TODO - loaddata here should have referrer info (not None, None) // TODO - loaddata here should have referrer info (not None, None)
self.navigate_or_reload_child_browsing_context(Some(LoadData::new(url, None, None))); self.navigate_or_reload_child_browsing_context(Some(LoadData::new(url, None, None)));
@ -430,10 +429,9 @@ impl HTMLIFrameElementMethods for HTMLIFrameElement {
// https://html.spec.whatwg.org/multipage/#dom-iframe-contentdocument // https://html.spec.whatwg.org/multipage/#dom-iframe-contentdocument
fn GetContentDocument(&self) -> Option<Root<Document>> { fn GetContentDocument(&self) -> Option<Root<Document>> {
self.GetContentWindow().and_then(|window| { self.GetContentWindow().and_then(|window| {
let self_url = match self.get_url() { // FIXME(#10964): this should use the Document's origin and the
Some(self_url) => self_url, // origin of the incumbent settings object.
None => return None, let self_url = self.get_url();
};
let win_url = window_from_node(self).get_url(); let win_url = window_from_node(self).get_url();
if UrlHelper::SameOrigin(&self_url, &win_url) { if UrlHelper::SameOrigin(&self_url, &win_url) {
@ -585,11 +583,12 @@ impl VirtualMethods for HTMLIFrameElement {
// Since most of this cleanup doesn't happen on same-origin // Since most of this cleanup doesn't happen on same-origin
// iframes, and since that would cause a deadlock, don't do it. // iframes, and since that would cause a deadlock, don't do it.
let ConstellationChan(ref chan) = *window.constellation_chan(); let ConstellationChan(ref chan) = *window.constellation_chan();
let same_origin = if let Some(self_url) = self.get_url() { let same_origin = {
// FIXME(#10968): this should probably match the origin check in
// HTMLIFrameElement::contentDocument.
let self_url = self.get_url();
let win_url = window_from_node(self).get_url(); let win_url = window_from_node(self).get_url();
UrlHelper::SameOrigin(&self_url, &win_url) UrlHelper::SameOrigin(&self_url, &win_url)
} else {
false
}; };
let (sender, receiver) = if same_origin { let (sender, receiver) = if same_origin {
(None, None) (None, None)