diff options
author | Josh Matthews <josh@joshmatthews.net> | 2018-12-20 16:16:51 -0500 |
---|---|---|
committer | Josh Matthews <josh@joshmatthews.net> | 2019-01-07 22:19:25 -0500 |
commit | 45619db0ba0999d93b5715e1dae0ff49d1088ebe (patch) | |
tree | 5008ee0bf4c228a0eb906296e465f9e8f9b12756 /components/script/script_thread.rs | |
parent | 212ae3b94a869f05a560288a0ec834d143ed7d37 (diff) | |
download | servo-45619db0ba0999d93b5715e1dae0ff49d1088ebe.tar.gz servo-45619db0ba0999d93b5715e1dae0ff49d1088ebe.zip |
Provide the source window as part of postMessage events.
Diffstat (limited to 'components/script/script_thread.rs')
-rw-r--r-- | components/script/script_thread.rs | 43 |
1 files changed, 37 insertions, 6 deletions
diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index 6114e353d97..9ef684b96c4 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)) + }, } } |