4 <script src=
"../../resources/js-test.js"></script>
7 <p id=
"description"></p>
8 <div id=
"console"></div>
10 description("Test the parsing of the cursor property.");
12 function makeCursorRule(rule
)
14 return "cursor: " + rule
+ ";";
17 function testCursorRule(rule
)
19 var cssText
= makeCursorRule(rule
);
20 shouldBeEqualToString('roundtripCssRule("' + cssText
+ '")', cssText
);
23 function testInvalidCursorRule(rule
)
25 shouldBeEqualToString('roundtripCssRule("' + makeCursorRule(rule
) + '")', '');
28 function roundtripCssRule(cssText
)
30 var div
= document
.createElement("div");
31 div
.setAttribute("style", cssText
);
32 document
.body
.appendChild(div
);
33 var result
= div
.style
.cssText
;
34 document
.body
.removeChild(div
);
38 // Note that any absolute URL will suffice for these tests (can't use relative URLs
39 // since they'll be converted to absolute form in the output). I chose file URLs just
40 // to avoid triggering any network activity.
42 debug('Test a bunch of cursor rules which should round-trip exactly.');
43 testCursorRule('auto');
44 testCursorRule('none');
45 testCursorRule('copy');
46 testCursorRule('zoom-in');
47 testCursorRule('zoom-out');
48 testCursorRule('-webkit-grabbing');
49 testCursorRule('-webkit-zoom-in');
50 testCursorRule('-webkit-zoom-out');
51 testCursorRule('url(file:///foo.png), crosshair');
52 testCursorRule('url(file:///foo.png), url(file:///foo2.png), pointer');
53 testCursorRule('url(file:///foo.png) 12 3, pointer');
54 testCursorRule('url(file:///foo.png) 0 0, pointer');
55 testCursorRule('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');
57 testCursorRule('url(file:///foo.png) 2 -3, pointer');
58 testCursorRule('url(file:///foo.png) -1 -1, pointer');
61 debug('Test a bunch of invalid cursor rules which shouldn\'t parse at all.');
62 testInvalidCursorRule('nonexistent');
63 testInvalidCursorRule('ltr');
64 testInvalidCursorRule('inline');
65 testInvalidCursorRule('hand');
66 testInvalidCursorRule('url(file:///foo.png)');
67 testInvalidCursorRule('url(file:///foo.png), url(file:///foo2.png)');
68 testInvalidCursorRule('url(file:///foo.png) 12');
69 testInvalidCursorRule('url(file:///foo.png) 12 3 5');
70 testInvalidCursorRule('url(file:///foo.png) x y');
71 testInvalidCursorRule('url(file:///foo.png) auto');
73 successfullyParsed
= true;