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

Method start

third_party/subscriptions-project/swg.js:7948–7979  ·  view source on GitHub ↗

* @return {!Promise<!../components/activities.ActivityIframePort>}

()

Source from the content-addressed store, hash-verified

7946 * @return {!Promise<!../components/activities.ActivityIframePort>}
7947 */
7948 start() {
7949 if (!this.serviceReady_) {
7950 // Please note that currently openIframe reads the current analytics
7951 // context and that it may not contain experiments activated late during
7952 // the publishers code lifecycle.
7953 this.addLabels(getOnExperiments(this.doc_.getWin()));
7954 this.serviceReady_ = this.activityPorts_
7955 .openIframe(this.iframe_, feUrl('/serviceiframe'), null, true)
7956 .then(
7957 (port) => {
7958 // Register a listener for the logging to code indicate it is
7959 // finished logging.
7960 port.on(FinishedLoggingResponse, this.afterLogging_.bind(this));
7961 return port.whenReady().then(() => {
7962 // The publisher should be done setting experiments but runtime
7963 // will forward them here if they aren't.
7964 this.addLabels(getOnExperiments(this.doc_.getWin()));
7965 return port;
7966 });
7967 },
7968 (message) => {
7969 // If the port doesn't open register that logging is broken so
7970 // nothing is just waiting.
7971 this.loggingBroken_ = true;
7972 this.afterLogging_(
7973 createErrorResponse('Could not connect [' + message + ']')
7974 );
7975 }
7976 );
7977 }
7978 return this.serviceReady_;
7979 }
7980
7981 /**
7982 * @param {boolean} isReadyToPay

Callers 1

handleClientEvent_Method · 0.95

Calls 10

addLabelsMethod · 0.95
afterLogging_Method · 0.95
getOnExperimentsFunction · 0.85
feUrlFunction · 0.85
createErrorResponseFunction · 0.85
openIframeMethod · 0.80
getWinMethod · 0.45
thenMethod · 0.45
onMethod · 0.45
whenReadyMethod · 0.45

Tested by

no test coverage detected