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

Function draw3p

3p/integration-lib.js:152–195  ·  view source on GitHub ↗
(
  opt_configCallback,
  opt_allowed3pTypes,
  opt_allowedEmbeddingOrigins
)

Source from the content-addressed store, hash-verified

150 * that are allowed to embed this frame.
151 */
152export function draw3p(
153 opt_configCallback,
154 opt_allowed3pTypes,
155 opt_allowedEmbeddingOrigins
156) {
157 try {
158 const location = getLocation();
159
160 ensureFramed(window);
161 validateParentOrigin(window, location);
162 validateAllowedTypes(window, getEmbedType(), opt_allowed3pTypes);
163 if (opt_allowedEmbeddingOrigins) {
164 validateAllowedEmbeddingOrigins(window, opt_allowedEmbeddingOrigins);
165 }
166 window.context = new IntegrationAmpContext(window);
167 manageWin(window);
168 installEmbedStateListener();
169
170 // Ugly type annotation is due to Event.prototype.data being denylisted
171 // and the compiler not being able to discern otherwise
172 // TODO(alanorozco): Do this more elegantly once old impl is cleaned up.
173 draw3pInternal(
174 window,
175 /** @type {!IntegrationAmpContext} */ (window.context).data || {},
176 opt_configCallback
177 );
178
179 window.context.bootstrapLoaded();
180 } catch (e) {
181 if (window.context && window.context.report3pError) {
182 // window.context has initiated yet
183 if (e.message && isUserErrorMessage(e.message)) {
184 // report user error to parent window
185 window.context.report3pError(e);
186 }
187 }
188
189 const c = window.context || {mode: {test: false}};
190 if (!c.mode.test) {
191 lightweightErrorReport(e, c.canary);
192 throw e;
193 }
194 }
195}
196
197/**
198 * Throws if the current frame's parent origin is not equal to

Callers

nothing calls this directly

Calls 13

getLocationFunction · 0.90
getEmbedTypeFunction · 0.90
manageWinFunction · 0.90
ensureFramedFunction · 0.85
validateParentOriginFunction · 0.85
validateAllowedTypesFunction · 0.85
draw3pInternalFunction · 0.85
isUserErrorMessageFunction · 0.85
lightweightErrorReportFunction · 0.85
bootstrapLoadedMethod · 0.80

Tested by

no test coverage detected