Manifest Update Process
High level information: https://web.dev/manifest-updates/
The manifest update process is required whenever a new manifest is served to an existing web_app, which would mean that the database entries corresponding to that web application needs to be updated. To do this, the following steps are kicked off:
-
Whenever the tab has kicked off a navigation to an url for a web_app, a check is kicked off to determine if a manifest update is required or not. The update process is aborted if the following conditions are satisfied:
- If the app is not installed.
- If the installed app is a System Web App
- If the installed app is a placeholder app
- If there was an existing update already running for a specific app id.
- If there has already been a manifest update within the past 24 hours. This is done to ensure similar behavior as on Android. This also helps prevent downloading megabytes of images every time a page with a valid manifest link is visited.
-
All pending updates are tracked in a map of update states keyed by app id by the
ManifestUpdateManager. If a successful update needs to happen, the process goes ahead by executing the following steps:- Wait for the page to finish loading.
- On successful page load, the
ManifestUpdateCheckCommandtakes over to perform the following tasks:- Fetching manifest data from the site.
- Loading saved manifest data from disk.
- Computing the differences between the site and on disk.
- Resolving changes to identity sensitive fields (app icon and name) by either allowing, requesting user confirmation or reverting changes.
- For any errors in the above steps or if there are no changes, the whole operation is aborted and the command gracefully exits.
- Once all the data has been fetched, wait for all existing app windows for that app to close.
- On all windows being closed, the
ManifestUpdateFinalizeCommandruns to write the new data to the DB and verify that a successful write has completed.
Testing
ManifestUpdateManagerBrowserTestcontains browser tests for the entire end-to-end working of the ManifestUpdateManager.ManifestUpdateCheckCommandTestcontains unit tests for the comparison part of the manifest update operation.ManifestUpdateFinalizeCommandTestcontains unit tests for the data writing section of the manifest update operation.