| <!DOCTYPE html> |
| <html> |
| <body> |
| <script src="../../../resources/js-test-pre.js"></script> |
| <script> |
| |
| description("This test calls comparePoint on detached nodes. They should compare nodes when they're in the same detached tree and throw otherwise.") |
| |
| var detachedDiv = document.createElement('div'); |
| var spanInDetachedDiv1 = document.createElement('span'); |
| var spanInDetachedDiv2 = document.createElement('span'); |
| detachedDiv.appendChild(spanInDetachedDiv1); |
| detachedDiv.appendChild(spanInDetachedDiv2); |
| |
| var detachedP = document.createElement('p'); |
| var spanInDetachedP = document.createElement('span'); |
| detachedP.appendChild(spanInDetachedP); |
| |
| shouldBe("var range = new Range; range.setStart(detachedDiv, 0); range.comparePoint(detachedDiv, 0);", "0"); |
| shouldBe("var range = new Range; range.setStart(detachedDiv, 0); range.comparePoint(detachedDiv, 1);", "1"); |
| shouldBe("var range = new Range; range.setStart(detachedDiv, 2); range.comparePoint(detachedDiv, 1);", "-1"); |
| shouldBe("var range = new Range; range.setStart(spanInDetachedDiv1, 0); range.comparePoint(spanInDetachedDiv2, 0);", "1"); |
| shouldBe("var range = new Range; range.setStart(spanInDetachedDiv2, 0); range.comparePoint(spanInDetachedDiv1, 0);", "-1"); |
| shouldBe("var range = new Range; range.setStart(spanInDetachedDiv1, 0); range.comparePoint(spanInDetachedDiv1, 0);", "0"); |
| shouldThrowErrorName("var range = new Range; range.setStart(detachedDiv, 0); range.comparePoint(detachedP, 0);", "WrongDocumentError"); |
| shouldThrowErrorName("var range = new Range; range.setStart(spanInDetachedDiv1, 0); range.comparePoint(spanInDetachedP, 0);", "WrongDocumentError"); |
| |
| var successfullyParsed = true; |
| |
| </script> |
| <script src="../../../resources/js-test-post.js"></script> |
| </body> |
| </html> |