summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/editing/dnd/the-draggable-attribute
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/html/editing/dnd/the-draggable-attribute
parentInitial commit. (diff)
downloadfirefox-upstream.tar.xz
firefox-upstream.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/html/editing/dnd/the-draggable-attribute')
-rw-r--r--testing/web-platform/tests/html/editing/dnd/the-draggable-attribute/draggable-enumerated-ascii-case-insensitive.html24
-rw-r--r--testing/web-platform/tests/html/editing/dnd/the-draggable-attribute/draggable_attribute.html123
2 files changed, 147 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/editing/dnd/the-draggable-attribute/draggable-enumerated-ascii-case-insensitive.html b/testing/web-platform/tests/html/editing/dnd/the-draggable-attribute/draggable-enumerated-ascii-case-insensitive.html
new file mode 100644
index 0000000000..8c33a6c25b
--- /dev/null
+++ b/testing/web-platform/tests/html/editing/dnd/the-draggable-attribute/draggable-enumerated-ascii-case-insensitive.html
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<link rel="help" href="https://html.spec.whatwg.org/#the-draggable-attribute">
+<link rel="help" href="https://html.spec.whatwg.org/#enumerated-attribute">
+<meta name="assert" content="@draggable values are ASCII case-insensitive">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<!--
+ We use <img> elements here so the invalid value default (auto) can be
+ distinguished from false through the IDL attribute. Most other elements
+ return false from the IDL attribute for the auto state too.
+-->
+<img draggable="false">
+<img draggable="FaLsE">
+<img draggable="falſe">
+<script>
+const img = document.querySelectorAll("img");
+
+test(() => {
+ assert_equals(img[0].draggable, false, "lowercase valid");
+ assert_equals(img[1].draggable, false, "mixed case valid");
+ assert_equals(img[2].draggable, true, "non-ASCII invalid");
+}, "keyword false");
+</script>
diff --git a/testing/web-platform/tests/html/editing/dnd/the-draggable-attribute/draggable_attribute.html b/testing/web-platform/tests/html/editing/dnd/the-draggable-attribute/draggable_attribute.html
new file mode 100644
index 0000000000..cd9073e105
--- /dev/null
+++ b/testing/web-platform/tests/html/editing/dnd/the-draggable-attribute/draggable_attribute.html
@@ -0,0 +1,123 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset='utf-8'>
+ <title>HTML Test: draggable_attribute</title>
+ <link rel='author' title='Intel' href='http://www.intel.com'>
+ <link rel='help' href='https://html.spec.whatwg.org/multipage/#the-draggable-attribute'>
+ <script src='/resources/testharness.js'></script>
+ <script src='/resources/testharnessreport.js'></script>
+ <script src='/html/semantics/interfaces.js'></script>
+ </head>
+
+ <body>
+ <div id='log'> </div>
+
+ <script>
+ elements.forEach(function(a) {
+ test(function() {
+ var eElement = document.createElement(a[0]);
+ assert_inherits(eElement, 'draggable', 'Element ' + a[0] +' should have draggable property');
+ }, 'Element ' + a[0] +' should have draggable property');
+ });
+
+ function run_test(element, element_name, exp) {
+ if (exp) {
+ assert_true(element.draggable, 'Element ' + element_name +' should be draggable');
+ } else {
+ assert_false(element.draggable, 'Element ' + element_name +' should not be draggable');
+ }
+ }
+
+ function run_idl_test(element, element_name, exp) {
+ if (exp) {
+ assert_equals(element.getAttribute('draggable'), 'true', 'Element ' + element_name +' should be draggable');
+ } else {
+ assert_equals(element.getAttribute('draggable'), 'false', 'Element ' + element_name +' should not be draggable');
+ }
+ }
+
+ elements.forEach(function(a) {
+
+ test(function() {
+ //Default values for elements
+ //If the element is an img element, or, if the element is an a element with an href content attribute,
+ //the draggable IDL attribute must return true.
+ var eElement = document.createElement(a[0]);
+ switch (a[0]) {
+ case 'a':
+ eElement.setAttribute('href', 'http://w3.org');
+ run_test(eElement, 'a', true);
+ break;
+ case 'img':
+ run_test(eElement, 'img', true);
+ break;
+ default:
+ run_test(eElement, a[0], false);
+ }
+
+ //If an element's draggable content attribute has the state true,
+ //the draggable IDL attribute must return true.
+ eElement.setAttribute('draggable', 'true');
+ run_test(eElement, a[0] + ' draggable=\'true\'', true);
+
+ //If an element's draggable content attribute has the state false,
+ //the draggable IDL attribute must return false.
+ eElement.setAttribute('draggable', 'false');
+ run_test(eElement, a[0] + ' draggable=\'false\'', false);
+
+ //auto values for elements
+ //The element's draggable content attribute has the state auto.
+ //If the element is an img element, or, if the element is an a element with an href content attribute,
+ //the draggable IDL attribute must return true.
+ switch (a[0]) {
+ case 'a':
+ eElement.setAttribute('href', 'http://w3.org');
+ eElement.setAttribute('draggable', 'auto');
+ run_test(eElement, 'Element ' + 'a' + ' draggable=\'auto\'', true);
+ break;
+ case 'img':
+ eElement.setAttribute('draggable', 'auto');
+ run_test(eElement, 'Element ' + 'img' + ' draggable=\'auto\'', true);
+ break;
+ default:
+ run_test(eElement, 'Element ' + a[0] + ' draggable=\'auto\'', false);
+ }
+
+ //Foo values for elements
+ //The element's draggable content attribute value is not enumerated (true, false, auto) but unexpected.
+ //Fallback to defaults
+ switch (a[0]) {
+ case 'a':
+ eElement.setAttribute('href', 'http://w3.org');
+ eElement.setAttribute('draggable', 'foo');
+ run_test(eElement, 'Element ' + 'a' + ' draggable=\'foo\'', true);
+ break;
+ case 'img':
+ eElement.setAttribute('draggable', 'foo');
+ run_test(eElement, 'Element ' + 'img' + ' draggable=\'foo\'', true);
+ break;
+ default:
+ run_test(eElement, 'Element ' + a[0] + ' draggable=\'foo\'', false);
+ }
+
+ //An element with a draggable attribute should also have a title attribute
+ //that names the element for the purpose of non-visual interactions.
+ eElement.setAttribute('title', 'foo as title value');
+ assert_equals(typeof eElement.title, 'string', '<' + a[0] + '> draggable block has title attribute');
+
+ //If the draggable IDL attribute is set to the value false,
+ //the draggable content attribute must be set to the literal value false.
+ eElement.draggable = false;
+ run_idl_test(eElement, a[0] + '.getAttribute(\'draggable\') is \'false\'', false);
+
+ //If the draggable IDL attribute is set to the value true,
+ //the draggable content attribute must be set to the literal value true.
+ eElement.draggable = true;
+ run_idl_test(eElement, a[0] + '.getAttribute(\'draggable\') is \'true\'', true);
+ }, 'Element ' + a[0] +' draggable attribute test');
+
+ });
+ </script>
+ </body>
+</html>