aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/script_thread.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/script_thread.rs')
-rw-r--r--components/script/script_thread.rs58
1 files changed, 52 insertions, 6 deletions
diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs
index 6114e353d97..9247ca6afba 100644
--- a/components/script/script_thread.rs
+++ b/components/script/script_thread.rs
@@ -1419,7 +1419,7 @@ impl ScriptThread {
ChangeFrameVisibilityStatus(id, ..) => Some(id),
NotifyVisibilityChange(id, ..) => Some(id),
Navigate(id, ..) => Some(id),
- PostMessage(id, ..) => Some(id),
+ PostMessage { target: id, .. } => Some(id),
UpdatePipelineId(_, _, id, _) => Some(id),
UpdateHistoryState(id, ..) => Some(id),
RemoveHistoryStates(id, ..) => Some(id),
@@ -1592,9 +1592,19 @@ impl ScriptThread {
browsing_context_id,
visible,
),
- ConstellationControlMsg::PostMessage(pipeline_id, origin, data) => {
- self.handle_post_message_msg(pipeline_id, origin, data)
- },
+ ConstellationControlMsg::PostMessage {
+ target: target_pipeline_id,
+ source: source_pipeline_id,
+ source_browsing_context,
+ target_origin: origin,
+ data,
+ } => self.handle_post_message_msg(
+ target_pipeline_id,
+ source_pipeline_id,
+ source_browsing_context,
+ origin,
+ data,
+ ),
ConstellationControlMsg::UpdatePipelineId(
parent_pipeline_id,
browsing_context_id,
@@ -2080,12 +2090,33 @@ impl ScriptThread {
fn handle_post_message_msg(
&self,
pipeline_id: PipelineId,
+ source_pipeline_id: PipelineId,
+ source_browsing_context: TopLevelBrowsingContextId,
origin: Option<ImmutableOrigin>,
data: Vec<u8>,
) {
match { self.documents.borrow().find_window(pipeline_id) } {
- None => return warn!("postMessage after pipeline {} closed.", pipeline_id),
- Some(window) => window.post_message(origin, StructuredCloneData::Vector(data)),
+ None => return warn!("postMessage after target pipeline {} closed.", pipeline_id),
+ Some(window) => {
+ // FIXME: synchronously talks to constellation.
+ // send the required info as part of postmessage instead.
+ let source = match self.remote_window_proxy(
+ &*window.global(),
+ source_browsing_context,
+ source_pipeline_id,
+ None,
+ ) {
+ None => {
+ return warn!(
+ "postMessage after source pipeline {} closed.",
+ source_pipeline_id,
+ );
+ },
+ Some(source) => source,
+ };
+ // FIXME(#22512): enqueues a task; unnecessary delay.
+ window.post_message(origin, &*source, StructuredCloneData::Vector(data))
+ },
}
}
@@ -2820,6 +2851,21 @@ impl ScriptThread {
window.init_document(&document);
+ // For any similar-origin iframe, ensure that the contentWindow/contentDocument
+ // APIs resolve to the new window/document as soon as parsing starts.
+ if let Some(frame) = window_proxy
+ .frame_element()
+ .and_then(|e| e.downcast::<HTMLIFrameElement>())
+ {
+ let parent_pipeline = frame.global().pipeline_id();
+ self.handle_update_pipeline_id(
+ parent_pipeline,
+ window_proxy.browsing_context_id(),
+ incomplete.pipeline_id,
+ UpdatePipelineIdReason::Navigation,
+ );
+ }
+
self.script_sender
.send((incomplete.pipeline_id, ScriptMsg::ActivateDocument))
.unwrap();