Created attachment 464508 [details] `display-mode` is incorrectly `standalone` inside of the page of a website opened with an external link (target=_blank) from an installed webapp. The following evaluates to `true`: ```js window.matchMedia("(display-mode: standalone)").matches ``` for any external link (target=_blank) opened from a PWA installed to your homescreen on iOS when the manifest has `"display": "standalone"`. To reproduce: 1. Install elk.zone to your homescreen. 2. Open the following toot: https://elk.zone/social.harding.dev/@alex/109694193072896291 3. Tap the codepen link (https://codepen.io/aeharding/details/eYjEWEq) 4. Observe `display-mode: standalone` evaluates to true. Expected result: I would expect it to evaluate to false. Furthermore, I'd expect `display-mode` to have a value similar to opening an external link with SFSafariViewController from a traditional mobile app like Twitter (I'd expect it to be `browser`).
Sorry, looks like that toot link broke. Updated elk.zone toot here: https://main.elk.zone/social.harding.dev/@alex/109702803989162784 assuming you have https://main.elk.zone installed to your homescreen.
<rdar://problem/104333829>
Thanks for the report. I see two *potential* issues here, either of which could address this: (i.e. make it so that the display-mode doesn’t match ‘standalone’ in the opened window) 1. When the system creates a new web view to handle the opened “window”, we create that secondary web view with a WKWebViewConfiguration containing the web app’s _WKApplicationManifest. That allows the manifest (which defines the `display-mode` CSS property) to even be considered for browsing in that new window. 2. After glancing through the App Manifest spec, I noticed this wording: > As long as the application is navigated to URLs that are within scope, the browser will continue to apply the manifest. However, navigating the web applications "out of scope" will cause the manifest to no longer be applied, and the browser will apply its own defaults. So it seems like WebCore might be out of alignment with the spec here. Because codepen.io is not within scope of main.elk.zone, we shouldn’t consider the manifest of the web app to be applied to that individual URL. I’m pretty certain we should fix issue 2. Not sure about issue 1. (That doesn’t come into play in this particular case if we fix issue 2 -- but it would have impact if a web app decided to window.open() a URL within the scope of the application. Do we apply the manifest to the new window in that case?)