From 59203c63bb777a3bacec32fb8830fba33540e809 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 12 Jun 2024 07:35:29 +0200 Subject: Adding upstream version 127.0. Signed-off-by: Daniel Baumann --- .../mochitest/browser_dbg-event-breakpoints.js | 10 +++++ .../mochitest/browser_dbg-javascript-tracer.js | 45 ++++++++++++++++++++++ .../test/mochitest/examples/event-breakpoints.js | 7 +++- 3 files changed, 61 insertions(+), 1 deletion(-) (limited to 'devtools/client/debugger/test/mochitest') diff --git a/devtools/client/debugger/test/mochitest/browser_dbg-event-breakpoints.js b/devtools/client/debugger/test/mochitest/browser_dbg-event-breakpoints.js index 1065674186..49b3d3ffce 100644 --- a/devtools/client/debugger/test/mochitest/browser_dbg-event-breakpoints.js +++ b/devtools/client/debugger/test/mochitest/browser_dbg-event-breakpoints.js @@ -7,6 +7,7 @@ add_task(async function () { await pushPref("dom.element.invokers.enabled", true); await pushPref("dom.element.popover.enabled", true); + await pushPref("dom.events.textevent.enabled", true); const dbg = await initDebugger( "doc-event-breakpoints.html", @@ -151,6 +152,15 @@ add_task(async function () { assertPausedAtSourceAndLine(dbg, eventBreakpointsSource.id, 63); await resume(dbg); + info("Test textInput"); + await toggleEventBreakpoint(dbg, "Keyboard", "event.keyboard.textInput"); + invokeOnElement("#focus-text", "focus"); + EventUtils.sendChar("N"); + await waitForPaused(dbg); + assertPausedAtSourceAndLine(dbg, eventBreakpointsSource.id, 98); + await resume(dbg); + await toggleEventBreakpoint(dbg, "Keyboard", "event.keyboard.textInput"); + info(`Check that breakpoint can be set on "scrollend"`); await toggleEventBreakpoint(dbg, "Control", "event.control.scrollend"); diff --git a/devtools/client/debugger/test/mochitest/browser_dbg-javascript-tracer.js b/devtools/client/debugger/test/mochitest/browser_dbg-javascript-tracer.js index bfa2447474..29335af768 100644 --- a/devtools/client/debugger/test/mochitest/browser_dbg-javascript-tracer.js +++ b/devtools/client/debugger/test/mochitest/browser_dbg-javascript-tracer.js @@ -12,6 +12,19 @@ add_task(async function () { const dbg = await initDebugger("doc-scripts.html"); + // Add an iframe before starting the tracer to later check for key event on it + const preExistingIframeBrowsingContext = await SpecialPowers.spawn( + gBrowser.selectedBrowser, + [], + async function () { + const iframe = content.document.createElement("iframe"); + iframe.src = `data:text/html,`; + content.document.body.appendChild(iframe); + await new Promise(resolve => (iframe.onload = resolve)); + return iframe.contentWindow.browsingContext; + } + ); + info("Enable the tracing"); await clickElement(dbg, "trace"); @@ -55,6 +68,38 @@ add_task(async function () { await hasConsoleMessage(dbg, "DOM | click"); await hasConsoleMessage(dbg, "λ simple"); + const iframeBrowsingContext = await SpecialPowers.spawn( + gBrowser.selectedBrowser, + [], + async function () { + const iframe = content.document.createElement("iframe"); + iframe.src = `data:text/html,`; + content.document.body.appendChild(iframe); + await new Promise(resolve => (iframe.onload = resolve)); + iframe.contentWindow.document.querySelector("input").focus(); + return iframe.contentWindow.browsingContext; + } + ); + + await BrowserTestUtils.synthesizeKey("x", {}, iframeBrowsingContext); + await hasConsoleMessage(dbg, "DOM | keypress"); + await hasConsoleMessage(dbg, "λ onkeypress"); + + await SpecialPowers.spawn( + preExistingIframeBrowsingContext, + [], + async function () { + content.document.querySelector("input").focus(); + } + ); + await BrowserTestUtils.synthesizeKey( + "x", + {}, + preExistingIframeBrowsingContext + ); + await hasConsoleMessage(dbg, "DOM | keydown"); + await hasConsoleMessage(dbg, "λ onkeydown"); + // Test Blackboxing info("Clear the console from previous traces"); const { hud } = await dbg.toolbox.getPanel("webconsole"); diff --git a/devtools/client/debugger/test/mochitest/examples/event-breakpoints.js b/devtools/client/debugger/test/mochitest/examples/event-breakpoints.js index f9aa16b858..3d8163a8c4 100644 --- a/devtools/client/debugger/test/mochitest/examples/event-breakpoints.js +++ b/devtools/client/debugger/test/mochitest/examples/event-breakpoints.js @@ -91,4 +91,9 @@ function onBeforeToggle(event) { popover.addEventListener("toggle", onToggle); function onToggle(event) { console.log("toggle", event); -} \ No newline at end of file +} + +document.getElementById("focus-text").addEventListener("textInput", onTextInput); +function onTextInput() { + console.log("textInput"); +} -- cgit v1.2.3