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

Method getViewerOrigin

src/service/viewer-impl.js:613–636  ·  view source on GitHub ↗

@override

()

Source from the content-addressed store, hash-verified

611
612 /** @override */
613 getViewerOrigin() {
614 if (!this.viewerOrigin_) {
615 let origin;
616 if (!this.isEmbedded()) {
617 // Viewer is only determined for iframed documents at this time.
618 origin = '';
619 } else if (
620 this.win.location.ancestorOrigins &&
621 this.win.location.ancestorOrigins.length > 0
622 ) {
623 origin = this.win.location.ancestorOrigins[0];
624 }
625 this.viewerOrigin_ =
626 origin !== undefined
627 ? Promise.resolve(origin)
628 : Services.timerFor(this.win)
629 .timeoutPromise(
630 VIEWER_ORIGIN_TIMEOUT_,
631 this.messagingReadyPromise_
632 )
633 .catch(() => '');
634 }
635 return /** @type {!Promise<string>} */ (this.viewerOrigin_);
636 }
637
638 /**
639 * @param {string} urlString

Callers 4

test-viewer.jsFile · 0.45
constructorMethod · 0.45
initializeMethod · 0.45
resolveGoogleViewer_Method · 0.45

Calls 4

isEmbeddedMethod · 0.95
resolveMethod · 0.80
catchMethod · 0.80
timeoutPromiseMethod · 0.80

Tested by

no test coverage detected