|
1 | 1 | /* global TrustedScriptURL, TrustedScript */
|
2 | 2 |
|
3 | 3 | import ContentFeature from '../content-feature.js'
|
4 |
| -import { DDGProxy, getStackTraceOrigins, getStack, matchHostname, injectGlobalStyles, createStyleElement } from '../utils.js' |
| 4 | +import { DDGProxy, getStackTraceOrigins, getStack, matchHostname, injectGlobalStyles, createStyleElement, postDebugMessage } from '../utils.js' |
5 | 5 | import { wrapScriptCodeOverload } from './runtime-checks/script-overload.js'
|
6 | 6 |
|
7 | 7 | let stackDomains = []
|
@@ -351,19 +351,35 @@ function shouldInterrogate (tagName) {
|
351 | 351 | return false
|
352 | 352 | }
|
353 | 353 | if (matchAllStackDomains) {
|
| 354 | + isInterrogatingDebugMessage('matchedAllStackDomain') |
354 | 355 | return true
|
355 | 356 | }
|
356 | 357 | if (taintCheck && document.currentScript?.[taintSymbol]) {
|
| 358 | + isInterrogatingDebugMessage('taintCheck') |
357 | 359 | return true
|
358 | 360 | }
|
359 | 361 | const stack = getStack()
|
360 | 362 | const scriptOrigins = [...getStackTraceOrigins(stack)]
|
361 |
| - const isInterestingHost = scriptOrigins.some(origin => { |
| 363 | + const interestingHost = scriptOrigins.find(origin => { |
362 | 364 | return stackDomains.some(rule => matchHostname(origin, rule.domain))
|
363 | 365 | })
|
| 366 | + const isInterestingHost = !!interestingHost |
| 367 | + if (isInterestingHost) { |
| 368 | + isInterrogatingDebugMessage('matchedStackDomain', interestingHost, stack, scriptOrigins) |
| 369 | + } |
364 | 370 | return isInterestingHost
|
365 | 371 | }
|
366 | 372 |
|
| 373 | +function isInterrogatingDebugMessage (matchType, matchedStackDomain, stack, scriptOrigins) { |
| 374 | + postDebugMessage('runtimeChecks', { |
| 375 | + documentUrl: document.location.href, |
| 376 | + matchedStackDomain, |
| 377 | + matchType, |
| 378 | + scriptOrigins, |
| 379 | + stack |
| 380 | + }) |
| 381 | +} |
| 382 | + |
367 | 383 | function overrideCreateElement () {
|
368 | 384 | const proxy = new DDGProxy(featureName, Document.prototype, 'createElement', {
|
369 | 385 | apply (fn, scope, args) {
|
|
0 commit comments