Auto merge of #10554 - asajeffrey:fast-fail-handle-script-loaded-url-in-iframe, r=Ms2ger

Fast fail_handle_script_loaded_url_in_iframe_msg

<!-- 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/10554)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-04-13 15:23:51 +05:30
commit aec297565b

View file

@ -943,7 +943,10 @@ impl<LTF: LayoutThreadFactory, STF: ScriptThreadFactory> Constellation<LTF, STF>
let old_pipeline = old_pipeline_id let old_pipeline = old_pipeline_id
.and_then(|old_pipeline_id| self.pipelines.get(&old_pipeline_id)); .and_then(|old_pipeline_id| self.pipelines.get(&old_pipeline_id));
let source_pipeline = self.pipelines.get(&load_info.containing_pipeline_id); let source_pipeline = match self.pipelines.get(&load_info.containing_pipeline_id) {
Some(source_pipeline) => source_pipeline,
None => return warn!("Script loaded url in closed iframe {}.", load_info.containing_pipeline_id),
};
// If no url is specified, reload. // If no url is specified, reload.
let new_url = load_info.url.clone() let new_url = load_info.url.clone()
@ -952,16 +955,15 @@ impl<LTF: LayoutThreadFactory, STF: ScriptThreadFactory> Constellation<LTF, STF>
// Compare the pipeline's url to the new url. If the origin is the same, // Compare the pipeline's url to the new url. If the origin is the same,
// then reuse the script thread in creating the new pipeline // then reuse the script thread in creating the new pipeline
let script_chan = source_pipeline.and_then(|source_pipeline| {
let source_url = source_pipeline.url.clone(); let source_url = source_pipeline.url.clone();
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 // 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
if same_script { let script_chan = if same_script {
debug!("Constellation: loading same-origin iframe, \ debug!("Constellation: loading same-origin iframe, \
parent url {:?}, iframe url {:?}", source_url, new_url); parent url {:?}, iframe url {:?}", source_url, new_url);
Some(source_pipeline.script_chan.clone()) Some(source_pipeline.script_chan.clone())
@ -969,8 +971,7 @@ impl<LTF: LayoutThreadFactory, STF: ScriptThreadFactory> Constellation<LTF, STF>
debug!("Constellation: loading cross-origin iframe, \ debug!("Constellation: loading cross-origin iframe, \
parent url {:?}, iframe url {:?}", source_url, new_url); parent url {:?}, iframe url {:?}", source_url, new_url);
None None
} };
});
let window_size = old_pipeline.and_then(|old_pipeline| old_pipeline.size); let window_size = old_pipeline.and_then(|old_pipeline| old_pipeline.size);