summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/inert/inert-inlines.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/inert/inert-inlines.html
parentInitial commit. (diff)
downloadfirefox-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 'testing/web-platform/tests/inert/inert-inlines.html')
-rw-r--r--testing/web-platform/tests/inert/inert-inlines.html55
1 files changed, 55 insertions, 0 deletions
diff --git a/testing/web-platform/tests/inert/inert-inlines.html b/testing/web-platform/tests/inert/inert-inlines.html
new file mode 100644
index 0000000000..b056c6495d
--- /dev/null
+++ b/testing/web-platform/tests/inert/inert-inlines.html
@@ -0,0 +1,55 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8" />
+ <title>inert inlines</title>
+ <link rel="author" title="Alice Boxhall" href="aboxhall@chromium.org">
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ <script src="/resources/testdriver.js"></script>
+ <script src="/resources/testdriver-vendor.js"></script>
+ </head>
+<body>
+<a inert id="a" href="javascript:void(0)">Click me</a>
+<button inert id="button">Click me</button>
+<div inert id="div" style="background-color: blue; width: 50px; height: 50px">Click me</div>
+<span inert id="span">Click me</span>
+<script>
+function eventFiredOnInertElement(e) {
+ e.target.style.background = 'red';
+ inertElementFiredOn = true;
+}
+
+inertElements = ['a', 'button', 'div', 'span']
+inertElements.forEach(function(id) {
+ element = document.getElementById(id);
+ element.addEventListener('click', eventFiredOnInertElement);
+ element.addEventListener('mousemove', eventFiredOnInertElement);
+});
+
+document.addEventListener('click', function(e) {
+ document.firedOn = true;
+});
+
+promise_test(async () => {
+ for (let id of inertElements) {
+ var element = document.getElementById(id);
+ inertElementFiredOn = false;
+ document.firedOn = false;
+ try {
+ await test_driver.click(element);
+ assert_false(inertElementFiredOn, 'no event should be fired on ' + id);
+ assert_true(document.firedOn, 'event should be fired on document instead of ' + id);
+ } catch (e) {
+ // test driver detects inert elements as unclickable
+ // and throws an error
+ assert_false(inertElementFiredOn, 'no event should be fired on ' + id);
+ }
+ }
+}, 'Tests that inert inlines do not receive mouse events. ' +
+ 'To test manually, click on all the "Click me"s. The test ' +
+ 'fails if you see red.');
+
+</script>
+</body>
+</html>