layout/style/test/test_bug74880.html

Wed, 31 Dec 2014 07:16:47 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:16:47 +0100
branch
TOR_BUG_9701
changeset 3
141e0f1194b1
permissions
-rw-r--r--

Revert simplistic fix pending revisit of Mozilla integration attempt.

michael@0 1 <!DOCTYPE HTML>
michael@0 2 <html>
michael@0 3 <!--
michael@0 4 https://bugzilla.mozilla.org/show_bug.cgi?id=74880
michael@0 5 -->
michael@0 6 <head>
michael@0 7 <title>Test for Bug 74880</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 /* so that computed values for other border properties work right */
michael@0 13 #display { border-style: solid; }
michael@0 14
michael@0 15 </style>
michael@0 16 </head>
michael@0 17 <body>
michael@0 18 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=74880">Mozilla Bug 74880</a>
michael@0 19 <div style="margin: 1px 2px 3px 4px; border-width: 5px 6px 7px 8px; border-style: dotted dashed solid double; border-color: blue fuchsia green orange; padding: 9px 10px 11px 12px">
michael@0 20 <p id="display"></p>
michael@0 21 </div>
michael@0 22 <div id="content" style="display: none">
michael@0 23
michael@0 24 </div>
michael@0 25 <pre id="test">
michael@0 26 <script class="testbody" type="text/javascript">
michael@0 27
michael@0 28 /** Test for Bug 74880 **/
michael@0 29
michael@0 30 var gProps = [
michael@0 31 [ "margin-left", "margin-right", "-moz-margin-start", "-moz-margin-end" ],
michael@0 32 [ "padding-left", "padding-right", "-moz-padding-start", "-moz-padding-end" ],
michael@0 33 [ "border-left-color", "border-right-color", "-moz-border-start-color", "-moz-border-end-color" ],
michael@0 34 [ "border-left-style", "border-right-style", "-moz-border-start-style", "-moz-border-end-style" ],
michael@0 35 [ "border-left-width", "border-right-width", "-moz-border-start-width", "-moz-border-end-width" ],
michael@0 36 ];
michael@0 37
michael@0 38 var gLengthValues = [ "inherit", "initial", "2px", "1em" ];
michael@0 39 var gColorValues = [ "inherit", "initial", "currentColor", "green" ];
michael@0 40 var gStyleValues = [ "inherit", "initial", "double", "dashed" ];
michael@0 41
michael@0 42 if (SpecialPowers.getBoolPref("layout.css.unset-value.enabled")) {
michael@0 43 gLengthValues.push("unset");
michael@0 44 gColorValues.push("unset");
michael@0 45 gStyleValues.push("unset");
michael@0 46 }
michael@0 47
michael@0 48 function values_for(set) {
michael@0 49 var values;
michael@0 50 if (set[0].match(/style$/))
michael@0 51 values = gStyleValues;
michael@0 52 else if (set[0].match(/color$/))
michael@0 53 values = gColorValues;
michael@0 54 else
michael@0 55 values = gLengthValues;
michael@0 56 return values;
michael@0 57 }
michael@0 58
michael@0 59 var e = document.getElementById("display");
michael@0 60 var s = e.style;
michael@0 61 var c = window.getComputedStyle(e, "");
michael@0 62
michael@0 63 for (var set of gProps) {
michael@0 64 var values = values_for(set);
michael@0 65 for (var val of values) {
michael@0 66 function check(dir, plogical, pvisual) {
michael@0 67 var v0 = c.getPropertyValue(pvisual);
michael@0 68 s.setProperty("direction", dir, "");
michael@0 69 s.setProperty(pvisual, val, "");
michael@0 70 var v1 = c.getPropertyValue(pvisual);
michael@0 71 if (val != "initial" && val != "unset" && val != "currentColor")
michael@0 72 isnot(v1, v0, "setProperty set the property " + pvisual + ": " + val);
michael@0 73 s.removeProperty(pvisual);
michael@0 74 is(c.getPropertyValue(pvisual), v0, "removeProperty worked for " + pvisual);
michael@0 75 s.setProperty(plogical, val, "")
michael@0 76 var v2 = c.getPropertyValue(pvisual);
michael@0 77 is(v2, v1, "the logical property " + plogical + ": " + val + " showed up in the right place");
michael@0 78 s.removeProperty(plogical);
michael@0 79 is(c.getPropertyValue(pvisual), v0, "removeProperty worked for " + plogical);
michael@0 80
michael@0 81 s.removeProperty("direction");
michael@0 82 }
michael@0 83
michael@0 84 check("ltr", set[2], set[0]);
michael@0 85 check("ltr", set[3], set[1]);
michael@0 86 check("rtl", set[2], set[1]);
michael@0 87 check("rtl", set[3], set[0]);
michael@0 88 }
michael@0 89
michael@0 90 function check_cascading(dir, plogical, pvisual) {
michael@0 91 var dirstr = "direction: " + dir + ";";
michael@0 92 e.setAttribute("style", dirstr + pvisual + ":" + values[2]);
michael@0 93 var v2 = c.getPropertyValue(pvisual);
michael@0 94 e.setAttribute("style", dirstr + pvisual + ":" + values[3]);
michael@0 95 var v3 = c.getPropertyValue(pvisual);
michael@0 96 isnot(v2, v3, "values should produce different computed values");
michael@0 97
michael@0 98 var desc = ["cascading for", pvisual, "and", plogical, "with direction", dir].join(" ");
michael@0 99 e.setAttribute("style", dirstr + pvisual + ":" + values[3] + ";" +
michael@0 100 plogical + ":" + values[2]);
michael@0 101 is(c.getPropertyValue(pvisual), v2, desc);
michael@0 102 e.setAttribute("style", dirstr + plogical + ":" + values[3] + ";" +
michael@0 103 pvisual + ":" + values[2]);
michael@0 104 is(c.getPropertyValue(pvisual), v2, desc);
michael@0 105 e.setAttribute("style", dirstr + pvisual + ":" + values[2] + ";" +
michael@0 106 plogical + ":" + values[3]);
michael@0 107 is(c.getPropertyValue(pvisual), v3, desc);
michael@0 108 e.setAttribute("style", dirstr + plogical + ":" + values[2] + ";" +
michael@0 109 pvisual + ":" + values[3]);
michael@0 110 is(c.getPropertyValue(pvisual), v3, desc);
michael@0 111 e.removeAttribute("style");
michael@0 112 }
michael@0 113
michael@0 114 check_cascading("ltr", set[2], set[0]);
michael@0 115 check_cascading("ltr", set[3], set[1]);
michael@0 116 check_cascading("rtl", set[2], set[1]);
michael@0 117 check_cascading("rtl", set[3], set[0]);
michael@0 118 }
michael@0 119
michael@0 120
michael@0 121 </script>
michael@0 122 </pre>
michael@0 123 </body>
michael@0 124 </html>
michael@0 125

mercurial