Skip to content

Commit 41616df

Browse files
committed
Improve trusted-suppress-native-method scriptlet
Add `debug` as disposition option: if the `how` parameter is `debug`, the scriptlet will trigger a `debugger` statement and the target method won't be suppressed. Useful to find out how the method is being called by page code. To be used for investigation purpose only.
1 parent fd60f54 commit 41616df

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

assets/resources/scriptlets.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4432,13 +4432,10 @@ function trustedSuppressNativeMethod(
44324432
safe.uboLog(logPrefix, `Arguments:\n${callArgs.join('\n')}`);
44334433
return context.reflect();
44344434
}
4435-
if ( callArgs.length < signatureArgs.length ) {
4436-
return context.reflect();
4437-
}
44384435
for ( let i = 0; i < signatureArgs.length; i++ ) {
44394436
const signatureArg = signatureArgs[i];
44404437
if ( signatureArg === undefined ) { continue; }
4441-
const targetArg = callArgs[i];
4438+
const targetArg = i < callArgs.length ? callArgs[i] : undefined;
44424439
if ( signatureArg.type === 'exact' ) {
44434440
if ( targetArg !== signatureArg.value ) {
44444441
return context.reflect();
@@ -4450,6 +4447,10 @@ function trustedSuppressNativeMethod(
44504447
}
44514448
}
44524449
}
4450+
if ( how === 'debug' ) {
4451+
debugger; // eslint-disable-line no-debugger
4452+
return context.reflect();
4453+
}
44534454
safe.uboLog(logPrefix, `Suppressed:\n${callArgs.join('\n')}`);
44544455
if ( how === 'abort' ) {
44554456
throw new ReferenceError();

0 commit comments

Comments
 (0)