Thu, 15 Jan 2015 21:03:48 +0100
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 lang=en> |
michael@0 | 3 | <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 4 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
michael@0 | 5 | <META http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
michael@0 | 6 | <body> |
michael@0 | 7 | <iframe></iframe> |
michael@0 | 8 | <!-- Note that the following style and div elements are duplicates |
michael@0 | 9 | of the ones written into the iframe; they are here for convienience |
michael@0 | 10 | in resolving the "standard" computed value for a given specification |
michael@0 | 11 | --> |
michael@0 | 12 | <style></style> |
michael@0 | 13 | <div id=a class='a b c' title='zxcv weeqweqeweasd a '></div> |
michael@0 | 14 | <script> |
michael@0 | 15 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 16 | |
michael@0 | 17 | window.onload=function(){ |
michael@0 | 18 | |
michael@0 | 19 | var base; |
michael@0 | 20 | |
michael@0 | 21 | // A short note about escaping: all of the strings in this test go through |
michael@0 | 22 | // Javascript unescaping before getting passed to CSS. This means that |
michael@0 | 23 | // sequences like "\n" refer to a newline, a single backslash is written "\\", |
michael@0 | 24 | // a CSS escape sequence is something like "\\A", and some quotes must be |
michael@0 | 25 | // escaped. |
michael@0 | 26 | |
michael@0 | 27 | var testset = [ |
michael@0 | 28 | |
michael@0 | 29 | // Color tests |
michael@0 | 30 | // Generic property for testing |
michael@0 | 31 | { base : base = "div {color:green}", |
michael@0 | 32 | tests : [ |
michael@0 | 33 | // My misc tests |
michael@0 | 34 | "<!--#a {color:green}", |
michael@0 | 35 | base + "<!-#a {color:red}", |
michael@0 | 36 | base + "#a<!--{color:red}", |
michael@0 | 37 | "-->#a{color:green}", |
michael@0 | 38 | base + "--#a {color:red}", |
michael@0 | 39 | base + "--aasdf, #a {color:green}", |
michael@0 | 40 | base + "-0aasdf, #a {color:red}", |
michael@0 | 41 | "-asdf, #a {color:green}", |
michael@0 | 42 | base + "#a {color: rgb\n(255, 0, 0)}", |
michael@0 | 43 | "#a {font: \"Arial\n;color:green}", |
michael@0 | 44 | "#a {color: @charset{}\"\\\n'\"url(\na\na); color:green}", |
michael@0 | 45 | "#a\r{color:green}", |
michael@0 | 46 | "#a\n{color:green}", |
michael@0 | 47 | "#a\t{color:green}", |
michael@0 | 48 | "@threedee maroon url('asdf\n) ra('asdf\n); " + base, |
michael@0 | 49 | "@threedee {maroon url('asdf\n) ra('asdf\n);} " + base, |
michael@0 | 50 | "div[title='zxcv weeqweqeweasd\\D\\A a']{color:green}", |
michael@0 | 51 | "div[title~='weeqweqeweasd']{color:green}", |
michael@0 | 52 | base + "#a\\\n{color:red}", |
michael@0 | 53 | base + "#a\v{color:red}", |
michael@0 | 54 | |
michael@0 | 55 | // CSS1 section 7.1 |
michael@0 | 56 | "#a {color: green; rotation: 70deg;}", |
michael@0 | 57 | "#a {color: green;} #a{color:invalidValue;}", |
michael@0 | 58 | base + "#a {color: \"red\"}", |
michael@0 | 59 | base + "@three-dee {\n @background-lighting {\n azimuth: 30deg;\n elevation: 190deg;\n }\n #a { color: red }\n }", |
michael@0 | 60 | "#a {COLOR: GREEN}", |
michael@0 | 61 | base + "#a:wait {color: red}", |
michael@0 | 62 | "#a:lang(en) {color: green}", |
michael@0 | 63 | "#a:lang(\nen\r\t ) {color: green}", |
michael@0 | 64 | base + "div ! em, #a {color: red}", |
michael@0 | 65 | base + "//asdf.zxcv,\n#a {color: red}", |
michael@0 | 66 | "#a {rotation-code: \"}\"; color: green;}", |
michael@0 | 67 | "#a {rotation-code: \"\\\"}\\\"\"; color: green;}", |
michael@0 | 68 | "#a {rotation-code: '}'; color: green;}", |
michael@0 | 69 | "#a {rotation-code: '\\'}\\''; color: green;}", |
michael@0 | 70 | "#a {\n type-display: @threedee {rotation-code: '}';};\n color: green;\n }", |
michael@0 | 71 | base + "p {text-indent: 0.5in;} color: maroon #a {color: red;}", |
michael@0 | 72 | base + "p {text-indent: 0.5in;} color: maroon; #a {color: red;}", |
michael@0 | 73 | |
michael@0 | 74 | // string tokenization as error token, not EOF (bug 311566 comment 70) |
michael@0 | 75 | "#a { color: green; foo: { \"bar\n;color: red}", |
michael@0 | 76 | |
michael@0 | 77 | // CSS 2.1 section 4.1.3 |
michael@0 | 78 | "@MediA All {#a {ColOR :RgB(\t0,\r128,\n0 ) } };", |
michael@0 | 79 | base + "\\#a{color:red;}", |
michael@0 | 80 | base + "#a\\{color:red;\\}", |
michael@0 | 81 | base + "#a{color\\:red;}", |
michael@0 | 82 | base + "#a{color:red\\;}", |
michael@0 | 83 | "#a {c\\o\\l\\o\\r:\\g\\ree\\n}", |
michael@0 | 84 | "#a{ co\\00006Cor: gr\\000065en; }", |
michael@0 | 85 | "#a{ co\\4C or: gr\\000045en; }", |
michael@0 | 86 | ".IdE6n-3t0_6, #a { color: green }", |
michael@0 | 87 | "#IdE6n-3t0_6, #a { color: green }", |
michael@0 | 88 | "._ident, #a { color: green }", |
michael@0 | 89 | "#_ident, #a { color: green }", |
michael@0 | 90 | ".-ident, .a { color: green; }", // Testsuite has incorrect version |
michael@0 | 91 | "#怀ident, .a { color: green }", |
michael@0 | 92 | "#iden怀t怀, .a { color: green }", |
michael@0 | 93 | "#\\6000ident, .a { color: green }", |
michael@0 | 94 | "#iden\\6000t\\6000, .a { color: green }", |
michael@0 | 95 | ".怀ident, .a { color: green }", |
michael@0 | 96 | ".iden怀t怀, .a { color: green }", |
michael@0 | 97 | ".\\6000ident, .a { color: green }", |
michael@0 | 98 | ".iden\\6000t\\6000, .a { color: green }", |
michael@0 | 99 | base + "#6ident, #a {color: red }", |
michael@0 | 100 | ".id4ent6, .a { color: green }", |
michael@0 | 101 | "#\\ident, .a { color: green; }", |
michael@0 | 102 | "#ide\\n\\t, .a { color: green; }", |
michael@0 | 103 | ".\\6ident, .a { color: green; }", |
michael@0 | 104 | ".\\--ident, .a { color: green; }", |
michael@0 | 105 | |
michael@0 | 106 | // CSS2.1 section 4.1.5 and 4.2 |
michael@0 | 107 | "@import 'data:text/css,%23a{color:green}';", |
michael@0 | 108 | "@import \"data:text/css,%23a{color:green}\";", |
michael@0 | 109 | "@import url(data:text/css,%23a{color:green});", |
michael@0 | 110 | "@import 'data:text/css,%23a{color:green}' screen;", |
michael@0 | 111 | base + "@import 'data:text/css,%23a{color:red}' blahblahblah;", |
michael@0 | 112 | "@import 'data:text/css,%23a{color:green}'", |
michael@0 | 113 | "@import 'data:text/css,%23a{color:green}", |
michael@0 | 114 | "@foo {}" + base, |
michael@0 | 115 | "@foo bar {}" + base, |
michael@0 | 116 | "@foo; " + base, |
michael@0 | 117 | "@foo bar baz; " + base, |
michael@0 | 118 | base + "@foo {}; #a {color: red}", |
michael@0 | 119 | |
michael@0 | 120 | // CSS2.1 section 4.1.9 |
michael@0 | 121 | "/* This is a CSS comment. */" + base, |
michael@0 | 122 | base + "/* #a {color: red} */", |
michael@0 | 123 | "/*********** /*/" + base, |
michael@0 | 124 | |
michael@0 | 125 | // CSS2.1 section 4.3.6 |
michael@0 | 126 | base + "#a {color: rgb(255, 0, 0%)}", |
michael@0 | 127 | base + "#a {color: rgb(100%, 0, 0)}", |
michael@0 | 128 | base + "#a {color: rgb(255.0, 0, 0)}", |
michael@0 | 129 | "#a {color: rgb(0, 128, 0)}", |
michael@0 | 130 | "#a {color: rgb(0%, 50%, 0%)}", |
michael@0 | 131 | "#a {color: rgb(0%, 49.999999999999%, 0%)}", |
michael@0 | 132 | ], prop: "color", pseudo: "" |
michael@0 | 133 | }, |
michael@0 | 134 | |
michael@0 | 135 | // Border tests |
michael@0 | 136 | // For testing lengths |
michael@0 | 137 | { base : base = "#a {border-style:solid}", |
michael@0 | 138 | tests : [ |
michael@0 | 139 | // CSS1 section 7.1 |
michael@0 | 140 | base + "#a {border-width: funny}", |
michael@0 | 141 | base + "#a {border-width: 50zu}", |
michael@0 | 142 | base + "#a {border-width: px}", |
michael@0 | 143 | |
michael@0 | 144 | // Number/unit parsing |
michael@0 | 145 | base + "#a {border-width: 0.px}", |
michael@0 | 146 | base + "#a {border-width: ..0px}", |
michael@0 | 147 | base + "#a {border-width: 0..0px}", |
michael@0 | 148 | base + "#a {border-width: 0.}", |
michael@0 | 149 | base + "#a {border-width: ..0}", |
michael@0 | 150 | base + "#a {border-width: 0..0}", |
michael@0 | 151 | base + "#a {border-width: 0; border-width: .0px medium}", |
michael@0 | 152 | base + "#a {border-width: 0; border-width: .0 medium}", |
michael@0 | 153 | base + "#a {border-width: 0; border-width: 0.0px medium}", |
michael@0 | 154 | ], prop: "borderRightWidth", pseudo: ""}, |
michael@0 | 155 | |
michael@0 | 156 | // Content tests |
michael@0 | 157 | // Tests for strings and pseudos |
michael@0 | 158 | {base : base = ".a::before {content: 'This is \\a'}", |
michael@0 | 159 | tests : [ |
michael@0 | 160 | // CSS 2.1 section 4.1.3 |
michael@0 | 161 | "#a::before {content: 'This is \\a '}", |
michael@0 | 162 | "#a::before {content: 'This is \\A '}", |
michael@0 | 163 | "#a::before {content: 'This is \\0000a '}", |
michael@0 | 164 | "#a::before {content: 'This is \\00000a '}", |
michael@0 | 165 | "#a::before {content: 'This is \\\n\\00000a '}", |
michael@0 | 166 | "#a::before {content: 'This is \\\015\012\\00000a '}", |
michael@0 | 167 | "#a::before {content: 'This is \\\015\\00000a '}", |
michael@0 | 168 | "#a::before {content: 'This is \\\f\\00000a '}", |
michael@0 | 169 | "#a::before {content: 'This is\\20\f\\a'}", |
michael@0 | 170 | "#a::before {content: 'This is\\20\r\\a'}", |
michael@0 | 171 | "#a::before {content: 'This is\\20\n\\a'}", |
michael@0 | 172 | "#a::before {content: 'This is\\20\r\n\\a'}", |
michael@0 | 173 | base + "#a::before {content: 'FAIL \f\\a'}", |
michael@0 | 174 | base + "#a::before {content: 'FAIL \\\n\r\\a'}", |
michael@0 | 175 | "#a:before {content: 'This is \\a'}", |
michael@0 | 176 | |
michael@0 | 177 | base + "#a:: before {content: 'FAIL'}", |
michael@0 | 178 | base + "#a ::before {content: 'FAIL'}", |
michael@0 | 179 | "#a::before {content: 'This is \\a", |
michael@0 | 180 | |
michael@0 | 181 | ], prop: "content", pseudo: "::before" |
michael@0 | 182 | }, |
michael@0 | 183 | |
michael@0 | 184 | // Background color tests |
michael@0 | 185 | // For basic URL parsing sanity checks |
michael@0 | 186 | { base : base = "div {background: blue}", |
michael@0 | 187 | tests : [ |
michael@0 | 188 | "#a {background: url() blue}", |
michael@0 | 189 | "#a {background: url(怀) blue}", |
michael@0 | 190 | ], prop: "backgroundColor", pseudo: "" |
michael@0 | 191 | }, |
michael@0 | 192 | |
michael@0 | 193 | // A one-off test I couldn't come up with a better way to do |
michael@0 | 194 | { base : base = "div {border-style: dotted}", |
michael@0 | 195 | tests : [ |
michael@0 | 196 | // Sanity-check to make sure this test will work |
michael@0 | 197 | // This test requires a color name that starts with a "-" |
michael@0 | 198 | base + "#a {border: dotted 0 -moz-menuhover}", |
michael@0 | 199 | // The actual test: check that 0-moz-menuhover get parsed as an unknown dimension |
michael@0 | 200 | // rather than a separate identifier |
michael@0 | 201 | base + "#a {border: solid 0-moz-menuhover}", |
michael@0 | 202 | ], prop: "borderLeftStyle", pseudo: "" |
michael@0 | 203 | }, |
michael@0 | 204 | |
michael@0 | 205 | ]; |
michael@0 | 206 | |
michael@0 | 207 | var curTest = -1; |
michael@0 | 208 | var curSubTest = 0; |
michael@0 | 209 | |
michael@0 | 210 | var styleElement = document.getElementsByTagName("style")[0]; |
michael@0 | 211 | var divElement = document.getElementById("a"); |
michael@0 | 212 | var frame = document.getElementsByTagName("iframe")[0]; |
michael@0 | 213 | |
michael@0 | 214 | var canonical; |
michael@0 | 215 | |
michael@0 | 216 | var doTests = function() { |
michael@0 | 217 | if (curTest >= 0) { |
michael@0 | 218 | var curElement = frame.contentDocument.getElementsByTagName("div")[0]; |
michael@0 | 219 | var curStyle = frame.contentDocument.defaultView.getComputedStyle(curElement, testset[curTest].pseudo); |
michael@0 | 220 | if (testset[curTest].todo && testset[curTest].todo[testset[curTest].tests[curSubTest]]) { |
michael@0 | 221 | todo_is(curStyle[testset[curTest].prop], canonical, testset[curTest].tests[curSubTest]); |
michael@0 | 222 | } else { |
michael@0 | 223 | is(curStyle[testset[curTest].prop], canonical, testset[curTest].tests[curSubTest]); |
michael@0 | 224 | } |
michael@0 | 225 | curSubTest++; |
michael@0 | 226 | } |
michael@0 | 227 | if (curTest == -1 || curSubTest >= testset[curTest].tests.length) { |
michael@0 | 228 | curTest++; |
michael@0 | 229 | curSubTest = 0; |
michael@0 | 230 | } |
michael@0 | 231 | if (!(curTest < testset.length)) { |
michael@0 | 232 | SimpleTest.finish(); |
michael@0 | 233 | return; |
michael@0 | 234 | } |
michael@0 | 235 | if (curSubTest == 0) { |
michael@0 | 236 | styleElement.textContent = ""; |
michael@0 | 237 | var base = document.defaultView.getComputedStyle(divElement, testset[curTest].pseudo)[testset[curTest].prop]; |
michael@0 | 238 | styleElement.textContent = testset[curTest].base; |
michael@0 | 239 | canonical = document.defaultView.getComputedStyle(divElement, testset[curTest].pseudo)[testset[curTest].prop]; |
michael@0 | 240 | styleElement.textContent = ""; |
michael@0 | 241 | isnot(base, canonical, "Sanity check for rule: " + testset[curTest].base); |
michael@0 | 242 | } |
michael@0 | 243 | frame.contentDocument.open(); |
michael@0 | 244 | frame.contentDocument.write("<html lang=en><style>" + testset[curTest].tests[curSubTest] + "</style><div id=a class='a b c' title='zxcv weeqweqeweasd a'></div>"); |
michael@0 | 245 | frame.contentWindow.onload = function(){setTimeout(doTests, 0);}; |
michael@0 | 246 | frame.contentDocument.close(); |
michael@0 | 247 | }; |
michael@0 | 248 | |
michael@0 | 249 | doTests(); |
michael@0 | 250 | |
michael@0 | 251 | }; |
michael@0 | 252 | |
michael@0 | 253 | </script> |