-
Notifications
You must be signed in to change notification settings - Fork 4.1k
amp-script meta hash tags not recognized in PWA #26534
Description
What's the issue?
amp-script <meta> tags, e.g. <meta name="amp-script-src" content="sha384-YCFs8k-ouELcBTgzKzNAujZFxygwiqimSqKK7JqeKaGNflwDxaC3g2toj7s_kxWG">, are not imported into the <head> of a PWA, nor are they recognized when manually inserted into the <head> of a PWA appshell.
How do we reproduce the issue?
This AMP page includes a small amp-script:
https://ampdemo.cmphys.com/issue-amp-script-pwa/amp-script-demo-amp.html
This PWA loads the previous AMP page into a PWA:
https://ampdemo.cmphys.com/issue-amp-script-pwa/amp-script-demo-pwa.html
The AMP page loads <amp-script> just fine. The PWA does not, reporting:
Script hash not found. amp-script[script="hello-world"].js must have "sha384-YCFs8k-ouELcBTgzKzNAujZFxygwiqimSqKK7JqeKaGNflwDxaC3g2toj7s_kxWG" in meta[name="amp-script-src"].
Additional context
Manually adding <meta name="amp-script-src" ...> to the <head> of the appshell is not sufficient. It seems amp-script is locked into ampdoc scope, but there is no <head> in the ShadowRoot hosted ampdoc. Suggested solution is to update shadow-v0.js to bump relevant <meta> tags to the appshell <head> when .attachShadowDoc() is invoked (deleting existing amp-script <meta> tags) and amp-script should also be modified to look in the appshell <head> for relevant <meta> tags.
What browsers are affected?
Test in Chrome Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36.
Which AMP version is affected?
2001071857360