OLD | NEW |
---|---|
1 <!DOCTYPE HTML> | 1 <!DOCTYPE HTML> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <script src="../../resources/js-test.js"></script> | 4 <script src="../../resources/js-test.js"></script> |
5 </head> | 5 </head> |
6 <body> | 6 <body> |
7 <p id="description"></p> | 7 <p id="description"></p> |
8 <div id="console"></div> | 8 <div id="console"></div> |
9 <script> | 9 <script> |
10 description("Test the parsing of the cursor property."); | 10 description("Test the parsing of the cursor property."); |
11 | 11 |
12 function makeCursorRule(rule) | 12 function makeCursorRule(rule) |
13 { | 13 { |
14 return "cursor: " + rule + ";"; | 14 return "cursor: " + rule + ";"; |
15 } | 15 } |
16 | 16 |
17 function testCursorRule(rule) | 17 function testCursorRule(rule, expected) |
18 { | 18 { |
19 var cssText = makeCursorRule(rule); | 19 var cssText = makeCursorRule(rule); |
20 shouldBeEqualToString('roundtripCssRule("' + cssText + '")', cssText); | 20 shouldBeEqualToString('roundtripCssRule("' + cssText + '")', makeCursorRule( expected)); |
21 } | 21 } |
22 | 22 |
23 function testInvalidCursorRule(rule) | 23 function testInvalidCursorRule(rule) |
24 { | 24 { |
25 shouldBeEqualToString('roundtripCssRule("' + makeCursorRule(rule) + '")', '' ); | 25 shouldBeEqualToString('roundtripCssRule("' + makeCursorRule(rule) + '")', '' ); |
26 } | 26 } |
27 | 27 |
28 function roundtripCssRule(cssText) | 28 function roundtripCssRule(cssText) |
29 { | 29 { |
30 var div = document.createElement("div"); | 30 var div = document.createElement("div"); |
31 div.setAttribute("style", cssText); | 31 div.setAttribute("style", cssText); |
32 document.body.appendChild(div); | 32 document.body.appendChild(div); |
33 var result = div.style.cssText; | 33 var result = div.style.cssText; |
34 document.body.removeChild(div); | 34 document.body.removeChild(div); |
35 return result; | 35 return result; |
36 } | 36 } |
37 | 37 |
38 // Note that any absolute URL will suffice for these tests (can't use relative U RLs | 38 // Note that any absolute URL will suffice for these tests (can't use relative U RLs |
39 // since they'll be converted to absolute form in the output). I chose file URL s just | 39 // since they'll be converted to absolute form in the output). I chosefile URLs just |
40 // to avoid triggering any network activity. | 40 // to avoid triggering any network activity. |
41 | 41 |
42 debug('Test a bunch of cursor rules which should round-trip exactly.'); | 42 debug('Test a bunch of cursor rules which should round-trip exactly.'); |
43 testCursorRule('auto'); | 43 testCursorRule('auto', 'auto'); |
44 testCursorRule('none'); | 44 testCursorRule('none', 'none'); |
45 testCursorRule('copy'); | 45 testCursorRule('copy', 'copy'); |
46 testCursorRule('zoom-in'); | 46 testCursorRule('zoom-in', 'zoom-in'); |
47 testCursorRule('zoom-out'); | 47 testCursorRule('zoom-out', 'zoom-out'); |
48 testCursorRule('-webkit-grabbing'); | 48 testCursorRule('-webkit-grabbing', '-webkit-grabbing'); |
49 testCursorRule('-webkit-zoom-in'); | 49 testCursorRule('-webkit-zoom-in', '-webkit-zoom-in'); |
50 testCursorRule('-webkit-zoom-out'); | 50 testCursorRule('-webkit-zoom-out', '-webkit-zoom-out'); |
51 testCursorRule('url(file:///foo.png), crosshair'); | 51 testCursorRule('url(file:///foo.png), crosshair', 'url("file:///foo.png"), cross hair'); |
Timothy Loh
2015/09/24 07:53:21
just add quotes in the first argument instead of a
nainar
2015/09/25 04:10:18
Done.
| |
52 testCursorRule('url(file:///foo.png), url(file:///foo2.png), pointer'); | 52 testCursorRule('url(file:///foo.png), url(file:///foo2.png), pointer', 'url("fil e:///foo.png"), url("file:///foo2.png"), pointer'); |
53 testCursorRule('url(file:///foo.png) 12 3, pointer'); | 53 testCursorRule('url(file:///foo.png) 12 3, pointer', 'url("file:///foo.png") 12 3, pointer'); |
54 testCursorRule('url(file:///foo.png) 0 0, pointer'); | 54 testCursorRule('url(file:///foo.png) 0 0, pointer', 'url("file:///foo.png") 0 0, pointer'); |
55 testCursorRule('url(file:///foo.png) 12 3, url(file:///foo2.png), url(file:///fo o3.png) 6 7, crosshair'); | 55 testCursorRule('url(file:///foo.png) 12 3, url(file:///foo2.png), url(file:///fo o3.png) 6 7, crosshair', 'url("file:///foo.png") 12 3, url("file:///foo2.png"), url("file:///foo3.png") 6 7, crosshair'); |
56 testCursorRule('url(file:///foo.png) -2 3, pointer'); | 56 testCursorRule('url(file:///foo.png) -2 3, pointer', 'url("file:///foo.png") -2 3, pointer'); |
57 testCursorRule('url(file:///foo.png) 2 -3, pointer'); | 57 testCursorRule('url(file:///foo.png) 2 -3, pointer', 'url("file:///foo.png") 2 - 3, pointer'); |
58 testCursorRule('url(file:///foo.png) -1 -1, pointer'); | 58 testCursorRule('url(file:///foo.png) -1 -1, pointer', 'url("file:///foo.png") -1 -1, pointer'); |
59 | 59 |
60 debug(''); | 60 debug(''); |
61 debug('Test a bunch of invalid cursor rules which shouldn\'t parse at all.'); | 61 debug('Test a bunch of invalid cursor rules which shouldn\'t parse at all.'); |
62 testInvalidCursorRule('nonexistent'); | 62 testInvalidCursorRule('nonexistent'); |
63 testInvalidCursorRule('ltr'); | 63 testInvalidCursorRule('ltr'); |
64 testInvalidCursorRule('inline'); | 64 testInvalidCursorRule('inline'); |
65 testInvalidCursorRule('hand'); | 65 testInvalidCursorRule('hand'); |
66 testInvalidCursorRule('url(file:///foo.png)'); | 66 testInvalidCursorRule('url(file:///foo.png)'); |
67 testInvalidCursorRule('url(file:///foo.png), url(file:///foo2.png)'); | 67 testInvalidCursorRule('url(file:///foo.png), url(file:///foo2.png)'); |
68 testInvalidCursorRule('url(file:///foo.png) 12'); | 68 testInvalidCursorRule('url(file:///foo.png) 12'); |
69 testInvalidCursorRule('url(file:///foo.png) 12 3 5'); | 69 testInvalidCursorRule('url(file:///foo.png) 12 3 5'); |
70 testInvalidCursorRule('url(file:///foo.png) x y'); | 70 testInvalidCursorRule('url(file:///foo.png) x y'); |
71 testInvalidCursorRule('url(file:///foo.png) auto'); | 71 testInvalidCursorRule('url(file:///foo.png) auto'); |
72 | 72 |
73 successfullyParsed = true; | 73 successfullyParsed = true; |
74 </script> | 74 </script> |
75 </body> | 75 </body> |
76 </html> | 76 </html> |
OLD | NEW |