New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement Window.open and related infrastructure #20678
Changes from 1 commit
f408b79
21bf5a3
e27ba16
a0082c5
fee5428
96f7546
e784f5a
File filter...
Jump to…
share event-loops based on eTLD+1
- Loading branch information
| @@ -264,18 +264,13 @@ pub struct Constellation<Message, LTF, STF> { | ||
| /// WebRender thread. | ||
| webrender_api_sender: webrender_api::RenderApiSender, | ||
|
|
||
| /// The set of all event loops in the browser. We generate a new | ||
| /// event loop for each registered domain name (aka eTLD+1) in | ||
| /// each top-level browsing context. We store the event loops in a map | ||
| /// indexed by top-level browsing context id | ||
| /// (as a `TopLevelBrowsingContextId`) and registered | ||
| /// domain name (as a `Host`) to event loops. This double | ||
| /// indirection ensures that separate tabs do not share event | ||
| /// loops, even if the same domain is loaded in each. | ||
| /// The set of all event loops in the browser. | ||
| /// We store the event loops in a map | ||
| /// indexed by registered domain name (as a `Host`) to event loops. | ||
| /// It is important that scripts with the same eTLD+1 | ||
| /// share an event loop, since they can use `document.domain` | ||
| /// to become same-origin, at which point they can share DOM objects. | ||
| event_loops: HashMap<TopLevelBrowsingContextId, HashMap<Host, Weak<EventLoop>>>, | ||
| event_loops: HashMap<Host, Weak<EventLoop>>, | ||
gterzian
Author
Member
|
||
|
|
||
| joint_session_histories: HashMap<TopLevelBrowsingContextId, JointSessionHistory>, | ||
|
|
||
| @@ -718,9 +713,7 @@ where | ||
| None => (None, None), | ||
| Some(host) => { | ||
| let event_loop = self | ||
| .event_loops | ||
| .get(&top_level_browsing_context_id) | ||
| .and_then(|map| map.get(&host)) | ||
| .event_loops.get(&host) | ||
| .and_then(|weak| weak.upgrade()); | ||
| match event_loop { | ||
| None => (None, Some(host)), | ||
| @@ -806,9 +799,8 @@ where | ||
| "Adding new host entry {} for top-level browsing context {}.", | ||
| host, top_level_browsing_context_id | ||
| ); | ||
| self.event_loops | ||
| .entry(top_level_browsing_context_id) | ||
| .or_insert_with(HashMap::new) | ||
| let _ = self | ||
| .event_loops | ||
| .insert(host, Rc::downgrade(&pipeline.event_loop)); | ||
| } | ||
|
|
||
| @@ -1905,18 +1897,7 @@ where | ||
| Some(opener_pipeline) => (opener_pipeline, opener_pipeline.browsing_context_id), | ||
| None => return warn!("Auxiliary loaded url in closed pipeline {}.", opener_pipeline_id), | ||
| }; | ||
| let opener_host = match reg_host(&opener_pipeline.url) { | ||
| Some(host) => host, | ||
| None => return warn!("Auxiliary loaded pipeline with no url {}.", opener_pipeline_id), | ||
| }; | ||
| let script_sender = opener_pipeline.event_loop.clone(); | ||
| // https://html.spec.whatwg.org/multipage/#unit-of-related-similar-origin-browsing-contexts | ||
| // If the auxiliary shares the host/scheme with the creator, they share an event-loop. | ||
| // So the first entry for the auxiliary, itself currently "about:blank", | ||
| // is the event-loop for the current host of the creator. | ||
| self.event_loops.entry(new_top_level_browsing_context_id) | ||
| .or_insert_with(HashMap::new) | ||
| .insert(opener_host, Rc::downgrade(&script_sender)); | ||
| Pipeline::new(new_pipeline_id, | ||
| new_browsing_context_id, | ||
| new_top_level_browsing_context_id, | ||
| @@ -3565,10 +3546,6 @@ where | ||
| session_history.remove_entries_for_browsing_context(browsing_context_id); | ||
| } | ||
|
|
||
| if BrowsingContextId::from(browsing_context.top_level_id) == browsing_context_id { | ||
| self.event_loops.remove(&browsing_context.top_level_id); | ||
| } | ||
|
|
||
| let parent_info = self | ||
| .pipelines | ||
| .get(&browsing_context.pipeline_id) | ||
I don't understand this change. What happens if 2 tabs are from the same domain name now?