Custom formatter hooks don't bail when native functions are called
Categories
(DevTools :: Framework, defect, P1)
Tracking
(firefox110 verified, firefox111 verified)
People
(Reporter: nchevobbe, Assigned: nchevobbe)
References
(Blocks 1 open bug)
Details
Attachments
(1 file)
(deleted),
text/x-phabricator-request
|
Details |
Steps to reproduce
- With
devtools.custom-formatters
anddevtools.custom-formatters.enabled
set to true - Open the console in this page
- Evaluate the following snippet
window.devtoolsFormatters = [{
header: (obj, config) => {
if (obj.hasOwnProperty("customFormatHeader")) {
localStorage.setItem("test", 12);
return [
"span",
{
},
"custom formatted header",
];
}
return null;
},
}
];
({
customFormatHeader: true
})
Expected results
The regular object is printed (Object { customFormatHeader: true }
) on the console, as the header
function is effectful (calling localStorage.setItem
)
Actual results
The custom formatted version is printed (custom formatted header
), meaning the side-effect-free debugger failed to bail.
We're missing something here.
The side-effect-free debugger has a onNativeCall
hook that should handle those native calls (https://searchfox.org/mozilla-central/rev/17aeb39742eba71e0936ae44a51a54197100166d/devtools/server/actors/webconsole/eval-with-debugger.js#397-416)
But the doc states that
SpiderMonkey only calls onNativeCall hooks when execution is inside a debugger evaluation associated with the debugger that has the onNativeCall hook. Such evaluation methods include Debugger.Object.executeInGlobal, Debugger.Frame.eval, and associated methods.
The issue is that we're using DebuggerObject#call
to call the custom formatter hook functions (https://searchfox.org/mozilla-central/rev/17aeb39742eba71e0936ae44a51a54197100166d/devtools/server/actors/object.js#791), and so the onNativeCall
hook is not triggered, which makes our side-effect-free setup quite inefficient.
We would need to either:
- trigger
onNativeCall
hooks when callingDebuggerObject#call
/DebuggerObject#apply
- or find a way to call the custom formatters via
executeInGlobal
Assignee | ||
Comment 1•2 years ago
|
||
Depends on D165140
Updated•2 years ago
|
Updated•2 years ago
|
Comment 3•2 years ago
|
||
bugherder |
Updated•2 years ago
|
Comment 4•2 years ago
|
||
Reproduced on Firefox 109.0.1(build ID: 20230127170202) on macOS 12.
Verified as fixed on Firefox 110.0b8(build ID: 20230202190127) and Nightly 111.0a1(build ID: 20230203091639) on macOS 12, Windows 10, Ubuntu 22.
Description
•