diff --git a/components/constellation/constellation.rs b/components/constellation/constellation.rs index 77305b4e153..a3086b50d93 100644 --- a/components/constellation/constellation.rs +++ b/components/constellation/constellation.rs @@ -1231,6 +1231,15 @@ impl Constellation warn!("Sending reply to get parent info failed ({:?}).", e); } } + FromScriptMsg::GetChildBrowsingContextId(browsing_context_id, index, sender) => { + // We increment here because the 0th element is the parent browsing context itself + let result = self.all_descendant_browsing_contexts_iter(browsing_context_id) + .nth(index + 1) + .map(|bc| bc.id); + if let Err(e) = sender.send(result) { + warn!("Sending reply to get child browsing context ID failed ({:?}).", e); + } + } FromScriptMsg::RegisterServiceWorker(scope_things, scope) => { debug!("constellation got store registration scope message"); self.handle_register_serviceworker(scope_things, scope); diff --git a/components/script_traits/script_msg.rs b/components/script_traits/script_msg.rs index efc368e0761..b3075c082bc 100644 --- a/components/script_traits/script_msg.rs +++ b/components/script_traits/script_msg.rs @@ -90,6 +90,8 @@ pub enum ScriptMsg { GetBrowsingContextId(PipelineId, IpcSender>), /// Get the parent info for a given pipeline. GetParentInfo(PipelineId, IpcSender>), + /// Get the nth child browsing context ID for a given browsing context, sorted in tree order. + GetChildBrowsingContextId(BrowsingContextId, usize, IpcSender>), /// tag finished parsing HeadParsed, /// All pending loads are complete, and the `load` event for this pipeline