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

Method load

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

* Creates a hidden iframe for logging and appends it to the top level * document.

()

Source from the content-addressed store, hash-verified

15378 * document.
15379 */
15380 static load() {
15381 if (iframe) {
15382 return;
15383 }
15384 const initOptions =
15385 /** @type {!PaymentOptions} */ (window['gpayInitParams']) || {};
15386 environment = initOptions.environment || Constants.Environment.PRODUCTION;
15387 iframe = document.createElement('iframe');
15388 // Pass in origin because document.referrer inside iframe is empty in
15389 // certain cases
15390 // Can be replaced by iframe.src=... in non Google context.
15391 iframe.src = PayFrameHelper.getIframeUrl_(
15392 window.location.origin,
15393 initOptions.merchantInfo && initOptions.merchantInfo.merchantId);
15394 PayFrameHelper.postMessage({
15395 'eventType': PostMessageEventType.LOG_PAY_FRAME_REQUESTED,
15396 'clientLatencyStartMs': Date.now(),
15397 });
15398 iframe.height = '0';
15399 iframe.width = '0';
15400 iframe.style.display = 'none';
15401 iframe.style.visibility = 'hidden';
15402 iframe.onload = function() {
15403 PayFrameHelper.postMessage({
15404 'eventType': PostMessageEventType.LOG_PAY_FRAME_LOADED_WITH_ALL_JS,
15405 'clientLatencyStartMs': Date.now(),
15406 });
15407 PayFrameHelper.iframeLoaded();
15408 };
15409 // If the body is already loaded, just append the iframe. Otherwise, we wait
15410 // until the DOM has loaded to append the iframe, otherwise document.body is
15411 // null.
15412 if (document.body) {
15413 PayFrameHelper.initialize_();
15414 } else {
15415 document.addEventListener(
15416 'DOMContentLoaded', () => PayFrameHelper.initialize_());
15417 }
15418 }
15419
15420 /**
15421 * Appends the iframe to the DOM and updates the post message service.

Callers 4

test-ini-load.jsFile · 0.45
constructorMethod · 0.45
configureGoogleSignInFunction · 0.45

Calls 6

getIframeUrl_Method · 0.80
nowMethod · 0.80
iframeLoadedMethod · 0.80
postMessageMethod · 0.45
initialize_Method · 0.45
addEventListenerMethod · 0.45

Tested by

no test coverage detected