diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /devtools/client/inspector/markup/test/browser_markup_events_01.js | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | devtools/client/inspector/markup/test/browser_markup_events_01.js | 132 |
1 files changed, 132 insertions, 0 deletions
diff --git a/devtools/client/inspector/markup/test/browser_markup_events_01.js b/devtools/client/inspector/markup/test/browser_markup_events_01.js new file mode 100644 index 0000000000..0fbd47b8f5 --- /dev/null +++ b/devtools/client/inspector/markup/test/browser_markup_events_01.js @@ -0,0 +1,132 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ +/* import-globals-from helper_events_test_runner.js */ + +"use strict"; + +// Test that markup view event bubbles show the correct event info for DOM +// events. + +const TEST_URL = URL_ROOT_SSL + "doc_markup_events_01.html"; + +loadHelperScript("helper_events_test_runner.js"); + +const TEST_DATA = [ + { + selector: "html", + expected: [ + { + type: "load", + filename: TEST_URL, + attributes: ["Bubbling"], + handler: "function onload(event) {\n" + " init();\n" + "}", + }, + ], + }, + { + selector: "#container", + expected: [ + { + type: "mouseover", + filename: TEST_URL + ":48:31", + attributes: ["Capturing"], + handler: + "function mouseoverHandler(event) {\n" + + ' if (event.target.id !== "container") {\n' + + ' const output = document.getElementById("output");\n' + + " output.textContent = event.target.textContent;\n" + + " }\n" + + "}", + }, + ], + }, + { + selector: "#multiple", + expected: [ + { + type: "click", + filename: TEST_URL + ":55:27", + attributes: ["Bubbling"], + handler: + "function clickHandler(event) {\n" + + ' const output = document.getElementById("output");\n' + + ' output.textContent = "click";\n' + + "}", + }, + { + type: "mouseup", + filename: TEST_URL + ":60:29", + attributes: ["Bubbling"], + handler: + "function mouseupHandler(event) {\n" + + ' const output = document.getElementById("output");\n' + + ' output.textContent = "mouseup";\n' + + "}", + }, + ], + }, + // #noevents tests check that dynamically added events are properly displayed + // in the markupview + { + selector: "#noevents", + expected: [], + }, + { + selector: "#noevents", + async beforeTest(inspector) { + const nodeMutated = inspector.once("markupmutation"); + await SpecialPowers.spawn(gBrowser.selectedBrowser, [], () => + content.wrappedJSObject.addNoeventsClickHandler() + ); + await nodeMutated; + }, + expected: [ + { + type: "click", + filename: TEST_URL + ":76:35", + attributes: ["Bubbling"], + handler: + "function noeventsClickHandler(event) {\n" + + ' alert("noevents has an event listener");\n' + + "}", + }, + ], + }, + { + selector: "#noevents", + async beforeTest(inspector) { + const nodeMutated = inspector.once("markupmutation"); + await SpecialPowers.spawn(gBrowser.selectedBrowser, [], () => + content.wrappedJSObject.removeNoeventsClickHandler() + ); + await nodeMutated; + }, + expected: [], + }, + { + selector: "#DOM0", + expected: [ + { + type: "click", + filename: TEST_URL, + attributes: ["Bubbling"], + handler: "function onclick(event) {\n" + " alert('DOM0')\n" + "}", + }, + ], + }, + { + selector: "#handleevent", + expected: [ + { + type: "click", + filename: TEST_URL + ":71:29", + attributes: ["Bubbling"], + handler: "function(blah) {\n" + ' alert("handleEvent");\n' + "}", + }, + ], + }, +]; + +add_task(async function () { + await runEventPopupTests(TEST_URL, TEST_DATA); +}); |