Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
Feature request: <webview> app-manifest-updated event #10169
I'd like to propose a new event which is dispatched when a web app manifest link relation changes:
...as defined by W3C Web App Manifest specification and used by modern progressive web apps.
The payload of the event could simply be the URL of the manifest as with icon link relations, or it could be the manifest JSON content itself with Electron responsible for fetching the manifest in a fully spec compliant way (e.g. using the correct browsing context and supporting HTTP authenticated manifests etc).
For prior art, see the vendor-prefixed
The use case of this event is to detect when the current web page is part of a web app that can be installed, and use the manifest metadata to install the web app into a web app runtime.
The event name could be different to what I propose here, but note that a web app manifest applies to a whole web app or website which may consist of multiple pages, it it not strictly page metadata in the way that a
I had a play around using a
FWIW I had the same issue when I implemented the W3C web app manifest support in the Firefox browser in Firefox OS. I initially tried to implement it in the app itself but we eventually realised manifest fetching had to be implemented at the platform level to be fully spec compliant.
I did a quick dive into the Chromium logic that managers the app manifest and it looks like behind the scenes their may be something we can hook in to. But it isn't exposed in as nice a way as other renderer events
FWIW, below is some rough code for a basic workaround which works for manifests that are present in the DOM at the point DOMContentLoaded is fired, which covers most web apps.
app.html - the browser chrome embedding the webview
app.js - browser chrome code to receive the manifestdetected messages
preload.js - the preload script injected into web content which sends the messages
As noted above, a MutationObserver could detect manifests inserted into the DOM after this point.
Also as noted above, I don't think an implementation can be fully compliant with the W3C Web App Manifest specification using this approach as really Electron/Chromium needs to fetch and process the manifest in the correct browsing context and properly support CSP, authentication etc.