DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Mercurial (b6057e17f856)

VCS Links

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253
<!DOCTYPE html>
<html lang=en>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<body>
<iframe></iframe>
<!-- Note that the following style and div elements are duplicates
     of the ones written into the iframe; they are here for convienience
     in resolving the "standard" computed value for a given specification
-->
<style></style>
<div id=a class='a b c' title='zxcv weeqweqeweasd&#13;&#10;a&#10;'></div>
<script>
SimpleTest.waitForExplicitFinish();

window.onload=function(){

var base;

// A short note about escaping: all of the strings in this test go through
// Javascript unescaping before getting passed to CSS.  This means that
// sequences like "\n" refer to a newline, a single backslash is written "\\",
// a CSS escape sequence is something like "\\A", and some quotes must be
// escaped.

var testset = [

// Color tests
// Generic property for testing
{ base : base = "div {color:green}",
  tests : [
// My misc tests
"<!--#a {color:green}",
base + "<!-#a {color:red}",
base + "#a<!--{color:red}",
"-->#a{color:green}",
base + "--#a {color:red}",
base + "--aasdf, #a {color:green}",
base + "-0aasdf, #a {color:red}",
"-asdf, #a {color:green}",
base + "#a {color: rgb\n(255, 0, 0)}",
"#a {font: \"Arial\n;color:green}",
"#a {color: @charset{}\"\\\n'\"url(\na\na); color:green}",
"#a\r{color:green}",
"#a\n{color:green}",
"#a\t{color:green}",
"@threedee maroon url('asdf\n) ra('asdf\n); " + base,
"@threedee {maroon url('asdf\n) ra('asdf\n);} " + base,
"div[title='zxcv weeqweqeweasd\\D\\A a']{color:green}",
"div[title~='weeqweqeweasd']{color:green}",
base + "#a\\\n{color:red}",
base + "#a\v{color:red}",

// CSS1 section 7.1
"#a {color: green; rotation: 70deg;}",
"#a {color: green;} #a{color:invalidValue;}",
base + "#a {color: \"red\"}",
base + "@three-dee {\n @background-lighting {\n  azimuth: 30deg;\n  elevation: 190deg;\n  }\n #a { color: red }\n }",
"#a {COLOR: GREEN}",
base + "#a:wait {color: red}",
"#a:lang(en) {color: green}",
"#a:lang(\nen\r\t ) {color: green}",
base + "div ! em, #a {color: red}",
base + "//asdf.zxcv,\n#a {color: red}",
"#a {rotation-code: \"}\"; color: green;}",
"#a {rotation-code: \"\\\"}\\\"\"; color: green;}",
"#a {rotation-code: '}'; color: green;}",
"#a {rotation-code: '\\'}\\''; color: green;}",
"#a {\n type-display: @threedee {rotation-code: '}';};\n color: green;\n }",
base + "p {text-indent: 0.5in;} color: maroon #a {color: red;}",
base + "p {text-indent: 0.5in;} color: maroon; #a {color: red;}",

// string tokenization as error token, not EOF (bug 311566 comment 70)
"#a { color: green; foo: { \"bar\n;color: red}",

// CSS 2.1 section 4.1.3
"@MediA All {#a {ColOR :RgB(\t0,\r128,\n0 ) } };",
base + "\\#a{color:red;}",
base + "#a\\{color:red;\\}",
base + "#a{color\\:red;}",
base + "#a{color:red\\;}",
"#a {c\\o\\l\\o\\r:\\g\\ree\\n}",
"#a{ co\\00006Cor: gr\\000065en; }",
"#a{ co\\4C or: gr\\000045en; }",
".IdE6n-3t0_6, #a { color: green }",
"#IdE6n-3t0_6, #a { color: green }",
"._ident, #a { color: green }",
"#_ident, #a { color: green }",
".-ident, .a { color: green; }", // Testsuite has incorrect version
"#怀ident, .a { color: green }",
"#iden怀t怀, .a { color: green }",
"#\\6000ident, .a { color: green }",
"#iden\\6000t\\6000, .a { color: green }",
".怀ident, .a { color: green }",
".iden怀t怀, .a { color: green }",
".\\6000ident, .a { color: green }",
".iden\\6000t\\6000, .a { color: green }",
base + "#6ident, #a {color: red }",
".id4ent6, .a { color: green }",
"#\\ident, .a { color: green; }",
"#ide\\n\\t, .a { color: green; }",
".\\6ident, .a { color: green; }",
".\\--ident, .a { color: green; }",

// CSS2.1 section 4.1.5 and 4.2
"@import 'data:text/css,%23a{color:green}';",
"@import \"data:text/css,%23a{color:green}\";",
"@import url(data:text/css,%23a{color:green});",
"@import 'data:text/css,%23a{color:green}' screen;",
base + "@import 'data:text/css,%23a{color:red}' blahblahblah;",
"@import 'data:text/css,%23a{color:green}'",
"@import 'data:text/css,%23a{color:green}",
"@foo {}" + base,
"@foo bar {}" + base,
"@foo; " + base,
"@foo bar baz; " + base,
base + "@foo {}; #a {color: red}",

// CSS2.1 section 4.1.9
"/* This is a CSS comment. */" + base,
base + "/* #a {color: red} */",
"/*********** /*/" + base,

// CSS2.1 section 4.3.6
base + "#a {color: rgb(255, 0, 0%)}",
base + "#a {color: rgb(100%, 0, 0)}",
base + "#a {color: rgb(255.0, 0, 0)}",
"#a {color: rgb(0, 128, 0)}",
"#a {color: rgb(0%, 50%, 0%)}",
"#a {color: rgb(0%, 49.999999999999%, 0%)}",
], prop: "color", pseudo: ""
},

// Border tests
// For testing lengths
{ base : base = "#a {border-style:solid}",
  tests : [
// CSS1 section 7.1
base + "#a {border-width: funny}",
base + "#a {border-width: 50zu}",
base + "#a {border-width: px}",

// Number/unit parsing
base + "#a {border-width: 0.px}",
base + "#a {border-width: ..0px}",
base + "#a {border-width: 0..0px}",
base + "#a {border-width: 0.}",
base + "#a {border-width: ..0}",
base + "#a {border-width: 0..0}",
base + "#a {border-width: 0; border-width: .0px medium}",
base + "#a {border-width: 0; border-width: .0 medium}",
base + "#a {border-width: 0; border-width: 0.0px medium}",
], prop: "borderRightWidth", pseudo: ""},

// Content tests
// Tests for strings and pseudos
{base : base = ".a::before {content: 'This is \\a'}",
 tests : [
// CSS 2.1 section 4.1.3
"#a::before {content: 'This is \\a '}",
"#a::before {content: 'This is \\A '}",
"#a::before {content: 'This is \\0000a '}",
"#a::before {content: 'This is \\00000a '}",
"#a::before {content: 'This is \\\n\\00000a '}",
"#a::before {content: 'This is \\\015\012\\00000a '}",
"#a::before {content: 'This is \\\015\\00000a '}",
"#a::before {content: 'This is \\\f\\00000a '}",
"#a::before {content: 'This is\\20\f\\a'}",
"#a::before {content: 'This is\\20\r\\a'}",
"#a::before {content: 'This is\\20\n\\a'}",
"#a::before {content: 'This is\\20\r\n\\a'}",
base + "#a::before {content: 'FAIL \f\\a'}",
base + "#a::before {content: 'FAIL \\\n\r\\a'}",
"#a:before {content: 'This is \\a'}",

base + "#a:: before {content: 'FAIL'}",
base + "#a ::before {content: 'FAIL'}",
"#a::before {content: 'This is \\a",

], prop: "content", pseudo: "::before"
},

// Background color tests
// For basic URL parsing sanity checks
{ base : base = "div {background: blue}",
  tests : [
"#a {background: url() blue}",
"#a {background: url(怀) blue}",
], prop: "backgroundColor", pseudo: ""
},

// A one-off test I couldn't come up with a better way to do
{ base : base = "div {border-style: dotted}",
  tests : [
// Sanity-check to make sure this test will work
// This test requires a color name that starts with a "-"
base + "#a {border: dotted 0 -moz-menuhover}",
// The actual test: check that 0-moz-menuhover get parsed as an unknown dimension
// rather than a separate identifier
base + "#a {border: solid 0-moz-menuhover}",
], prop: "borderLeftStyle", pseudo: ""
},

];

var curTest = -1;
var curSubTest = 0;

var styleElement = document.getElementsByTagName("style")[0];
var divElement = document.getElementById("a");
var frame = document.getElementsByTagName("iframe")[0];

var canonical;

var doTests = function() {
  if (curTest >= 0) {
    var curElement = frame.contentDocument.getElementsByTagName("div")[0];
    var curStyle = frame.contentDocument.defaultView.getComputedStyle(curElement, testset[curTest].pseudo);
    if (testset[curTest].todo && testset[curTest].todo[testset[curTest].tests[curSubTest]]) {
      todo_is(curStyle[testset[curTest].prop], canonical, testset[curTest].tests[curSubTest]);
    } else {
      is(curStyle[testset[curTest].prop], canonical, testset[curTest].tests[curSubTest]);
    }
    curSubTest++;
  }
  if (curTest == -1 || curSubTest >= testset[curTest].tests.length) {
    curTest++;
    curSubTest = 0;
  }
  if (!(curTest < testset.length)) {
    SimpleTest.finish();
    return;
  }
  if (curSubTest == 0) {
    styleElement.textContent = "";
    var base = document.defaultView.getComputedStyle(divElement, testset[curTest].pseudo)[testset[curTest].prop];
    styleElement.textContent = testset[curTest].base;
    canonical = document.defaultView.getComputedStyle(divElement, testset[curTest].pseudo)[testset[curTest].prop];
    styleElement.textContent = "";
    isnot(base, canonical, "Sanity check for rule: " + testset[curTest].base);
  }
  frame.contentDocument.open();
  frame.contentDocument.write("<html lang=en><style>" + testset[curTest].tests[curSubTest] + "</style><div id=a class='a b c' title='zxcv weeqweqeweasd&#13;&#10;a'></div>");
  frame.contentWindow.onload = function(){setTimeout(doTests, 0);};
  frame.contentDocument.close();
};

doTests();

};

</script>