Update web-platform-tests to revision 4bba821de44da9ed47c2562f995a0da6eecc177b

This commit is contained in:
Ms2ger 2015-10-12 17:01:10 +02:00
parent af637640ae
commit c8c377df9f
48 changed files with 697 additions and 8688 deletions

View file

@ -571,14 +571,6 @@ function indexOf(node) {
* a spec bug.
*/
function myExtractContents(range) {
// "If the context object's detached flag is set, raise an
// INVALID_STATE_ERR exception and abort these steps."
try {
range.collapsed;
} catch (e) {
return "INVALID_STATE_ERR";
}
// "Let frag be a new DocumentFragment whose ownerDocument is the same as
// the ownerDocument of the context object's start node."
var ownerDoc = range.startContainer.nodeType == Node.DOCUMENT_NODE
@ -601,10 +593,11 @@ function myExtractContents(range) {
var originalEndNode = range.endContainer;
var originalEndOffset = range.endOffset;
// "If original start node and original end node are the same, and they are
// a Text or Comment node:"
// "If original start node is original end node, and they are a Text,
// ProcessingInstruction, or Comment node:"
if (range.startContainer == range.endContainer
&& (range.startContainer.nodeType == Node.TEXT_NODE
|| range.startContainer.nodeType == Node.PROCESSING_INSTRUCTION_NODE
|| range.startContainer.nodeType == Node.COMMENT_NODE)) {
// "Let clone be the result of calling cloneNode(false) on original
// start node."
@ -716,9 +709,11 @@ function myExtractContents(range) {
newOffset = 1 + indexOf(referenceNode);
}
// "If first partially contained child is a Text or Comment node:"
// "If first partially contained child is a Text, ProcessingInstruction, or
// Comment node:"
if (firstPartiallyContainedChild
&& (firstPartiallyContainedChild.nodeType == Node.TEXT_NODE
|| firstPartiallyContainedChild.nodeType == Node.PROCESSING_INSTRUCTION_NODE
|| firstPartiallyContainedChild.nodeType == Node.COMMENT_NODE)) {
// "Let clone be the result of calling cloneNode(false) on original
// start node."
@ -773,9 +768,11 @@ function myExtractContents(range) {
frag.appendChild(containedChildren[i]);
}
// "If last partially contained child is a Text or Comment node:"
// "If last partially contained child is a Text, ProcessingInstruction, or
// Comment node:"
if (lastPartiallyContainedChild
&& (lastPartiallyContainedChild.nodeType == Node.TEXT_NODE
|| lastPartiallyContainedChild.nodeType == Node.PROCESSING_INSTRUCTION_NODE
|| lastPartiallyContainedChild.nodeType == Node.COMMENT_NODE)) {
// "Let clone be the result of calling cloneNode(false) on original
// end node."
@ -831,13 +828,14 @@ function myExtractContents(range) {
* instance "HIERARCHY_REQUEST_ERR".
*/
function myInsertNode(range, node) {
// "If range's start node is either a ProcessingInstruction or Comment
// node, or a Text node whose parent is null, throw an
// "If range's start node is a ProcessingInstruction or Comment node, or is
// a Text node whose parent is null, or is node, throw an
// "HierarchyRequestError" exception and terminate these steps."
if (range.startContainer.nodeType == Node.PROCESSING_INSTRUCTION_NODE
|| range.startContainer.nodeType == Node.COMMENT_NODE
|| (range.startContainer.nodeType == Node.TEXT_NODE
&& !range.startContainer.parentNode)) {
&& !range.startContainer.parentNode)
|| range.startContainer == node) {
return "HIERARCHY_REQUEST_ERR";
}

View file

@ -0,0 +1 @@
<!DOCTYPE foo [ <!ELEMENT foo (#PCDATA)> ]><foo/>

View file

@ -0,0 +1 @@
<!DOCTYPE foo [ <!ELEMENT foo EMPTY> ]><foo/>

View file

@ -78,7 +78,7 @@ function iframeLoaded() {
}
}
</script>
<iframe id="subset1" onload="iframeLoaded()" src="data:application/xml,&lt;!DOCTYPE foo [ &lt;!ELEMENT foo (%23PCDATA)> ]>&lt;foo/>" />
<iframe id="subset2" onload="iframeLoaded()" src="data:application/xml,&lt;!DOCTYPE foo [ &lt;!ELEMENT foo EMPTY> ]>&lt;foo/>" />
<iframe id="subset1" onload="iframeLoaded()" src="Node-isEqualNode-iframe1.xml" />
<iframe id="subset2" onload="iframeLoaded()" src="Node-isEqualNode-iframe2.xml" />
</body>
</html>

View file

@ -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>

View file

@ -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);
}

View file

@ -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) {

View file

@ -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;