From 2aa4a82499d4becd2284cdb482213d541b8804dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 16:29:10 +0200 Subject: Adding upstream version 86.0.1. Signed-off-by: Daniel Baumann --- .../test/mochitest/browser_dbg-inline-preview.js | 95 ++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 devtools/client/debugger/test/mochitest/browser_dbg-inline-preview.js (limited to 'devtools/client/debugger/test/mochitest/browser_dbg-inline-preview.js') 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 . */ + +// 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); +} -- cgit v1.2.3