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.
This commit is contained in:
Raymond Hill 2024-11-08 08:32:19 -05:00
parent fd60f54a5f
commit 41616df866
No known key found for this signature in database
GPG key ID: 25E1490B761470C2

View file

@ -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();
@ -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();