MCPcopy Create free account
hub / github.com/ampproject/amphtml / constructor

Method constructor

extensions/amp-script/0.1/amp-script.js:592–614  ·  view source on GitHub ↗

* @param {!../../../src/service/ampdoc-impl.AmpDoc} ampdoc

(ampdoc)

Source from the content-addressed store, hash-verified

590 * @param {!../../../src/service/ampdoc-impl.AmpDoc} ampdoc
591 */
592 constructor(ampdoc) {
593 /** @private {!../../../src/service/ampdoc-impl.AmpDoc} */
594 this.ampdoc_ = ampdoc;
595
596 /** @private {number} */
597 this.cumulativeNonSandboxedSize_ = 0;
598
599 /** @private {number} */
600 this.cumulativeSandboxedSize_ = 0;
601
602 /** @private {!Array<string>} */
603 this.sources_ = [];
604
605 // Query the meta tag once per document.
606 const allowedHashes = ampdoc.getMetaByName('amp-script-src');
607 if (allowedHashes) {
608 // Allow newlines between hashes for readability/diffs
609 this.sources_ = allowedHashes.split(/\s+/).filter(Boolean);
610 }
611
612 /** @private @const {!../../../src/service/crypto-impl.Crypto} */
613 this.crypto_ = Services.cryptoFor(ampdoc.win);
614 }
615
616 /**
617 * Checks if `sha384(script)` exists in `meta[name="amp-script-src"]` element

Callers

nothing calls this directly

Calls 2

getMetaByNameMethod · 0.80
filterMethod · 0.45

Tested by

no test coverage detected