diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
commit | 2aa4a82499d4becd2284cdb482213d541b8804dd (patch) | |
tree | b80bf8bf13c3766139fbacc530efd0dd9d54394c /devtools/client/debugger/test/mochitest/browser_dbg-inline-preview.js | |
parent | Initial commit. (diff) | |
download | firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.tar.xz firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.zip |
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'devtools/client/debugger/test/mochitest/browser_dbg-inline-preview.js')
-rw-r--r-- | devtools/client/debugger/test/mochitest/browser_dbg-inline-preview.js | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/devtools/client/debugger/test/mochitest/browser_dbg-inline-preview.js b/devtools/client/debugger/test/mochitest/browser_dbg-inline-preview.js new file mode 100644 index 0000000000..2749321c7d --- /dev/null +++ b/devtools/client/debugger/test/mochitest/browser_dbg-inline-preview.js @@ -0,0 +1,95 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */ + +// Test checking inline preview feature +add_task(async function() { + await pushPref("devtools.debugger.features.inline-preview", true); + + const dbg = await initDebugger( + "doc-inline-preview.html", + "inline-preview.js" + ); + await selectSource(dbg, "inline-preview.js"); + + await checkInlinePreview(dbg, "checkValues", [ + { identifier: "a:", value: '""' }, + { identifier: "b:", value: "false" }, + { identifier: "c:", value: "undefined" }, + { identifier: "d:", value: "null" }, + { identifier: "e:", value: "Array []" }, + { identifier: "f:", value: "Object { }" }, + { identifier: "obj:", value: "Object { foo: 1 }" }, + { + identifier: "bs:", + value: "Array(101) [ {…}, {…}, {…}, … ]", + }, + ]); + + await checkInlinePreview(dbg, "columnWise", [ + { identifier: "c:", value: '"c"' }, + { identifier: "a:", value: '"a"' }, + { identifier: "b:", value: '"b"' }, + ]); + + // Checks that open in inspector button works in inline preview + invokeInTab("btnClick"); + await checkInspectorIcon(dbg); + + const { toolbox } = dbg; + await toolbox.selectTool("jsdebugger"); + + await waitForPaused(dbg); + + // Check preview of event ( event.target should be clickable ) + // onBtnClick function in inline-preview.js + await checkInspectorIcon(dbg); +}); + +async function checkInlinePreview(dbg, fnName, inlinePreviews) { + invokeInTab(fnName); + + await waitForAllElements(dbg, "inlinePreviewLabels", inlinePreviews.length); + + const labels = findAllElements(dbg, "inlinePreviewLabels"); + const values = findAllElements(dbg, "inlinePreviewValues"); + + inlinePreviews.forEach((inlinePreview, index) => { + const { identifier, value, expandedValue } = inlinePreview; + is( + labels[index].innerText, + identifier, + `${identifier} in ${fnName} has correct inline preview label` + ); + is( + values[index].innerText, + value, + `${identifier} in ${fnName} has correct inline preview value` + ); + }); + + await resume(dbg); +} + +async function checkInspectorIcon(dbg) { + await waitForElement(dbg, "inlinePreviewOpenInspector"); + + const { toolbox } = dbg; + const node = findElement(dbg, "inlinePreviewOpenInspector"); + + // Ensure hovering over button highlights the node in content pane + const view = node.ownerDocument.defaultView; + const onNodeHighlight = toolbox.getHighlighter().waitForHighlighterShown(); + + EventUtils.synthesizeMouseAtCenter(node, { type: "mousemove" }, view); + + const { nodeFront } = await onNodeHighlight; + is(nodeFront.displayName, "button", "The correct node was highlighted"); + + // Ensure panel changes when button is clicked + const onInspectorPanelLoad = waitForInspectorPanelChange(dbg); + node.click(); + await onInspectorPanelLoad; + + await resume(dbg); +} |