OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <head> |
| 4 <meta http-equiv="Content-Security-Policy" content="style-src 'self';"> |
| 5 <script src="../../resources/js-test-pre.js"></script> |
| 6 <script> |
| 7 window.onload = function () { |
| 8 debug("This test ensures that styles can be set by object.cloneNode(
)"); |
| 9 |
| 10 window.nodes = document.getElementById('nodes'); |
| 11 window.node1 = document.getElementById('node1'); |
| 12 window.node1.style.background = "yellow"; |
| 13 window.node1.style.color = "red"; |
| 14 window.node2 = document.getElementById('node1').cloneNode(true); |
| 15 window.node2.id = "node2"; |
| 16 window.node3 = document.getElementById('node3'); |
| 17 window.node3.style.background = "blue"; |
| 18 window.node3.style.color = "green"; |
| 19 window.node4 = document.getElementById('node3').cloneNode(false); |
| 20 window.node4.id = "node4"; |
| 21 window.node4.innerHTML = "Node #4"; |
| 22 |
| 23 nodes.appendChild(node1); |
| 24 nodes.appendChild(node2); |
| 25 nodes.appendChild(node3); |
| 26 nodes.appendChild(node4); |
| 27 |
| 28 shouldBeEqualToString("node1.style.background", "yellow"); |
| 29 shouldBeEqualToString("node2.style.background", "yellow"); |
| 30 shouldBeEqualToString("node3.style.background", "blue"); |
| 31 shouldBeEqualToString("node4.style.background", "blue"); |
| 32 |
| 33 shouldBeEqualToString("node1.style.color", "red"); |
| 34 shouldBeEqualToString("node2.style.color", "red"); |
| 35 shouldBeEqualToString("node3.style.color", "green"); |
| 36 shouldBeEqualToString("node4.style.color", "green"); |
| 37 |
| 38 shouldBe("window.getComputedStyle(node1).getPropertyCSSValue('backgr
ound').cssText", "window.getComputedStyle(node2).getPropertyCSSValue('background
').cssText"); |
| 39 shouldBe("window.getComputedStyle(node3).getPropertyCSSValue('backgr
ound').cssText", "window.getComputedStyle(node4).getPropertyCSSValue('background
').cssText"); |
| 40 |
| 41 shouldBe("window.getComputedStyle(node1).getPropertyCSSValue('color'
).cssText", "window.getComputedStyle(node2).getPropertyCSSValue('color').cssText
"); |
| 42 shouldBe("window.getComputedStyle(node3).getPropertyCSSValue('color'
).cssText", "window.getComputedStyle(node4).getPropertyCSSValue('color').cssText
"); |
| 43 |
| 44 window.ops = document.getElementById('ops'); |
| 45 ops.style.color = 'red'; |
| 46 window.clonedOps = ops.cloneNode(true); |
| 47 window.violetOps = document.getElementById('violetOps'); |
| 48 |
| 49 violetOps.style.background = 'rgb(238, 130, 238)'; |
| 50 document.getElementsByTagName('body')[0].appendChild(clonedOps); |
| 51 |
| 52 shouldBeEqualToString("ops.style.background", ""); |
| 53 debug("getComputedStyle(clonedOps).getPropertyCSSValue('background')
.cssText: " + window.getComputedStyle(ops).getPropertyCSSValue('background').css
Text); |
| 54 shouldBeEqualToString("ops.style.color", "red"); |
| 55 shouldBeEqualToString("clonedOps.style.background", ""); |
| 56 shouldBeEqualToString("violetOps.style.background", "rgb(238, 130, 2
38)"); |
| 57 |
| 58 shouldBe("window.getComputedStyle(clonedOps).getPropertyCSSValue('ba
ckground').cssText", "window.getComputedStyle(ops).getPropertyCSSValue('backgrou
nd').cssText"); |
| 59 shouldBe("window.getComputedStyle(clonedOps).getPropertyCSSValue('co
lor').cssText", "window.getComputedStyle(ops).getPropertyCSSValue('color').cssTe
xt"); |
| 60 debug("getComputedStyle(violetOps).getPropertyCSSValue('background')
.cssText: " + window.getComputedStyle(violetOps).getPropertyCSSValue('background
').cssText); |
| 61 shouldNotBe("window.getComputedStyle(ops).getPropertyCSSValue('backg
round').cssText", "window.getComputedStyle(violetOps).getPropertyCSSValue('backg
round').cssText"); |
| 62 shouldNotBe("window.getComputedStyle(clonedOps).getPropertyCSSValue(
'background').cssText", "window.getComputedStyle(violetOps).getPropertyCSSValue(
'background').cssText"); |
| 63 |
| 64 shouldBeEqualToString("ops.id", "ops"); |
| 65 shouldBe("ops.id", "clonedOps.id"); |
| 66 }; |
| 67 </script> |
| 68 </head> |
| 69 <body> |
| 70 |
| 71 <div id="nodes"> |
| 72 This is a div (nodes) |
| 73 <div id="node1"> This is a div. (node 1 or 2)</div> |
| 74 <div id="node3"> This is a div. (node 3 or 4)</div> |
| 75 </div> |
| 76 |
| 77 <div id="ops" style="background: rgb(238, 130, 238)"> |
| 78 Yet another div. |
| 79 </div> |
| 80 |
| 81 <div id="violetOps"> |
| 82 Yet another div. |
| 83 </div> |
| 84 |
| 85 </body> |
| 86 </html> |
OLD | NEW |