| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346 |
- var TESTS = [
- {
- input: "/* fuuuu */",
- result: {
- cssRules: []
- }
- },
- {
- input: "/**/",
- result: {
- cssRules: []
- }
- },
- {
- input: "/*a {content: '* {color:#000}'}*/",
- result: {
- cssRules: []
- }
- },
- {
- input: "a {color: red}",
- result: {
- cssRules: [
- {
- selectorText: "a",
- style: {
- 0: "color",
- color: "red",
- length: 1
- }
- }
- ]
- }
- },
- {
- input: ".left {float: left;}",
- result: {
- cssRules: [
- {
- selectorText: ".left",
- style: {
- 0: "float",
- float: "left",
- length: 1
- }
- }
- ]
- }
- },
- {
- input: "h1 {font-family: 'Times New Roman', Helvetica Neue, sans-serif }",
- result: {
- cssRules: [
- {
- selectorText: "h1",
- style: {
- 0: "font-family",
- "font-family": "'Times New Roman', Helvetica Neue, sans-serif",
- length: 1
- }
- }
- ]
- }
- },
- {
- input: "h2 {font: normal\n1.6em\r\nTimes New Roman,\tserif ;}",
- result: {
- cssRules: [
- {
- selectorText: "h2",
- style: {
- 0: "font",
- font: "normal 1.6em Times New Roman, serif",
- length: 1
- }
- }
- ]
- }
- },
- {
- input: ".icon>*{background-image: url(../images/ramona_strong.gif);}",
- result: {
- cssRules: [
- {
- selectorText: ".icon>*",
- style: {
- 0: "background-image",
- "background-image": "url(../images/ramona_strong.gif)",
- length: 1
- }
- }
- ]
- }
- },
- {
- input: "*/**/{}",
- result: {
- cssRules: [
- {
- selectorText: "*",
- style: {
- length: 0
- }
- }
- ]
- }
- },
- {
- input: "/**/*{}",
- result: {
- cssRules: [
- {
- selectorText: "*",
- style: {
- length: 0
- }
- }
- ]
- }
- },
- {
- input: "* /**/*{}",
- result: {
- cssRules: [
- {
- selectorText: "* *",
- style: {
- length: 0
- }
- }
- ]
- }
- },
- {
- input: "*/*/*/ *{}",
- result: {
- cssRules: [
- {
- selectorText: "* *",
- style: {
- length: 0
- }
- }
- ]
- }
- },
- {
- input: "#a {b:c;}\n#d {e:f}",
- result: {
- cssRules: [
- {
- selectorText: "#a",
- style: {
- 0: "b",
- b: "c",
- length: 1
- }
- }, {
- selectorText: "#d",
- style: {
- 0: "e",
- e: "f",
- length: 1
- }
- }
- ]
- }
- },
- {
- input: "* { border: none } \n#foo {font-size: 12px; background:#fff;}",
- result: {
- cssRules: [
- {
- selectorText: "*",
- style: {
- 0: "border",
- border: "none",
- length: 1
- }
- },
- {
- selectorText: "#foo",
- style: {
- 0: "font-size",
- "font-size": "12px",
- 1: "background",
- background: "#fff",
- length: 2
- }
- }
- ]
- }
- },
- {
- input: "span {display: inline-block !important; vertical-align: middle !important} .error{color:red!important;}",
- result: {
- cssRules: [
- {
- selectorText: "span",
- style: {
- 0: "display",
- 1: "vertical-align",
- display: "inline-block",
- "vertical-align": "middle",
- length: 2
- }
- },
- {
- selectorText: ".error",
- style: {
- 0: "color",
- color: "red",
- length: 1
- }
- }
- ]
- }
- },
- {
- input: "@media handheld, only screen and (max-device-width: 480px) {body{max-width:480px}}",
- result: {
- cssRules: [
- {
- media: {
- 0: "handheld",
- 1: "only screen and (max-device-width: 480px)",
- length: 2
- },
- cssRules: [
- {
- selectorText: "body",
- style: {
- 0: "max-width",
- "max-width": "480px",
- length: 1
- }
- }
- ]
- }
- ]
- }
- },
- {
- input: "@media screen, screen, screen {/* Match Firefox and Opera behavior here rather than WebKit. \nSane person shouldn't write like this anyway. */}",
- result: {
- cssRules: [
- {
- media: {
- 0: "screen",
- 1: "screen",
- 2: "screen",
- length: 3
- },
- cssRules: []
- }
- ]
- }
- },
- {
- input: "@media/**/print {*{background:#fff}}",
- result: {
- cssRules: [
- {
- media: {
- 0: "print",
- length: 1
- },
- cssRules: [
- {
- selectorText: "*",
- style: {
- 0: "background",
- background: "#fff",
- length: 1
- }
- }
- ]
- }
- ]
- }
- },
- {
- input: "a{}@media all{b{color:#000}}",
- result: {
- cssRules: [
- {
- selectorText: "a",
- style: {
- length: 0
- }
- },
- {
- media: {
- 0: "all",
- length: 1
- },
- cssRules: [
- {
- selectorText: "b",
- style: {
- 0: "color",
- color: "#000",
- length: 1
- }
- }
- ]
- }
- ]
- }
- },
- {
- input: "@mediaall {}",
- result: {
- cssRules: []
- }
- },
- {
- input: "some invalid junk @media projection {body{background:black}}",
- result: {
- cssRules: [
- {
- media: {
- 0: "projection",
- length: 1
- },
- cssRules: [
- {
- selectorText: "body",
- style: {
- 0: "background",
- background: "black",
- length: 1
- }
- }
- ]
- }
- ]
- }
- }
- ];
- // Run tests.
- for (var i=0; i<TESTS.length; i++) {
- compare(TESTS[i].input, TESTS[i].result, TESTS[i].name);
- }
|