diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:47:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:47:29 +0000 |
commit | 0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d (patch) | |
tree | a31f07c9bcca9d56ce61e9a1ffd30ef350d513aa /testing/web-platform/tests/css/css-writing-modes/tools | |
parent | Initial commit. (diff) | |
download | firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.tar.xz firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.zip |
Adding upstream version 115.8.0esr.upstream/115.8.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/css/css-writing-modes/tools')
-rwxr-xr-x | testing/web-platform/tests/css/css-writing-modes/tools/generators/generate.py | 86 | ||||
-rw-r--r-- | testing/web-platform/tests/css/css-writing-modes/tools/generators/template.html | 83 |
2 files changed, 169 insertions, 0 deletions
diff --git a/testing/web-platform/tests/css/css-writing-modes/tools/generators/generate.py b/testing/web-platform/tests/css/css-writing-modes/tools/generators/generate.py new file mode 100755 index 0000000000..6d54eebc05 --- /dev/null +++ b/testing/web-platform/tests/css/css-writing-modes/tools/generators/generate.py @@ -0,0 +1,86 @@ +#!/usr/bin/env python3 +import os +import string + +from typing import List, Tuple + +test_template = """<h3>{number}: {title}</h3> +<div class="test"> + {html} +</div>""" + + +def generate_test_list() -> List[Tuple[str, str]]: + test_list = []; + outers = [ + ["inline-block", '<div class="inline-block">', '</div><span class="next">ZZ</span>'], + ["float", '<div class="float">', '</div><span class="next">ZZ</span>'], + ["table-cell", '<table><tr><td>', '</td><td class="next">ZZ</td></tr></table>']]; + middles = [ + None, + ["inline-block", '<div class="inline-block">', '</div>']]; + targets = [ + ["block", '<div class="target">HH</div>'], + ["inline", '<span class="target">HH</span>'], + ["block with borders", '<div class="target border">HHH</div>'], + ["inline with borders", '<span class="target border">HHH</span>']]; + for outer in outers: + for middle in middles: + for target in targets: + title = target[0]; + html = target[1]; + if middle is not None: + title += " in " + middle[0]; + html = middle[1] + html + middle[2]; + title = "Shrink-to-fit " + outer[0] + " with a child of orthogonal " + title; + html = outer[1] + html + outer[2]; + test_list.append((title, html)); + return test_list + + +def read_template() -> str: + with open("template.html") as f: + return f.read() + + +def main(): + template = read_template() + test_list = generate_test_list() + + dest_dir = os.path.abspath( + os.path.join(os.path.dirname(os.path.abspath(__file__)), + os.path.pardir, + os.path.pardir)) + + for index in range(-1, len(test_list)): + if index == -1: + offset = 0 + suffix = "" + tests = test_list + title = "Shrink-to-fit with orthogonal children" + flags = " combo" + else: + offset = index + suffix = string.ascii_letters[index] + tests = [test_list[index]] + title = tests[0][0] + flags = "" + + filename = f"orthogonal-parent-shrink-to-fit-001{suffix}.html" + + tests_data = [] + for idx, (test_title, html) in enumerate(tests): + number = offset + idx + 1 + tests_data.append(test_template.format(number=number, + title=test_title, + html=html)) + + output = template.replace("{{title}}", title) + output = output.replace("{{flags}}", flags) + output = output.replace("{{tests}}", "\n".join(tests_data)) + with open(os.path.join(dest_dir, filename), "w") as f: + f.write(output) + + +if __name__ == "__main__": + main() diff --git a/testing/web-platform/tests/css/css-writing-modes/tools/generators/template.html b/testing/web-platform/tests/css/css-writing-modes/tools/generators/template.html new file mode 100644 index 0000000000..74fc185232 --- /dev/null +++ b/testing/web-platform/tests/css/css-writing-modes/tools/generators/template.html @@ -0,0 +1,83 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>CSS Writing Modes Test: {{title}}</title> +<link rel="help" href="http://www.w3.org/TR/css-writing-modes-3/#orthogonal-flows" title="7.3. Orthogonal Flows"> +<meta name="assert" content="{{title}}"> +<meta name="flags" content="ahem dom{{flags}}"> +<link rel="author" title="Koji Ishii" href="mailto:kojiishi@gmail.com"> +<link rel="reviewer" title="GĂ©rard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/"> <!-- 2015-12-23 --> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<link rel="stylesheet" type="text/css" href="/fonts/ahem.css" /> +<style> +.test { + border:thin solid; + font:20px/1 Ahem; +} +.target { + color:blue; + height:3em; /* height: 3em is not required. IE11 and Edge12 compute height to ICB height if + not set. We want the test to focus exclusively on shrink-to-fit algorithm. */ + writing-mode:vertical-rl; +} +.border { + border-right:blue solid .5em; +} +.next { + color:orange; +} +.inline-block { + display:inline-block; +} +.float { + float:left; +} +h3 { + clear:both; +} +h3.fail { + color:red; +} +table { + border-spacing:0px; +} +td { + padding:0px; +} +</style> +<div id="log"></div> +<div id="container"> +<p>Test passes if the X-position of the <b>left</b> edge of the orange box and the <b>right</b> edge of the blue box are the same. +<p>If script is enabled, there should be one or more PASS and no FAIL. +{{tests}} +</div> +<script> +if (window.location.search == "?wait") { + console.log("Sleeping 5 secs for debug"); + setup({explicit_done:true}); + window.setTimeout(run, 5000); +} else { + run(); +} + +function run() { + Array.prototype.forEach.call(document.querySelectorAll(".test"), function (node) { + var title = node.previousElementSibling.textContent; + test(function () { + try { + var targetNode = node.querySelector(".target"); + var fontSize = parseFloat(getComputedStyle(targetNode).fontSize); + var targetBounds = targetNode.getBoundingClientRect(); + assert_less_than_equal(targetBounds.width, fontSize * 2.01, "writing-mode is vertical") + var nextNode = node.querySelector(".next"); + var nextBounds = nextNode.getBoundingClientRect(); + assert_equals(nextBounds.left - targetBounds.right, 0, "the left edge of the orange box touches the right edge of the blue box"); + } catch (e) { + node.previousElementSibling.classList.add("fail"); + throw e; + } + }, title); + }); + done(); +} +</script> |