test_bug372770.html (2696B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=372770 5 --> 6 <head> 7 <title>Test for Bug 372770</title> 8 <script src="/tests/SimpleTest/SimpleTest.js"></script> 9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 10 <style id="testStyle"> 11 #content {} 12 </style> 13 </head> 14 <body> 15 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=372770">Mozilla Bug 372770</a> 16 <p id="display"></p> 17 <div id="content" style="display: none"> 18 19 </div> 20 <pre id="test"> 21 <script class="testbody" type="text/javascript"> 22 23 /** Test for Bug 372770 */ 24 var style1 = $("content").style; 25 var style2 = $("testStyle").sheet.cssRules[0].style; 26 27 var colors = [ "rgb(128, 128, 128)", "transparent" ] 28 var i; 29 30 for (i = 0; i < colors.length; ++i) { 31 var color = colors[i]; 32 style1.color = color; 33 style2.color = color; 34 is(style1.color, color, "Inline style color roundtripping failed at color " + i); 35 is(style2.color, color, "Rule style color roundtripping failed at color " + i); 36 } 37 38 style1.color = "rgba(0, 0, 0, 0)"; 39 style2.color = "rgba(0, 0, 0, 0)"; 40 is(style1.color, "rgba(0, 0, 0, 0)", 41 "Inline style should round-trip black transparent color correctly"); 42 is(style2.color, "rgba(0, 0, 0, 0)", 43 "Rule style should round-trip black transparent color correctly"); 44 45 for (var i = 0; i <= 100; ++i) { 46 if (i == 70 || i == 90) { 47 // Tinderbox unhappy for some reason... just skip these for now? 48 continue; 49 } 50 var color1 = "rgba(128, 128, 128, " + i/100 + ")"; 51 var color2 = "rgba(175, 63, 27, " + i/100 + ")"; 52 style1.color = color1; 53 style1.backgroundColor = color2; 54 style2.color = color2; 55 style2.background = color1; 56 57 if (i == 100) { 58 // Bug 372783 means this doesn't round-trip quite right 59 todo(style1.color == color1, 60 "Inline style color roundtripping failed at opacity " + i); 61 todo(style1.backgroundColor == color2, 62 "Inline style background roundtripping failed at opacity " + i); 63 todo(style2.color == color2, 64 "Rule style color roundtripping failed at opacity " + i); 65 todo(style2.backgroundColor == color1, 66 "Rule style background roundtripping failed at opacity " + i); 67 color1 = "rgb(128, 128, 128)"; 68 color2 = "rgb(175, 63, 27)"; 69 } 70 71 is(style1.color, color1, 72 "Inline style color roundtripping failed at opacity " + i); 73 is(style1.backgroundColor, color2, 74 "Inline style background roundtripping failed at opacity " + i); 75 is(style2.color, color2, 76 "Rule style color roundtripping failed at opacity " + i); 77 is(style2.backgroundColor, color1, 78 "Rule style background roundtripping failed at opacity " + i); 79 80 } 81 </script> 82 </pre> 83 </body> 84 </html>