Rewild Your Web
web
browser
dweb
1--- original
2+++ modified
3@@ -6,6 +6,7 @@
4 use std::sync::Arc;
5 use std::time::{SystemTime, UNIX_EPOCH};
6
7+use constellation_traits::{EmbeddedWebViewEventType, ScriptToConstellationMessage};
8 use dom_struct::dom_struct;
9 use embedder_traits::{
10 EmbedderMsg, Notification as EmbedderNotification,
11@@ -270,11 +271,21 @@
12 if !shown {
13 // TODO: step 6.1: Append notification to the list of notifications.
14 // step 6.2: Display notification on the device
15- self.global()
16- .send_to_embedder(EmbedderMsg::ShowNotification(
17- self.global().webview_id(),
18- self.to_embedder_notification(),
19- ));
20+ let notification = self.to_embedder_notification();
21+ if self.global().is_embedded_webview() {
22+ // For embedded webviews, route through constellation to parent iframe
23+ self.global().send_to_constellation(
24+ ScriptToConstellationMessage::EmbeddedWebViewNotification(
25+ EmbeddedWebViewEventType::NotificationShow(notification),
26+ ),
27+ );
28+ } else {
29+ self.global()
30+ .send_to_embedder(EmbedderMsg::ShowNotification(
31+ self.global().webview_id(),
32+ notification,
33+ ));
34+ }
35 }
36
37 // TODO: step 7: If shown is false or oldNotification is non-null,
38@@ -854,6 +865,11 @@
39 for (request, resource_type) in pending_requests {
40 self.fetch_and_show_when_ready(request, resource_type);
41 }
42+
43+ // If there are no resources to fetch, show the notification immediately
44+ if self.pending_request_ids.borrow().is_empty() {
45+ self.show();
46+ }
47 }
48
49 fn fetch_and_show_when_ready(&self, request: RequestBuilder, resource_type: ResourceType) {