Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Backfill remote asset listing when needed (#1531)
## Motivation for the change, related issues In order to reintroduce the request routing improvements in #1490, we need to be sure that existing browser storage can backfill the wordpress-remote-asset-paths file when needed. That is the purpose of this PR. ## Implementation details During boot, we check whether the `/wordpress/wordpress-remote-asset-paths` exists. If it does not exist, we check a static file path that should be common across WP versions, `wp-admin/css/common.css`. If the common static file also does not exist, we guess we are dealing with a minified WP build cached in browser storage without a remote asset listing file, and we download it based on detected WordPress version (as long as the detected version is a supported WP version). ## Testing Instructions (or ideally a Blueprint) So far, I have tested this manually with steps like the following: 1. Install the Chrome extension [OPFS Explorer](https://chromewebstore.google.com/detail/opfs-explorer/acndjpgkpaclldomagafnognkcgjignd?hl=en) 2. Switch Playground to browser storage and note the current WP release _X_ in the query string 3. Open dev tools 4. Use OPFS explorer to confirm `/wordpress/wordpress-remote-asset-paths` exists and then delete the file 5. Switch to the dev tools Network tab 6. Reload the page 7. Filter the requests and confirm there was a request for the current WP release _X_ like `/wp-<X>/wordpress-remote-asset-paths` 8. Clear the Network request log 9. Use OPFS explorer to confirm `/wordpress/wordpress-remote-asset-paths` exists again. Then delete the file. 10. Manually adjust the query string to point to request a different WP release. 11. Reload the page 12. Return to the dev tools Network tab, filter the requests, and confirm there was a request for the current WP release _X_ like `/wp-<X>/wordpress-remote-asset-paths`. Regardless of the WP version in the query string, we should continue requesting the paths listing for version _X_ because that is what is in browser storage. 13. Review the console log and confirm there is a warning like "Loaded WordPress version (X) differs from requested version (Y)" and confirm that _Y_ matches the version requested via the query string. 14. Use OPFS explorer to confirm `/wordpress/wordpress-remote-asset-paths` exists again.
- Loading branch information