mirror of
https://github.com/servo/servo.git
synced 2025-08-12 08:55:32 +01:00
Update web-platform-tests to revision 4bba821de44da9ed47c2562f995a0da6eecc177b
This commit is contained in:
parent
af637640ae
commit
c8c377df9f
48 changed files with 697 additions and 8688 deletions
|
@ -0,0 +1,20 @@
|
|||
<!doctype html>
|
||||
<title>Range constructor test</title>
|
||||
<link rel="author" title="Aryeh Gregor" href=ayg@aryeh.name>
|
||||
<div id=log></div>
|
||||
<script src=/resources/testharness.js></script>
|
||||
<script src=/resources/testharnessreport.js></script>
|
||||
<script>
|
||||
"use strict";
|
||||
|
||||
test(function() {
|
||||
var range = new Range();
|
||||
assert_equals(range.startContainer, document, "startContainer");
|
||||
assert_equals(range.endContainer, document, "endContainer");
|
||||
assert_equals(range.startOffset, 0, "startOffset");
|
||||
assert_equals(range.endOffset, 0, "endOffset");
|
||||
assert_true(range.collapsed, "collapsed");
|
||||
assert_equals(range.commonAncestorContainer, document,
|
||||
"commonAncestorContainer");
|
||||
});
|
||||
</script>
|
|
@ -67,11 +67,13 @@ function myDeleteContents(range) {
|
|||
var originalEndOffset = range.endOffset;
|
||||
|
||||
// "If original start node and original end node are the same, and they are
|
||||
// a Text or Comment node, call deleteData(original start offset, original
|
||||
// end offset − original start offset) on that node, and abort these
|
||||
// steps."
|
||||
// a Text, ProcessingInstruction, or Comment node, replace data with node
|
||||
// original start node, offset original start offset, count original end
|
||||
// offset minus original start offset, and data the empty string, and then
|
||||
// terminate these steps"
|
||||
if (originalStartNode == originalEndNode
|
||||
&& (range.startContainer.nodeType == Node.TEXT_NODE
|
||||
|| range.startContainer.nodeType == Node.PROCESSING_INSTRUCTION_NODE
|
||||
|| range.startContainer.nodeType == Node.COMMENT_NODE)) {
|
||||
originalStartNode.deleteData(originalStartOffset, originalEndOffset - originalStartOffset);
|
||||
return;
|
||||
|
@ -120,10 +122,12 @@ function myDeleteContents(range) {
|
|||
newOffset = 1 + indexOf(referenceNode);
|
||||
}
|
||||
|
||||
// "If original start node is a Text or Comment node, run deleteData() on
|
||||
// it, with original start offset as the first argument and (length of
|
||||
// original start node − original start offset) as the second."
|
||||
// "If original start node is a Text, ProcessingInstruction, or Comment node,
|
||||
// replace data with node original start node, offset original start offset,
|
||||
// count original start node's length minus original start offset, data the
|
||||
// empty start"
|
||||
if (originalStartNode.nodeType == Node.TEXT_NODE
|
||||
|| originalStartNode.nodeType == Node.PROCESSING_INSTRUCTION_NODE
|
||||
|| originalStartNode.nodeType == Node.COMMENT_NODE) {
|
||||
originalStartNode.deleteData(originalStartOffset, nodeLength(originalStartNode) - originalStartOffset);
|
||||
}
|
||||
|
@ -134,9 +138,11 @@ function myDeleteContents(range) {
|
|||
nodesToRemove[i].parentNode.removeChild(nodesToRemove[i]);
|
||||
}
|
||||
|
||||
// "If original end node is a Text or Comment node, run deleteData(0,
|
||||
// original end offset) on it."
|
||||
// "If original end node is a Text, ProcessingInstruction, or Comment node,
|
||||
// replace data with node original end node, offset 0, count original end
|
||||
// offset, and data the empty string."
|
||||
if (originalEndNode.nodeType == Node.TEXT_NODE
|
||||
|| originalEndNode.nodeType == Node.PROCESSING_INSTRUCTION_NODE
|
||||
|| originalEndNode.nodeType == Node.COMMENT_NODE) {
|
||||
originalEndNode.deleteData(0, originalEndOffset);
|
||||
}
|
||||
|
|
|
@ -15,14 +15,6 @@ var testRangesCached = [];
|
|||
for (var i = 0; i < testNodes.length; i++) {
|
||||
var node = eval(testNodes[i]);
|
||||
|
||||
// "If the detached flag is set, throw an "InvalidStateError" exception and
|
||||
// terminate these steps."
|
||||
test(function() {
|
||||
var range = document.createRange();
|
||||
range.detach();
|
||||
assert_equals(range.intersectsNode(node), node === document);
|
||||
}, "Node " + i + " " + testNodes[i] + ", detached range");
|
||||
|
||||
for (var j = 0; j < testRanges.length; j++) {
|
||||
test(function() {
|
||||
if (testRangesCached[j] === undefined) {
|
||||
|
|
|
@ -17,14 +17,6 @@ testDiv.parentNode.removeChild(testDiv);
|
|||
|
||||
function mySurroundContents(range, newParent) {
|
||||
try {
|
||||
// "If the detached flag is set, throw an "InvalidStateError" exception
|
||||
// and terminate these steps."
|
||||
try {
|
||||
range.collapsed;
|
||||
} catch (e) {
|
||||
return "INVALID_STATE_ERR";
|
||||
}
|
||||
|
||||
// "If a non-Text node is partially contained in the context object,
|
||||
// throw a "InvalidStateError" exception and terminate these steps."
|
||||
var node = range.commonAncestorContainer;
|
||||
|
@ -118,8 +110,6 @@ function testSurroundContents(i, j) {
|
|||
var actualRoots = [];
|
||||
var expectedRoots = [];
|
||||
|
||||
var detached = false;
|
||||
|
||||
domTests[i][j].step(function() {
|
||||
restoreIframe(actualIframe, i, j);
|
||||
restoreIframe(expectedIframe, i, j);
|
||||
|
@ -129,12 +119,6 @@ function testSurroundContents(i, j) {
|
|||
actualNode = actualIframe.contentWindow.testNode;
|
||||
expectedNode = expectedIframe.contentWindow.testNode;
|
||||
|
||||
try {
|
||||
actualRange.collapsed;
|
||||
} catch (e) {
|
||||
detached = true;
|
||||
}
|
||||
|
||||
assert_equals(actualIframe.contentWindow.unexpectedException, null,
|
||||
"Unexpected exception thrown when setting up Range for actual surroundContents()");
|
||||
assert_equals(expectedIframe.contentWindow.unexpectedException, null,
|
||||
|
@ -160,15 +144,8 @@ function testSurroundContents(i, j) {
|
|||
// also the trees containing the moved nodes. These might not be the
|
||||
// same, if we're inserting a node from a detached tree or a different
|
||||
// document.
|
||||
//
|
||||
// Detached ranges are always in the contentDocument.
|
||||
if (detached) {
|
||||
actualRoots.push(actualIframe.contentDocument);
|
||||
expectedRoots.push(expectedIframe.contentDocument);
|
||||
} else {
|
||||
actualRoots.push(furthestAncestor(actualRange.startContainer));
|
||||
expectedRoots.push(furthestAncestor(expectedRange.startContainer));
|
||||
}
|
||||
actualRoots.push(furthestAncestor(actualRange.startContainer));
|
||||
expectedRoots.push(furthestAncestor(expectedRange.startContainer));
|
||||
|
||||
if (furthestAncestor(actualNode) != actualRoots[0]) {
|
||||
actualRoots.push(furthestAncestor(actualNode));
|
||||
|
@ -264,11 +241,6 @@ function testSurroundContents(i, j) {
|
|||
assertNodesEqual(actualRoots[k], expectedRoots[k], k ? "moved node's tree root" : "range's tree root");
|
||||
}
|
||||
|
||||
if (detached) {
|
||||
// No further tests we can do
|
||||
return;
|
||||
}
|
||||
|
||||
assert_equals(actualRange.startOffset, expectedRange.startOffset,
|
||||
"Unexpected startOffset after surroundContents()");
|
||||
assert_equals(actualRange.endOffset, expectedRange.endOffset,
|
||||
|
@ -300,8 +272,6 @@ function testSurroundContents(i, j) {
|
|||
positionTests[i][j].done();
|
||||
}
|
||||
|
||||
testRanges.unshift('"detached"');
|
||||
|
||||
var iStart = 0;
|
||||
var iStop = testRangesShort.length;
|
||||
var jStart = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue