diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /dom/base/test/test_bug366946.html | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/base/test/test_bug366946.html')
-rw-r--r-- | dom/base/test/test_bug366946.html | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/dom/base/test/test_bug366946.html b/dom/base/test/test_bug366946.html new file mode 100644 index 0000000000..a8173828dc --- /dev/null +++ b/dom/base/test/test_bug366946.html @@ -0,0 +1,79 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=366946 +--> +<head> + <title>Test for Bug 366946</title> + <script src="/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> +</head> +<body> +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=366946">Mozilla Bug 366946</a> +<p id="display"></p> +<div id="content" style="display: none"> + <div id="1"></div> + <div id="2"></div> + <div id="3"></div> +</div> +<pre id="test"> +<script class="testbody" type="text/javascript"> + /** Test for Bug 366946 **/ + SimpleTest.waitForExplicitFinish(); + + addLoadEvent(function() { + var doc1 = document; + + // Set up a new document. + var doc2 = document.implementation.createDocument('', '', null); + + // Copy some nodes into doc2 + var node1 = doc2.importNode(doc1.getElementById('1'), false); + var node2 = doc2.importNode(doc1.getElementById('1'), false); + node1.appendChild(node2); + doc2.appendChild(node1); + + // Create two ranges in doc1 to compare. + var range1 = doc1.createRange(); + range1.setStart(doc1.getElementById('1'), 0); + range1.setEnd(doc1.getElementById('2'), 0); + + var range2 = doc1.createRange(); + range2.setStart(doc1.getElementById('2'), 0); + range2.setEnd(doc1.getElementById('3'), 0); + + // Create a range in doc2. + var range3 = doc2.createRange(); + range3.setStart(node1, 0); + range3.setEnd(node2, 0); + + // Compare range1 and range2: Should return 1. + try { + var result1 = range2.compareBoundaryPoints(Range.START_TO_START, range1); + } + catch (ex) { + } + ok(result1 === 1, "range1 and range2 are compared correctly."); + + // Compare range1 and range3: Should throw DOMException WRONG_DOCUMENT_ERR. + try { + var result2 = range3.compareBoundaryPoints(Range.START_TO_START, range1); + } + catch (ex) { + var error = ex.name; + var errorCode = ex.code; + } + + ok(error == "WrongDocumentError", + "The WrongDocumentError exception thrown when comparing ranges from " + + "different documents "); + ok(errorCode == DOMException.WRONG_DOCUMENT_ERR, + "The exception thrown when comparing ranges from different documents " + + "has the code DOMException.WRONG_DOCUMENT_ERR"); + ok(result2 === undefined, "range1 and range3 couldn't be compared as expected."); + SimpleTest.finish(); + }); +</script> +</pre> +</body> +</html> |