diff --git a/front_end/elements_test_runner/ElementsTestRunner.js b/front_end/elements_test_runner/ElementsTestRunner.js index 566ac0d2fe..e13fd7ccd5 100644 --- a/front_end/elements_test_runner/ElementsTestRunner.js +++ b/front_end/elements_test_runner/ElementsTestRunner.js @@ -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} 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(); } };