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

Function validateAllowedTypes

3p/integration-lib.js:228–249  ·  view source on GitHub ↗
(window, type, allowedTypes)

Source from the content-addressed store, hash-verified

226 * @visibleForTesting
227 */
228export function validateAllowedTypes(window, type, allowedTypes) {
229 const thirdPartyHost = parseUrlDeprecated(urls.thirdParty).hostname;
230
231 // Everything allowed in default iframe.
232 if (window.location.hostname == thirdPartyHost) {
233 return;
234 }
235 if (urls.thirdPartyFrameRegex.test(window.location.hostname)) {
236 return;
237 }
238 if (window.location.hostname == 'ads.localhost') {
239 return;
240 }
241 if (defaultAllowedTypesInCustomFrame.indexOf(type) != -1) {
242 return;
243 }
244 userAssert(
245 allowedTypes && allowedTypes.indexOf(type) != -1,
246 '3p type for custom iframe not allowed: %s',
247 type
248 );
249}
250
251/**
252 * Check that parent host name was allowed.

Callers 2

draw3pFunction · 0.85

Calls 3

parseUrlDeprecatedFunction · 0.90
userAssertFunction · 0.90
testMethod · 0.45

Tested by

no test coverage detected