layout/style/test/test_bug98997.html

Wed, 31 Dec 2014 06:55:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:50 +0100
changeset 2
7e26c7da4463
permissions
-rw-r--r--

Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2

michael@0 1 <!DOCTYPE HTML>
michael@0 2 <html>
michael@0 3 <!--
michael@0 4 https://bugzilla.mozilla.org/show_bug.cgi?id=98997
michael@0 5 -->
michael@0 6 <head>
michael@0 7 <title>Test for Bug 98997</title>
michael@0 8 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
michael@0 10 <style type="text/css">
michael@0 11
michael@0 12 /*
michael@0 13 * This test does NOT test any of the cases where :empty and
michael@0 14 * :-moz-only-whitespace differ. We should probably have some tests
michael@0 15 * for that as well.
michael@0 16 */
michael@0 17 div.test { width: 200px; height: 30px; margin: 5px 0; }
michael@0 18 div.test.to, div.test.from:empty { background: orange; }
michael@0 19 div.test.to:empty, div.test.from { background: green; }
michael@0 20 div.test.to, div.test.from:-moz-only-whitespace { color: maroon; }
michael@0 21 div.test.to:-moz-only-whitespace, div.test.from { color: navy; }
michael@0 22
michael@0 23 </style>
michael@0 24 </head>
michael@0 25 <body>
michael@0 26 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=98997">Mozilla Bug 98997</a>
michael@0 27 <div id="display">
michael@0 28 <div class="test to" onclick="testReplaceChild(this, '')">x</div>
michael@0 29 <div class="test to" onclick="testReplaceChild(this, '')"><span>x</span></div>
michael@0 30 <div class="test to" onclick="testReplaceChild(this, '')">x<!-- comment --></div>
michael@0 31 <div class="test to" onclick="testRemoveChild(this)">x</div>
michael@0 32 <div class="test to" onclick="testRemoveChild(this)"><span>x</span></div>
michael@0 33 <div class="test to" onclick="testRemoveChild(this)">x<!-- comment --></div>
michael@0 34 <div class="test to" onclick="testChangeData(this, '')">x</div>
michael@0 35 <div class="test to" onclick="testChangeData(this, '')">x<!-- comment --></div>
michael@0 36 <div class="test to" onclick="testDeleteData(this)">x</div>
michael@0 37 <div class="test to" onclick="testDeleteData(this)">x<!-- comment --></div>
michael@0 38 <div class="test to" onclick="testReplaceData(this, '')">x</div>
michael@0 39 <div class="test to" onclick="testReplaceData(this, '')">x<!-- comment --></div>
michael@0 40
michael@0 41 <div class="test from makeemptytext" onclick="testReplaceChild(this, 'x')"></div>
michael@0 42 <div class="test from makeemptytext" onclick="testReplaceChild(this, 'x')"><!-- comment --></div>
michael@0 43 <div class="test from" onclick="testReplaceChild(this, 'x')"><!-- comment --></div>
michael@0 44 <div class="test from" onclick="testInsertBefore(this, 'x')"></div>
michael@0 45 <div class="test from" onclick="testInsertBefore(this, 'x')"><!-- comment --></div>
michael@0 46 <div class="test from" onclick="testAppendChild(this, 'x')"></div>
michael@0 47 <div class="test from" onclick="testAppendChild(this, 'x')"><!-- comment --></div>
michael@0 48 <div class="test from makeemptytext" onclick="testChangeData(this, 'x')"></div>
michael@0 49 <div class="test from makeemptytext" onclick="testChangeData(this, 'x')"><!-- comment --></div>
michael@0 50 <div class="test from makeemptytext" onclick="testAppendData(this, 'x')"></div>
michael@0 51 <div class="test from makeemptytext" onclick="testAppendData(this, 'x')"><!-- comment --></div>
michael@0 52 <div class="test from makeemptytext" onclick="testReplaceData(this, 'x')"></div>
michael@0 53 <div class="test from makeemptytext" onclick="testReplaceData(this, 'x')"><!-- comment --></div>
michael@0 54 </div>
michael@0 55
michael@0 56 <div id="content" style="display: none">
michael@0 57
michael@0 58 </div>
michael@0 59 <pre id="test">
michael@0 60 <script class="testbody" type="text/javascript">
michael@0 61
michael@0 62 /** Test for Bug 98997 **/
michael@0 63
michael@0 64 function testInsertBefore(elt, text) {
michael@0 65 elt.insertBefore(document.createTextNode(text), elt.firstChild);
michael@0 66 }
michael@0 67
michael@0 68 function testAppendChild(elt, text) {
michael@0 69 elt.appendChild(document.createTextNode(text));
michael@0 70 }
michael@0 71
michael@0 72 function testReplaceChild(elt, text) {
michael@0 73 elt.replaceChild(document.createTextNode(text), elt.firstChild);
michael@0 74 }
michael@0 75
michael@0 76 function testRemoveChild(elt) {
michael@0 77 elt.removeChild(elt.firstChild);
michael@0 78 }
michael@0 79
michael@0 80 function testChangeData(elt, text) {
michael@0 81 elt.firstChild.data = text;
michael@0 82 }
michael@0 83
michael@0 84 function testAppendData(elt, text) {
michael@0 85 elt.firstChild.appendData(text);
michael@0 86 }
michael@0 87
michael@0 88 function testDeleteData(elt) {
michael@0 89 elt.firstChild.deleteData(0, elt.firstChild.length);
michael@0 90 }
michael@0 91
michael@0 92 function testReplaceData(elt, text) {
michael@0 93 elt.firstChild.replaceData(0, elt.firstChild.length, text);
michael@0 94 }
michael@0 95
michael@0 96 var cnodes = document.getElementById("display").childNodes;
michael@0 97 var divs = [];
michael@0 98 var i;
michael@0 99 for (i = 0; i < cnodes.length; ++i) {
michael@0 100 if (cnodes[i].nodeName == "DIV")
michael@0 101 divs.push(cnodes[i]);
michael@0 102 }
michael@0 103
michael@0 104 for (i in divs) {
michael@0 105 var div = divs[i];
michael@0 106 if (div.className.match(/makeemptytext/))
michael@0 107 div.insertBefore(document.createTextNode(""), div.firstChild);
michael@0 108 }
michael@0 109
michael@0 110 const ORANGE = "rgb(255, 165, 0)";
michael@0 111 const MAROON = "rgb(128, 0, 0)";
michael@0 112 const GREEN = "rgb(0, 128, 0)";
michael@0 113 const NAVY = "rgb(0, 0, 128)";
michael@0 114
michael@0 115 function color(div) {
michael@0 116 return getComputedStyle(div, "").color;
michael@0 117 }
michael@0 118 function bg(div) {
michael@0 119 return getComputedStyle(div, "").backgroundColor;
michael@0 120 }
michael@0 121
michael@0 122 for (i in divs) {
michael@0 123 var div = divs[i];
michael@0 124 is(bg(div), ORANGE, "should be orange");
michael@0 125 is(color(div), MAROON, "should be maroon");
michael@0 126 }
michael@0 127
michael@0 128 for (i in divs) {
michael@0 129 var div = divs[i];
michael@0 130 var e = document.createEvent("MouseEvents");
michael@0 131 e.initEvent("click", true, true);
michael@0 132 div.dispatchEvent(e);
michael@0 133 }
michael@0 134
michael@0 135 for (i in divs) {
michael@0 136 var div = divs[i];
michael@0 137 is(bg(div), GREEN, "should be green");
michael@0 138 is(color(div), NAVY, "should be navy");
michael@0 139 }
michael@0 140
michael@0 141 </script>
michael@0 142 </pre>
michael@0 143 </body>
michael@0 144 </html>

mercurial