* @return {!Promise<!../components/activities.ActivityIframePort>}
()
| 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 |
no test coverage detected