Skip to content

Commit

Permalink
Improve trusted-suppress-native-method scriptlet
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
gorhill committed Nov 8, 2024
1 parent fd60f54 commit 41616df
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions assets/resources/scriptlets.js
Original file line number Diff line number Diff line change
Expand Up @@ -4432,13 +4432,10 @@ function trustedSuppressNativeMethod(
safe.uboLog(logPrefix, `Arguments:\n${callArgs.join('\n')}`);
return context.reflect();
}
if ( callArgs.length < signatureArgs.length ) {
return context.reflect();
}
for ( let i = 0; i < signatureArgs.length; i++ ) {
const signatureArg = signatureArgs[i];
if ( signatureArg === undefined ) { continue; }
const targetArg = callArgs[i];
const targetArg = i < callArgs.length ? callArgs[i] : undefined;
if ( signatureArg.type === 'exact' ) {
if ( targetArg !== signatureArg.value ) {
return context.reflect();
Expand All @@ -4450,6 +4447,10 @@ function trustedSuppressNativeMethod(
}
}
}
if ( how === 'debug' ) {
debugger; // eslint-disable-line no-debugger
return context.reflect();
}
safe.uboLog(logPrefix, `Suppressed:\n${callArgs.join('\n')}`);
if ( how === 'abort' ) {
throw new ReferenceError();
Expand Down

0 comments on commit 41616df

Please sign in to comment.