| <html><body><script src="../../resources/js-test.js"></script><script> |
| |
| description("Test the contains function that checks if a range contains a boundary point.") |
| |
| function range(startContainer, startOffset, endContainer, endOffset) |
| { |
| return new StaticRange({ startContainer: startContainer, startOffset: startOffset, endContainer: endContainer, endOffset: endOffset }) |
| } |
| |
| function contentsRange(node) |
| { |
| return range(node, 0, node, node.childNodes.length) |
| } |
| |
| let documentElement = document.documentElement; |
| let body = document.body; |
| |
| shouldBe("body.childNodes.length", "4") |
| |
| shouldBeTrue("internals.rangeContainsBoundaryPoint(contentsRange(document), document, 0, 'ComposedTree')") |
| shouldBeTrue("internals.rangeContainsBoundaryPoint(contentsRange(document), document, 1, 'ComposedTree')") |
| shouldBeFalse("internals.rangeContainsBoundaryPoint(contentsRange(document), document, 2, 'ComposedTree')") |
| shouldBeTrue("internals.rangeContainsBoundaryPoint(contentsRange(document), body, 0, 'ComposedTree')"); |
| shouldBeTrue("internals.rangeContainsBoundaryPoint(contentsRange(document), body, 1, 'ComposedTree')"); |
| shouldBeTrue("internals.rangeContainsBoundaryPoint(contentsRange(document), body, 10, 'ComposedTree')"); |
| shouldBeFalse("internals.rangeContainsBoundaryPoint(range(document, 0, documentElement, 0), body, 0, 'ComposedTree')"); |
| shouldBeTrue("internals.rangeContainsBoundaryPoint(range(document, 0, body, 0), body, 0, 'ComposedTree')"); |
| |
| let a = document.createElement("div") |
| shouldBeFalse("internals.rangeContainsBoundaryPoint(contentsRange(document), a, 0, 'ComposedTree')") |
| shouldBeFalse("internals.rangeContainsBoundaryPoint(contentsRange(body), a, 0, 'ComposedTree')") |
| |
| body.appendChild(a) |
| shouldBeTrue("internals.rangeContainsBoundaryPoint(contentsRange(document), a, 0, 'ComposedTree')") |
| shouldBeTrue("internals.rangeContainsBoundaryPoint(range(document, 0, a, 0), a, 0, 'ComposedTree')") |
| shouldBeFalse("internals.rangeContainsBoundaryPoint(range(document, 0, body, 0), a, 0, 'ComposedTree')") |
| shouldBeTrue("internals.rangeContainsBoundaryPoint(range(document, 0, body, 5), a, 0, 'ComposedTree')") |
| shouldBeFalse("internals.rangeContainsBoundaryPoint(range(body, 5, document, 1), a, 0, 'ComposedTree')") |
| shouldBeTrue("internals.rangeContainsBoundaryPoint(range(body, 0, document, 1), a, 0, 'ComposedTree')") |
| |
| let b = document.createElement("div") |
| body.appendChild(b) |
| |
| let c = document.createElement("div") |
| b.appendChild(c) |
| |
| let d = document.createElement("div") |
| a.appendChild(d) |
| |
| let e = document.createElement("div") |
| let f = document.createElement("div") |
| e.appendChild(f) |
| shouldBeFalse("internals.rangeContainsBoundaryPoint(contentsRange(body), f, 0, 'ComposedTree')") |
| |
| let g = document.createElement("textarea"); |
| c.appendChild(g) |
| let h = internals.ensureUserAgentShadowRoot(g).firstChild |
| shouldBeTrue("internals.rangeContainsBoundaryPoint(contentsRange(body), h, 0, 'ComposedTree')") |
| |
| </script> |
| </body></html> |