MCPcopy
hub / github.com/ampproject/amphtml / getWorkerScript_

Method getWorkerScript_

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

* @return {!Promise } * @private

()

Source from the content-addressed store, hash-verified

366 * @private
367 */
368 getWorkerScript_() {
369 // Use `testLocation` for testing with iframes. @see testing/iframe.js.
370 const location =
371 getMode().test && this.win.testLocation
372 ? this.win.testLocation
373 : this.win.location;
374 const useLocal = getMode().localDev || getMode().test;
375 const workerUrl = calculateExtensionScriptUrl(
376 location,
377 this.nodom_ ? 'amp-script-worker-nodom' : 'amp-script-worker',
378 '0.1',
379 useLocal
380 );
381 const xhr = Services.xhrFor(this.win);
382 return xhr.fetchText(workerUrl, {ampCors: false}).then((r) => r.text());
383 }
384
385 /**
386 * Query local or fetch remote author script.

Callers 1

layoutCallbackMethod · 0.95

Calls 5

getModeFunction · 0.90
fetchTextMethod · 0.80
thenMethod · 0.45
textMethod · 0.45

Tested by

no test coverage detected