mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-13 01:54:52 +08:00
Extend dumpInspectorHighlightJSON to accept a replacer for JSON.stringify
Based on the discussion in https://chromium-review.googlesource.com/c/chromium/src/+/2683860/2/third_party/blink/web_tests/http/tests/devtools/elements/highlight/highlight-css-flex-item.js#28 Bug: 1173995 Change-Id: I0365be80158b7b4a1b4d39244f0bbc9d8ad15317 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2687055 Reviewed-by: Mathias Bynens <mathias@chromium.org> Reviewed-by: Patrick Brosset <patrick.brosset@microsoft.com> Commit-Queue: Alex Rudenko <alexrudenko@chromium.org>
This commit is contained in:
@@ -1213,12 +1213,24 @@ function onBlankSection(selector, callback) {
|
||||
ElementsTestRunner.waitForSelectorCommitted(callback.bind(null, section));
|
||||
}
|
||||
|
||||
ElementsTestRunner.dumpInspectorHighlightJSON = function(idValue, callback) {
|
||||
/**
|
||||
* The function accepts 2 or 3 arguments. Callback is the last one and the second argument is optional.
|
||||
*
|
||||
* To dump all highlight properties: dumpInspectorHighlightJSON(idValue, callback).
|
||||
* To pick which properties to dump: dumpInspectorHighlightJSON(idValue, ['prop'], callback).
|
||||
*
|
||||
* @param {string} idValue
|
||||
* @param {!Function|!Array<string>} replacerOrCallback
|
||||
* @param {?Function=} maybeCallback
|
||||
*/
|
||||
ElementsTestRunner.dumpInspectorHighlightJSON = function(idValue, replacerOrCallback, maybeCallback) {
|
||||
const callback = arguments.length === 3 ? maybeCallback : replacerOrCallback;
|
||||
const replacer = arguments.length === 3 ? replacerOrCallback : null;
|
||||
ElementsTestRunner.nodeWithId(idValue, nodeResolved);
|
||||
|
||||
async function nodeResolved(node) {
|
||||
const result = await TestRunner.OverlayAgent.getHighlightObjectForTest(node.id);
|
||||
TestRunner.addResult(idValue + JSON.stringify(result, null, 2));
|
||||
TestRunner.addResult(idValue + JSON.stringify(result, replacer, 2));
|
||||
callback();
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user