layout/style/test/test_priority_preservation.html

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

michael@0 1 <!DOCTYPE HTML>
michael@0 2 <html>
michael@0 3 <head>
michael@0 4 <title>Test for property priority preservation</title>
michael@0 5 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 6 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
michael@0 7 </head>
michael@0 8 <body>
michael@0 9 <p id="display"></p>
michael@0 10 <div id="content" style="display: none">
michael@0 11
michael@0 12 </div>
michael@0 13 <pre id="test">
michael@0 14 <script type="application/javascript">
michael@0 15
michael@0 16 /**
michael@0 17 * Test that priorities are preserved correctly when setProperty is
michael@0 18 * called, and during declaration block expansion/compression when other
michael@0 19 * properties are manipulated.
michael@0 20 */
michael@0 21
michael@0 22 var div = document.getElementById("content");
michael@0 23 var s = div.style;
michael@0 24
michael@0 25 s.setProperty("text-decoration", "underline", "");
michael@0 26 is(s.getPropertyValue("text-decoration"), "underline",
michael@0 27 "text-decoration stored");
michael@0 28 is(s.getPropertyPriority("text-decoration"), "",
michael@0 29 "text-decoration priority stored");
michael@0 30 s.setProperty("z-index", "7", "important");
michael@0 31 is(s.getPropertyValue("z-index"), "7",
michael@0 32 "z-index stored");
michael@0 33 is(s.getPropertyPriority("z-index"), "important",
michael@0 34 "z-index priority stored");
michael@0 35 s.setProperty("z-index", "3", "");
michael@0 36 is(s.getPropertyValue("z-index"), "3",
michael@0 37 "z-index overridden by setting non-important");
michael@0 38 is(s.getPropertyPriority("z-index"), "",
michael@0 39 "z-index priority overridden by setting non-important");
michael@0 40 is(s.getPropertyValue("text-decoration"), "underline",
michael@0 41 "text-decoration still stored");
michael@0 42 is(s.getPropertyPriority("text-decoration"), "",
michael@0 43 "text-decoration priority still stored");
michael@0 44 s.setProperty("text-decoration", "overline", "");
michael@0 45 is(s.getPropertyValue("text-decoration"), "overline",
michael@0 46 "text-decoration stored");
michael@0 47 is(s.getPropertyPriority("text-decoration"), "",
michael@0 48 "text-decoration priority stored");
michael@0 49 is(s.getPropertyValue("z-index"), "3",
michael@0 50 "z-index still stored");
michael@0 51 is(s.getPropertyPriority("z-index"), "",
michael@0 52 "z-index priority still stored");
michael@0 53 s.setProperty("text-decoration", "line-through", "important");
michael@0 54 is(s.getPropertyValue("text-decoration"), "line-through",
michael@0 55 "text-decoration stored at new priority");
michael@0 56 is(s.getPropertyPriority("text-decoration"), "important",
michael@0 57 "text-decoration priority overridden");
michael@0 58 is(s.getPropertyValue("z-index"), "3",
michael@0 59 "z-index still stored");
michael@0 60 is(s.getPropertyPriority("z-index"), "",
michael@0 61 "z-index priority still stored");
michael@0 62
michael@0 63 // also test setting a shorthand
michael@0 64 s.setProperty("font", "italic bold 12px/30px serif", "important");
michael@0 65 is(s.getPropertyValue("font-style"), "italic", "font-style stored");
michael@0 66 is(s.getPropertyPriority("font-style"), "important",
michael@0 67 "font-style priority stored");
michael@0 68 is(s.getPropertyValue("font-weight"), "bold", "font-weight stored");
michael@0 69 is(s.getPropertyPriority("font-weight"), "important",
michael@0 70 "font-weight priority stored");
michael@0 71 is(s.getPropertyValue("font-size"), "12px", "font-size stored");
michael@0 72 is(s.getPropertyPriority("font-size"), "important",
michael@0 73 "font-size priority stored");
michael@0 74 is(s.getPropertyValue("line-height"), "30px", "line-height stored");
michael@0 75 is(s.getPropertyPriority("line-height"), "important",
michael@0 76 "line-height priority stored");
michael@0 77 is(s.getPropertyValue("font-family"), "serif", "font-family stored");
michael@0 78 is(s.getPropertyPriority("font-family"), "important",
michael@0 79 "font-family priority stored");
michael@0 80
michael@0 81 is(s.getPropertyValue("text-decoration"), "line-through",
michael@0 82 "text-decoration still stored");
michael@0 83 is(s.getPropertyPriority("text-decoration"), "important",
michael@0 84 "text-decoration priority still stored");
michael@0 85 is(s.getPropertyValue("z-index"), "3",
michael@0 86 "z-index still stored");
michael@0 87 is(s.getPropertyPriority("z-index"), "",
michael@0 88 "z-index priority still stored");
michael@0 89
michael@0 90 // and overriding one element of that shorthand with some longhand
michael@0 91 // test omitting the third argument to setProperty too (bug 655478)
michael@0 92 s.setProperty("font-style", "normal");
michael@0 93
michael@0 94 is(s.getPropertyValue("font-style"), "normal", "font-style overridden");
michael@0 95 is(s.getPropertyPriority("font-style"), "", "font-style priority overridden");
michael@0 96
michael@0 97 is(s.getPropertyValue("font-weight"), "bold", "font-weight unchanged");
michael@0 98 is(s.getPropertyPriority("font-weight"), "important",
michael@0 99 "font-weight priority unchanged");
michael@0 100 is(s.getPropertyValue("font-size"), "12px", "font-size unchanged");
michael@0 101 is(s.getPropertyPriority("font-size"), "important",
michael@0 102 "font-size priority unchanged");
michael@0 103 is(s.getPropertyValue("line-height"), "30px", "line-height unchanged");
michael@0 104 is(s.getPropertyPriority("line-height"), "important",
michael@0 105 "line-height priority unchanged");
michael@0 106 is(s.getPropertyValue("font-family"), "serif", "font-family unchanged");
michael@0 107 is(s.getPropertyPriority("font-family"), "important",
michael@0 108 "font-family priority unchanged");
michael@0 109
michael@0 110 is(s.getPropertyValue("text-decoration"), "line-through",
michael@0 111 "text-decoration still stored");
michael@0 112 is(s.getPropertyPriority("text-decoration"), "important",
michael@0 113 "text-decoration priority still stored");
michael@0 114 is(s.getPropertyValue("z-index"), "3",
michael@0 115 "z-index still stored");
michael@0 116 is(s.getPropertyPriority("z-index"), "",
michael@0 117 "z-index priority still stored");
michael@0 118
michael@0 119 s.setProperty("border-radius", "2em", "");
michael@0 120 is(s.getPropertyValue("border-radius"), "2em",
michael@0 121 "border-radius serialization 1")
michael@0 122
michael@0 123 s.setProperty("border-top-left-radius", "3em 4em", "");
michael@0 124 is(s.getPropertyValue("border-radius"),
michael@0 125 "3em 2em 2em / 4em 2em 2em",
michael@0 126 "border-radius serialization 2");
michael@0 127
michael@0 128 s.setProperty("border-radius", "2em / 3em", "");
michael@0 129 is(s.getPropertyValue("border-radius"),
michael@0 130 "2em / 3em",
michael@0 131 "border-radius serialization 3")
michael@0 132
michael@0 133 s.setProperty("border-top-left-radius", "4em", "");
michael@0 134 is(s.getPropertyValue("border-radius"),
michael@0 135 "4em 2em 2em / 4em 3em 3em",
michael@0 136 "border-radius serialization 3");
michael@0 137
michael@0 138 </script>
michael@0 139 </pre>
michael@0 140 </body>
michael@0 141 </html>

mercurial