Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(148)

Side by Side Diff: third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/ParentNode-append.html

Issue 1529523002: Import dom/ from web-platform-tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tweak W3CImportExpectations Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <meta charset=utf-8>
3 <title>ParentNode.append</title>
4 <link rel=help href="https://dom.spec.whatwg.org/#dom-parentnode-append">
5 <script src="../../../../resources/testharness.js"></script>
6 <script src="../../../../resources/testharnessreport.js"></script>
7 <script>
8
9 function test_append(node, nodeName) {
10
11 test(function() {
12 var parent = node.cloneNode();
13 parent.append();
14 assert_array_equals(parent.childNodes, []);
15 }, nodeName + '.append() without any argument, on a parent having no child.' );
16
17 test(function() {
18 var parent = node.cloneNode();
19 parent.append(null);
20 assert_equals(parent.childNodes[0].textContent, 'null');
21 }, nodeName + '.append() with null as an argument, on a parent having no chi ld.');
22
23 test(function() {
24 var parent = node.cloneNode();
25 parent.append(undefined);
26 assert_equals(parent.childNodes[0].textContent, 'undefined');
27 }, nodeName + '.append() with undefined as an argument, on a parent having n o child.');
28
29 test(function() {
30 var parent = node.cloneNode();
31 parent.append('text');
32 assert_equals(parent.childNodes[0].textContent, 'text');
33 }, nodeName + '.append() with only text as an argument, on a parent having n o child.');
34
35 test(function() {
36 var parent = node.cloneNode();
37 var x = document.createElement('x');
38 parent.append(x);
39 assert_array_equals(parent.childNodes, [x]);
40 }, nodeName + '.append() with only one element as an argument, on a parent h aving no child.');
41
42 test(function() {
43 var parent = node.cloneNode();
44 var child = document.createElement('test');
45 parent.appendChild(child);
46 parent.append(null);
47 assert_equals(parent.childNodes[0], child);
48 assert_equals(parent.childNodes[1].textContent, 'null');
49 }, nodeName + '.append() with null as an argument, on a parent having a chil d.');
50
51 test(function() {
52 var parent = node.cloneNode();
53 var x = document.createElement('x');
54 var child = document.createElement('test');
55 parent.appendChild(child);
56 parent.append(x, 'text');
57 assert_equals(parent.childNodes[0], child);
58 assert_equals(parent.childNodes[1], x);
59 assert_equals(parent.childNodes[2].textContent, 'text');
60 }, nodeName + '.append() with one element and text as argument, on a parent having a child.');
61 }
62
63 test_append(document.createElement('div'), 'Element');
64 test_append(document.createDocumentFragment(), 'DocumentFrgment');
65 </script>
66 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698