diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:33 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:33 +0000 |
commit | 086c044dc34dfc0f74fbe41f4ecb402b2cd34884 (patch) | |
tree | a4f824bd33cb075dd5aa3eb5a0a94af221bbe83a /testing/web-platform/tests/html/rendering/bidi-rendering/unicode-bidi-ua-rules.html | |
parent | Adding debian version 124.0.1-1. (diff) | |
download | firefox-086c044dc34dfc0f74fbe41f4ecb402b2cd34884.tar.xz firefox-086c044dc34dfc0f74fbe41f4ecb402b2cd34884.zip |
Merging upstream version 125.0.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/html/rendering/bidi-rendering/unicode-bidi-ua-rules.html')
-rw-r--r-- | testing/web-platform/tests/html/rendering/bidi-rendering/unicode-bidi-ua-rules.html | 88 |
1 files changed, 85 insertions, 3 deletions
diff --git a/testing/web-platform/tests/html/rendering/bidi-rendering/unicode-bidi-ua-rules.html b/testing/web-platform/tests/html/rendering/bidi-rendering/unicode-bidi-ua-rules.html index 78bfb80e6f..00f4c96317 100644 --- a/testing/web-platform/tests/html/rendering/bidi-rendering/unicode-bidi-ua-rules.html +++ b/testing/web-platform/tests/html/rendering/bidi-rendering/unicode-bidi-ua-rules.html @@ -4,22 +4,104 @@ <link rel="help" href="https://html.spec.whatwg.org/multipage/rendering.html#bidi-rendering"> <script src=/resources/testharness.js></script> <script src=/resources/testharnessreport.js></script> +<script src='../../resources/common.js'></script> <body> <script> - const elements = ['address', 'blockquote', 'center', 'div', 'figure', + function getUnicodeBidi(el) { + return window.getComputedStyle(el, "").unicodeBidi; + } + + // These elements should have `unicode-bidi: isolate` in the UA stylesheet: + const isolateElements = ['address', 'blockquote', 'center', 'div', 'figure', 'figcaption', 'footer', 'form', 'header', 'hr', 'legend', 'listing', 'main', 'p', 'plaintext', 'pre', 'summary', 'xmp', 'article', 'aside', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'hgroup', 'nav', 'section', 'search', 'table', 'caption', 'colgroup', 'col', 'thead', 'tbody', 'tfoot', 'tr', 'td', 'th', 'dir', 'dd', 'dl', 'dt', 'menu', 'ol', 'ul', 'li', 'bdi', 'output']; - for(let tagname of elements) { + const allButSeparateTests = HTML5_ELEMENTS.filter(el => (!['bdo','input','textarea','pre'].includes(el))); + for(let tagname of allButSeparateTests) { + test((t) => { + const element = document.createElement(tagname); + t.add_cleanup(() => element.remove()); + document.body.appendChild(element); + const expectation = isolateElements.includes(tagname) ? 'isolate' : 'normal'; + assert_equals(getUnicodeBidi(element),expectation); + + element.setAttribute('dir','ltr'); + assert_equals(getUnicodeBidi(element),'isolate','with dir=ltr'); + element.setAttribute('dir','LtR'); + assert_equals(getUnicodeBidi(element),'isolate','with dir=LtR (case insensitive)'); + element.setAttribute('dir','rtl'); + assert_equals(getUnicodeBidi(element),'isolate','with dir=rtl'); + element.setAttribute('dir','auto'); + assert_equals(getUnicodeBidi(element),'isolate','with dir=auto'); + element.setAttribute('dir','INVALID'); + assert_equals(getUnicodeBidi(element),expectation,'invalid dir value goes back to normal defaults'); + },`UA stylesheet rule for unicode-bidi, for <${tagname}>`); + } + + test((t) => { + const element = document.createElement('bdo'); + t.add_cleanup(() => element.remove()); + document.body.appendChild(element); + assert_equals(getUnicodeBidi(element),'isolate-override'); + element.setAttribute('dir','ltr'); + assert_equals(getUnicodeBidi(element),'isolate-override','with dir=ltr'); + element.setAttribute('dir','LtR'); + assert_equals(getUnicodeBidi(element),'isolate-override','with dir=LtR (case insensitive)'); + element.setAttribute('dir','rtl'); + assert_equals(getUnicodeBidi(element),'isolate-override','with dir=rtl'); + element.setAttribute('dir','auto'); + assert_equals(getUnicodeBidi(element),'isolate-override','with dir=auto'); + element.setAttribute('dir','INVALID'); + assert_equals(getUnicodeBidi(element),'isolate-override','invalid dir value'); + },`UA stylesheet rule for unicode-bidi, for <bdo>`); + + const shouldBePlaintext = ['search','tel','url','email']; + for(let type of HTML5_INPUT_TYPES) { + test((t) => { + const element = document.createElement('input'); + t.add_cleanup(() => element.remove()); + element.type = type; + document.body.appendChild(element); + const autoExpectation = shouldBePlaintext.includes(type) ? 'plaintext' : 'isolate'; + assert_equals(getUnicodeBidi(element),'normal'); + element.setAttribute('dir','ltr'); + assert_equals(getUnicodeBidi(element),'isolate','with dir=ltr'); + element.setAttribute('dir','LtR'); + assert_equals(getUnicodeBidi(element),'isolate','with dir=LtR (case insensitive)'); + element.setAttribute('dir','rtl'); + assert_equals(getUnicodeBidi(element),'isolate','with dir=rtl'); + element.setAttribute('dir','auto'); + assert_equals(getUnicodeBidi(element),autoExpectation,'with dir=auto'); + element.setAttribute('dir','AuTo'); + assert_equals(getUnicodeBidi(element),autoExpectation,'with dir=auto (case insensitive)'); + element.setAttribute('dir','INVALID'); + assert_equals(getUnicodeBidi(element),'normal','invalid dir value'); + },`UA stylesheet rule for unicode-bidi, for <input type=${type}>`); + } + + for(let tagname of ['textarea','pre']) { test((t) => { const element = document.createElement(tagname); t.add_cleanup(() => element.remove()); document.body.appendChild(element); - assert_equals(window.getComputedStyle(element, "").unicodeBidi,'isolate'); + const expectation = tagname === 'textarea' ? 'normal' : 'isolate'; + assert_equals(getUnicodeBidi(element),expectation); + element.setAttribute('dir','ltr'); + assert_equals(getUnicodeBidi(element),'isolate','with dir=ltr'); + element.setAttribute('dir','LtR'); + assert_equals(getUnicodeBidi(element),'isolate','with dir=LtR (case insensitive)'); + element.setAttribute('dir','rtl'); + assert_equals(getUnicodeBidi(element),'isolate','with dir=rtl'); + element.setAttribute('dir','auto'); + assert_equals(getUnicodeBidi(element),'plaintext','with dir=auto'); + element.setAttribute('dir','AuTo'); + assert_equals(getUnicodeBidi(element),'plaintext','with dir=auto (case insensitive)'); + element.setAttribute('dir','INVALID'); + assert_equals(getUnicodeBidi(element),expectation,'invalid dir value'); },`UA stylesheet rule for unicode-bidi, for <${tagname}>`); } </script> |