(window, type, allowedTypes)
| 226 | * @visibleForTesting |
| 227 | */ |
| 228 | export 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. |
no test coverage detected