summaryrefslogtreecommitdiffstats
path: root/dom/events/test/pointerevents/pointerevent_utils.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /dom/events/test/pointerevents/pointerevent_utils.js
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/events/test/pointerevents/pointerevent_utils.js')
-rw-r--r--dom/events/test/pointerevents/pointerevent_utils.js60
1 files changed, 60 insertions, 0 deletions
diff --git a/dom/events/test/pointerevents/pointerevent_utils.js b/dom/events/test/pointerevents/pointerevent_utils.js
new file mode 100644
index 0000000000..ac5eaf61a1
--- /dev/null
+++ b/dom/events/test/pointerevents/pointerevent_utils.js
@@ -0,0 +1,60 @@
+// Get test filename for page being run in popup so errors are more useful
+var testName = location.pathname.split("/").pop();
+
+// Wrap test functions and pass to parent window
+window.ok = function (a, msg) {
+ opener.ok(a, testName + ": " + msg);
+};
+
+window.is = function (a, b, msg) {
+ opener.is(a, b, testName + ": " + msg);
+};
+
+window.isnot = function (a, b, msg) {
+ opener.isnot(a, b, testName + ": " + msg);
+};
+
+window.todo = function (a, msg) {
+ opener.todo(a, testName + ": " + msg);
+};
+
+window.todo_is = function (a, b, msg) {
+ opener.todo_is(a, b, testName + ": " + msg);
+};
+
+window.todo_isnot = function (a, b, msg) {
+ opener.todo_isnot(a, b, testName + ": " + msg);
+};
+
+window.info = function (msg) {
+ opener.info(testName + ": " + msg);
+};
+
+// Override bits of SimpleTest so test files work stand-alone
+var SimpleTest = SimpleTest || {};
+
+SimpleTest.waitForExplicitFinish = function () {
+ dump("[POINTEREVENT] Starting " + testName + "\n");
+};
+
+SimpleTest.finish = function () {
+ dump("[POINTEREVENT] Finishing " + testName + "\n");
+ opener.nextTest();
+};
+
+// Utility functions
+function waitForEvent(aTarget, aEvent, aCallback) {
+ return new Promise(aResolve => {
+ aTarget.addEventListener(
+ aEvent,
+ e => {
+ ok(true, `got ${e.type} event on ${e.target.id}`);
+ if (aCallback) {
+ aCallback(e);
+ }
+ aResolve();
+ },
+ { once: true }
+ );
+ });
+}