diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /browser/base/content/test/webextensions/browser_permissions_pointerevent.js | |
parent | Initial commit. (diff) | |
download | firefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/base/content/test/webextensions/browser_permissions_pointerevent.js')
-rw-r--r-- | browser/base/content/test/webextensions/browser_permissions_pointerevent.js | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/browser/base/content/test/webextensions/browser_permissions_pointerevent.js b/browser/base/content/test/webextensions/browser_permissions_pointerevent.js new file mode 100644 index 0000000000..188aa8e3bf --- /dev/null +++ b/browser/base/content/test/webextensions/browser_permissions_pointerevent.js @@ -0,0 +1,53 @@ +/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* vim: set sts=2 sw=2 et tw=80: */ +"use strict"; + +add_task(async function test_pointerevent() { + async function contentScript() { + document.addEventListener("pointerdown", async e => { + browser.test.assertTrue(true, "Should receive pointerdown"); + e.preventDefault(); + }); + + document.addEventListener("mousedown", e => { + browser.test.assertTrue(true, "Should receive mousedown"); + }); + + document.addEventListener("mouseup", e => { + browser.test.assertTrue(true, "Should receive mouseup"); + }); + + document.addEventListener("pointerup", e => { + browser.test.assertTrue(true, "Should receive pointerup"); + browser.test.sendMessage("done"); + }); + browser.test.sendMessage("pageReady"); + } + + let extension = ExtensionTestUtils.loadExtension({ + background() { + browser.test.sendMessage("ready", browser.runtime.getURL("page.html")); + }, + files: { + "page.html": `<html><head><script src="page.js"></script></head></html>`, + "page.js": contentScript, + }, + }); + await extension.startup(); + let url = await extension.awaitMessage("ready"); + await BrowserTestUtils.withNewTab({ gBrowser, url }, async browser => { + await extension.awaitMessage("pageReady"); + await BrowserTestUtils.synthesizeMouseAtCenter( + "html", + { type: "mousedown", button: 0 }, + browser + ); + await BrowserTestUtils.synthesizeMouseAtCenter( + "html", + { type: "mouseup", button: 0 }, + browser + ); + await extension.awaitMessage("done"); + }); + await extension.unload(); +}); |