haikuwebkit/LayoutTests/fast/dom/ChildNode-before-expected.txt

190 lines
6.4 KiB
Plaintext
Raw Permalink Normal View History

DOM4: prepend, append, before, after & replace https://bugs.webkit.org/show_bug.cgi?id=74648 Reviewed by Darin Adler. Source/WebCore: - Adds support for ChildNode.before/after/replaceWith and ParentNode.prepend/append which are new functions in https://dom.spec.whatwg.org - Uses custom bindings rather than implementing support for union types in the code generator as their uses seems isolated to just this spec at the moment. If more uses come along, we should implement proper support for them in the generator and remove the custom bindings added here. Tests: fast/dom/ChildNode-after.html fast/dom/ChildNode-before.html fast/dom/ChildNode-replaceWith.html fast/dom/ParentNode-append.html fast/dom/ParentNode-prepend.html * CMakeLists.txt: * WebCore.vcxproj/WebCore.vcxproj: * WebCore.xcodeproj/project.pbxproj: * bindings/js/JSBindingsAllInOne.cpp: Add new files. * bindings/js/JSCharacterDataCustom.cpp: Added. (WebCore::JSCharacterData::before): (WebCore::JSCharacterData::after): (WebCore::JSCharacterData::replaceWith): * bindings/js/JSDocumentCustom.cpp: (WebCore::JSDocument::prepend): (WebCore::JSDocument::append): (WebCore::JSDocument::createTouchList): * bindings/js/JSDocumentFragmentCustom.cpp: Added. (WebCore::JSDocumentFragment::prepend): (WebCore::JSDocumentFragment::append): * bindings/js/JSDocumentTypeCustom.cpp: Added. (WebCore::JSDocumentType::before): (WebCore::JSDocumentType::after): (WebCore::JSDocumentType::replaceWith): * bindings/js/JSElementCustom.cpp: (WebCore::toJSNewlyCreated): (WebCore::JSElement::before): (WebCore::JSElement::after): (WebCore::JSElement::replaceWith): (WebCore::JSElement::prepend): (WebCore::JSElement::append): Add custom bindings to implement the use of variadic union types. * bindings/js/JSNodeOrString.cpp: Added. (WebCore::toNodeOrStringVector): * bindings/js/JSNodeOrString.h: Added. Adds a help function for converting an JS argument list into a Vector of NodeOrString objects. * dom/ChildNode.idl: Expose before/after/replaceWith to JavaScript. * dom/ContainerNode.cpp: (WebCore::ContainerNode::append): (WebCore::ContainerNode::prepend): * dom/ContainerNode.h: Add implementations of append and prepend. * dom/Node.h: * dom/Node.cpp: (WebCore::nodeSetPreTransformedFromNodeOrStringVector): (WebCore::firstPrecedingSiblingNotInNodeSet): (WebCore::firstFollowingSiblingNotInNodeSet): Helper functions for before, after and removeWith. (WebCore::Node::before): (WebCore::Node::after): (WebCore::Node::replaceWith): Add implementations of before, after and removeWith. * dom/NodeOrString.cpp: Added. (WebCore::convertNodesOrStringsIntoNode): * dom/NodeOrString.h: Added. (WebCore::NodeOrString::NodeOrString): (WebCore::NodeOrString::~NodeOrString): (WebCore::NodeOrString::type): (WebCore::NodeOrString::node): (WebCore::NodeOrString::string): Custom union type representing the (Node or DOMString) IDL type. * dom/ParentNode.idl: Expose append/prepend to JavaScript. LayoutTests: * fast/dom/ChildNode-after-expected.txt: Added. * fast/dom/ChildNode-after.html: Added. * fast/dom/ChildNode-before-expected.txt: Added. * fast/dom/ChildNode-before.html: Added. * fast/dom/ChildNode-replaceWith-expected.txt: Added. * fast/dom/ChildNode-replaceWith.html: Added. * fast/dom/ParentNode-append-expected.txt: Added. * fast/dom/ParentNode-append.html: Added. * fast/dom/ParentNode-prepend-expected.txt: Added. * fast/dom/ParentNode-prepend.html: Added. Canonical link: https://commits.webkit.org/164993@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@186803 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-07-14 15:58:05 +00:00
Tests ChildNode.before((Node or DOMString)...)
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
Test Element.before((Node or DOMString)...).
Test with no arguments.
PASS parent.childNodes.length is 1
Test with a single element.
PASS parent.childNodes.length is 2
PASS child.previousSibling is d1
Test with a single string.
PASS parent.childNodes.length is 2
PASS child.previousSibling.data is 'hello'
Test with a both strings and elements.
PASS parent.childNodes.length is 3
PASS child.previousSibling is d1
PASS parent.childNodes[0] is an instance of Text
PASS parent.childNodes[0].data is 'hello'
PASS parent.childNodes[1] is an instance of Element
PASS parent.childNodes[1] is d1
Test conversion to string
PASS parent.childNodes.length is 4
PASS parent.childNodes[0] is an instance of Text
PASS parent.childNodes[0].data is 'null'
PASS parent.childNodes[1] is an instance of Text
PASS parent.childNodes[1].data is 'undefined'
PASS parent.childNodes[2] is an instance of Text
PASS parent.childNodes[2].data is '7'
PASS parent.childNodes[3] is an instance of Element
PASS parent.childNodes[3] is child
Test a child without a parent.
PASS child.previousSibling is null
Test when there the previous sibling is not a viable previous sibling.
PASS parent.childNodes.length is 5
PASS parent.childNodes[0] is an instance of Element
PASS parent.childNodes[0] is d1
PASS parent.childNodes[1] is an instance of Text
PASS parent.childNodes[1].data is 'hello'
PASS parent.childNodes[2] is an instance of Element
PASS parent.childNodes[2] is d2
PASS parent.childNodes[3] is an instance of Text
PASS parent.childNodes[3].data is 'world'
PASS parent.childNodes[4] is an instance of Element
PASS parent.childNodes[4] is child
Test when there is no viable previous sibling.
PASS parent.childNodes.length is 5
PASS parent.childNodes[0] is an instance of Text
PASS parent.childNodes[0].data is 'hello'
PASS parent.childNodes[1] is an instance of Element
PASS parent.childNodes[1] is d1
PASS parent.childNodes[2] is an instance of Text
PASS parent.childNodes[2].data is 'world'
PASS parent.childNodes[3] is an instance of Element
PASS parent.childNodes[3] is d2
PASS parent.childNodes[4] is an instance of Element
PASS parent.childNodes[4] is child
Test Text.before((Node or DOMString)...).
Test with no arguments.
PASS parent.childNodes.length is 1
Test with a single element.
PASS parent.childNodes.length is 2
PASS child.previousSibling is d1
Test with a single string.
PASS parent.childNodes.length is 2
PASS child.previousSibling.data is 'hello'
Test with a both strings and elements.
PASS parent.childNodes.length is 3
PASS child.previousSibling is d1
PASS parent.childNodes[0] is an instance of Text
PASS parent.childNodes[0].data is 'hello'
PASS parent.childNodes[1] is an instance of Element
PASS parent.childNodes[1] is d1
Test conversion to string
PASS parent.childNodes.length is 4
PASS parent.childNodes[0] is an instance of Text
PASS parent.childNodes[0].data is 'null'
PASS parent.childNodes[1] is an instance of Text
PASS parent.childNodes[1].data is 'undefined'
PASS parent.childNodes[2] is an instance of Text
PASS parent.childNodes[2].data is '7'
PASS parent.childNodes[3] is an instance of Text
PASS parent.childNodes[3] is child
Test a child without a parent.
PASS child.previousSibling is null
Test when there the previous sibling is not a viable previous sibling.
PASS parent.childNodes.length is 5
PASS parent.childNodes[0] is an instance of Element
PASS parent.childNodes[0] is d1
PASS parent.childNodes[1] is an instance of Text
PASS parent.childNodes[1].data is 'hello'
PASS parent.childNodes[2] is an instance of Element
PASS parent.childNodes[2] is d2
PASS parent.childNodes[3] is an instance of Text
PASS parent.childNodes[3].data is 'world'
PASS parent.childNodes[4] is an instance of Text
PASS parent.childNodes[4] is child
Test when there is no viable previous sibling.
PASS parent.childNodes.length is 5
PASS parent.childNodes[0] is an instance of Text
PASS parent.childNodes[0].data is 'hello'
PASS parent.childNodes[1] is an instance of Element
PASS parent.childNodes[1] is d1
PASS parent.childNodes[2] is an instance of Text
PASS parent.childNodes[2].data is 'world'
PASS parent.childNodes[3] is an instance of Element
PASS parent.childNodes[3] is d2
PASS parent.childNodes[4] is an instance of Text
PASS parent.childNodes[4] is child
Test Comment.before((Node or DOMString)...).
Test with no arguments.
PASS parent.childNodes.length is 1
Test with a single element.
PASS parent.childNodes.length is 2
PASS child.previousSibling is d1
Test with a single string.
PASS parent.childNodes.length is 2
PASS child.previousSibling.data is 'hello'
Test with a both strings and elements.
PASS parent.childNodes.length is 3
PASS child.previousSibling is d1
PASS parent.childNodes[0] is an instance of Text
PASS parent.childNodes[0].data is 'hello'
PASS parent.childNodes[1] is an instance of Element
PASS parent.childNodes[1] is d1
Test conversion to string
PASS parent.childNodes.length is 4
PASS parent.childNodes[0] is an instance of Text
PASS parent.childNodes[0].data is 'null'
PASS parent.childNodes[1] is an instance of Text
PASS parent.childNodes[1].data is 'undefined'
PASS parent.childNodes[2] is an instance of Text
PASS parent.childNodes[2].data is '7'
PASS parent.childNodes[3] is an instance of Comment
PASS parent.childNodes[3] is child
Test a child without a parent.
PASS child.previousSibling is null
Test when there the previous sibling is not a viable previous sibling.
PASS parent.childNodes.length is 5
PASS parent.childNodes[0] is an instance of Element
PASS parent.childNodes[0] is d1
PASS parent.childNodes[1] is an instance of Text
PASS parent.childNodes[1].data is 'hello'
PASS parent.childNodes[2] is an instance of Element
PASS parent.childNodes[2] is d2
PASS parent.childNodes[3] is an instance of Text
PASS parent.childNodes[3].data is 'world'
PASS parent.childNodes[4] is an instance of Comment
PASS parent.childNodes[4] is child
Test when there is no viable previous sibling.
PASS parent.childNodes.length is 5
PASS parent.childNodes[0] is an instance of Text
PASS parent.childNodes[0].data is 'hello'
PASS parent.childNodes[1] is an instance of Element
PASS parent.childNodes[1] is d1
PASS parent.childNodes[2] is an instance of Text
PASS parent.childNodes[2].data is 'world'
PASS parent.childNodes[3] is an instance of Element
PASS parent.childNodes[3] is d2
PASS parent.childNodes[4] is an instance of Comment
PASS parent.childNodes[4] is child
PASS successfullyParsed is true
TEST COMPLETE