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

Side by Side Diff: LayoutTests/fast/dom/attribute-empty-value-no-children.html

Issue 253843002: Deprecate Attr.nodeValue / Attr.textContent (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebaseline more tests Created 6 years, 7 months 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 | Annotate | Revision Log
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <title>Attr empty value tests</title> 4 <title>Attr empty value tests</title>
5 <script> 5 <script>
6 if (window.testRunner) { 6 if (window.testRunner) {
7 testRunner.dumpAsText(); 7 testRunner.dumpAsText();
8 } 8 }
9 function isReallyEmpty(attr) { 9 function isReallyEmpty(attr) {
10 return attr.value === "" 10 return attr.value === ""
11 && attr.nodeValue === ""
12 && attr.textContent === ""
13 && attr.hasChildNodes() === false 11 && attr.hasChildNodes() === false
14 && attr.firstChild === null 12 && attr.firstChild === null
15 && attr.lastChild === null 13 && attr.lastChild === null
16 && attr.childNodes.length === 0; 14 && attr.childNodes.length === 0;
17 } 15 }
18 window.onload = function() { 16 window.onload = function() {
19 var tests = []; 17 var tests = [];
20 var dynamicAttr = document.createAttribute("foo"); 18 var dynamicAttr = document.createAttribute("foo");
21 tests[0] = isReallyEmpty(dynamicAttr); 19 tests[0] = isReallyEmpty(dynamicAttr);
22 20
23 dynamicAttr.value = ""; 21 dynamicAttr.value = "";
24 tests[1] = isReallyEmpty(dynamicAttr); 22 tests[1] = isReallyEmpty(dynamicAttr);
25 23
26 dynamicAttr.value = "bar"; 24 dynamicAttr.value = "bar";
27 dynamicAttr.value = ""; 25 dynamicAttr.value = "";
28 tests[2] = isReallyEmpty(dynamicAttr); 26 tests[2] = isReallyEmpty(dynamicAttr);
29 27
30 dynamicAttr.textContent = "bar"; 28 var parsedAttr = document.body.getAttributeNode("id");
31 dynamicAttr.textContent = ""; 29 tests[3] = isReallyEmpty(parsedAttr);
32 tests[3] = isReallyEmpty(dynamicAttr);
33 30
34 var parsedAttr = document.body.getAttributeNode("id"); 31 parsedAttr.value = "";
35 tests[4] = isReallyEmpty(parsedAttr); 32 tests[4] = isReallyEmpty(parsedAttr);
36 33
34 parsedAttr.value = "bar";
37 parsedAttr.value = ""; 35 parsedAttr.value = "";
38 tests[5] = isReallyEmpty(parsedAttr); 36 tests[5] = isReallyEmpty(parsedAttr);
39 37
40 parsedAttr.value = "bar";
41 parsedAttr.value = "";
42 tests[6] = isReallyEmpty(parsedAttr);
43
44 parsedAttr.textContent = "bar";
45 parsedAttr.textContent = "";
46 tests[7] = isReallyEmpty(parsedAttr);
47
48 var parsedAttrIntitiallyNonEmpty = document.body.getAttributeNod e("class"); 38 var parsedAttrIntitiallyNonEmpty = document.body.getAttributeNod e("class");
49 parsedAttrIntitiallyNonEmpty.value = ""; 39 parsedAttrIntitiallyNonEmpty.value = "";
50 tests[8] = isReallyEmpty(parsedAttrIntitiallyNonEmpty); 40 tests[6] = isReallyEmpty(parsedAttrIntitiallyNonEmpty);
51 41
52 parsedAttrIntitiallyNonEmpty.textContent = "bar"; 42 parsedAttrIntitiallyNonEmpty.value = "bar";
53 parsedAttrIntitiallyNonEmpty.textContent = ""; 43 parsedAttrIntitiallyNonEmpty.value = "";
54 tests[9] = isReallyEmpty(parsedAttrIntitiallyNonEmpty); 44 tests[7] = isReallyEmpty(parsedAttrIntitiallyNonEmpty);
55 45
56 document.body.setAttribute("title", ""); 46 document.body.setAttribute("title", "");
57 47
58 var parsedAttrNodeChangedToEmptyBySetAttribute = document.body.g etAttributeNode("title"); 48 var parsedAttrNodeChangedToEmptyBySetAttribute = document.body.g etAttributeNode("title");
59 tests[10] = isReallyEmpty(parsedAttrNodeChangedToEmptyBySetAttri bute); 49 tests[8] = isReallyEmpty(parsedAttrNodeChangedToEmptyBySetAttrib ute);
60 50
61 parsedAttrNodeChangedToEmptyBySetAttribute.textContent = "bar"; 51 parsedAttrNodeChangedToEmptyBySetAttribute.value = "bar";
62 parsedAttrNodeChangedToEmptyBySetAttribute.textContent = ""; 52 parsedAttrNodeChangedToEmptyBySetAttribute.value = "";
63 tests[11] = isReallyEmpty(parsedAttrNodeChangedToEmptyBySetAttri bute); 53 tests[9] = isReallyEmpty(parsedAttrNodeChangedToEmptyBySetAttrib ute);
64 54
65 var results = document.getElementsByTagName("p")[1]; 55 var results = document.getElementsByTagName("p")[1];
66 while (results.hasChildNodes()) { 56 while (results.hasChildNodes()) {
67 results.removeChild(results.lastChild); 57 results.removeChild(results.lastChild);
68 } 58 }
69 59
70 for (var i = 0; i < tests.length; ++i) { 60 for (var i = 0; i < tests.length; ++i) {
71 var pass = tests[i] ? "PASS" : "FAIL"; 61 var pass = tests[i] ? "PASS" : "FAIL";
72 results.appendChild(document.createTextNode("SubTest " + (i + 1) + " = " + pass)); 62 results.appendChild(document.createTextNode("SubTest " + (i + 1) + " = " + pass));
73 results.appendChild(document.createElement("br")); 63 results.appendChild(document.createElement("br"));
74 } 64 }
75 65
76 var completely = "PASS"; 66 var completely = "PASS";
77 for (var i = 0; i < tests.length; ++i) { 67 for (var i = 0; i < tests.length; ++i) {
78 if (tests[i] === false) { 68 if (tests[i] === false) {
79 completely = "FAIL"; 69 completely = "FAIL";
80 break; 70 break;
81 } 71 }
82 } 72 }
83 results.appendChild(document.createTextNode("Complete Test = " + completely)); 73 results.appendChild(document.createTextNode("Complete Test = " + completely));
84 }; 74 };
85 </script> 75 </script>
86 </head> 76 </head>
87 <body id="" class="test" title="test"> 77 <body id="" class="test" title="test">
88 <h1>Attr empty value tests <a href="https://bugs.webkit.org/show_bug.cgi ?id=16923">Bug 16923</a></h1> 78 <h1>Attr empty value tests <a href="https://bugs.webkit.org/show_bug.cgi ?id=16923">Bug 16923</a></h1>
89 <p>In Opera, Firefox and IE, when an Attr's value is an empty string, th e Attr node won't have any childNodes. The following 12 tests will see if this i s true for WebKit for both parsed and dynamically-created Attr nodes. The tests use multiple methods of changing the Attr's value and even test reverting from a non-empty value to an empty one to check that all childNodes were removed. Some of the tests make use of .textContent, so this test is not compatible with IE. Opera and Firefox both completely pass this test.</p> 79 <p>In Opera, Firefox and IE, when an Attr's value is an empty string, th e Attr node won't have any childNodes. The following 12 tests will see if this i s true for WebKit for both parsed and dynamically-created Attr nodes. The tests use multiple methods of changing the Attr's value and even test reverting from a non-empty value to an empty one to check that all childNodes were removed. Some of the tests make use of .textContent, so this test is not compatible with IE. Opera and Firefox both completely pass this test.</p>
90 <p>This test requires Javascript.</p> 80 <p>This test requires Javascript.</p>
91 </body> 81 </body>
92 </html> 82 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698