diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /layout/base/tests/chrome/test_getClientRectsAndTexts.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-upstream.tar.xz firefox-esr-upstream.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'layout/base/tests/chrome/test_getClientRectsAndTexts.html')
-rw-r--r-- | layout/base/tests/chrome/test_getClientRectsAndTexts.html | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/layout/base/tests/chrome/test_getClientRectsAndTexts.html b/layout/base/tests/chrome/test_getClientRectsAndTexts.html new file mode 100644 index 0000000000..d2fdde2197 --- /dev/null +++ b/layout/base/tests/chrome/test_getClientRectsAndTexts.html @@ -0,0 +1,80 @@ +<!DOCTYPE HTML> +<html> +<head> + <meta charset="utf-8"> + <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/> +</head> +<body> + +<div id="div1" style="width:200px">Here is some text that <a href="#">will wrap</a> in <a href="#">this small</a>-ish container.</div> +<div id="div2">Into another <a href="#">container</a></div> +<div id="div3">A very <span>deep <span>deep <span>deep</span></span></span> bit of text.</div> + +<script> +if (typeof(is) == "undefined") { + var is = function(a, b, m) { + if(a != b) { + window.console.log("Expected '" + b + "' but got '" + a + "': " + m); + } + }; +} + +if (typeof(todo_is) == "undefined") { + var todo_is = is; +} + +function testRangeTexts(startNode, startOffset, endNode, endOffset, expectedText, todo) { + let r = new Range(); + r.setStart(startNode, startOffset); + r.setEnd(endNode, endOffset); + + let texts = r.getClientRectsAndTexts().textList; + let concatText = ""; + for (let i = 0; i < texts.length; i++) { + concatText += texts[i]; + } + + if (todo) { + todo_is(concatText, expectedText, "Text matches."); + } else { + is(concatText, expectedText, "Text matches."); + } +} + +let d1c1 = div1.firstChild; +let d1c2 = d1c1.nextSibling; +let d1c3 = d1c2.nextSibling; +let d1c4 = d1c3.nextSibling; +let d1c5 = d1c4.nextSibling; + +let link1 = d1c2.firstChild; +let link2 = d1c4.firstChild; + +let d2c1 = div2.firstChild; +let d2c2 = d2c1.nextSibling; + +let link3 = d2c2.firstChild; + +let d3c1 = div3.firstChild; +let d3c2 = d3c1.nextSibling; +let d3c3 = d3c2.nextSibling; + +let data = [ + [d1c1, 0, d1c1, 0, ""], + [d1c1, 0, d1c1, 4, "Here"], + [d1c1, 4, d1c1, 7, " is"], + [d1c1, 22, link1, 0, " "], + [d1c1, 22, link1, 1, " w"], + [d1c1, 22, d1c3, 1, " will wrap "], + [link1, 2, link2, 3, "ll wrap in thi"], + [link2, 5, link3, 3, "small-ish container.Into another con"], + [d3c1, 3, d3c3, 4, "ery deep deep deep bit"], +]; + +data.forEach(function (d) { testRangeTexts.apply(null, d); }); + +</script> + +</body> +</html> |