Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(582)

Side by Side Diff: third_party/WebKit/LayoutTests/fast/css/cursor-parsing.html

Issue 1363233003: Make sure <url>s are being serialized according to spec (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Mac and Windows tests Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 var call = 'roundtripCssRule(`' + cssText + '`)';
21 shouldBeEqualToString(call, cssText);
21 } 22 }
22 23
23 function testInvalidCursorRule(rule) 24 function testInvalidCursorRule(rule)
24 { 25 {
25 shouldBeEqualToString('roundtripCssRule("' + makeCursorRule(rule) + '")', '' ); 26 shouldBeEqualToString('roundtripCssRule(`' + makeCursorRule(rule) + '`)', '' );
26 } 27 }
27 28
28 function roundtripCssRule(cssText) 29 function roundtripCssRule(cssText)
29 { 30 {
30 var div = document.createElement("div"); 31 var div = document.createElement("div");
31 div.setAttribute("style", cssText); 32 div.setAttribute("style", cssText);
32 document.body.appendChild(div); 33 document.body.appendChild(div);
33 var result = div.style.cssText; 34 var result = div.style.cssText;
34 document.body.removeChild(div); 35 document.body.removeChild(div);
35 return result; 36 return result;
36 } 37 }
37 38
38 // Note that any absolute URL will suffice for these tests (can't use relative U RLs 39 // 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 40 // since they'll be converted to absolute form in the output). I chose file URL s just
40 // to avoid triggering any network activity. 41 // to avoid triggering any network activity.
41 42
42 debug('Test a bunch of cursor rules which should round-trip exactly.'); 43 debug('Test a bunch of cursor rules which should round-trip exactly.');
43 testCursorRule('auto'); 44 testCursorRule('auto');
44 testCursorRule('none'); 45 testCursorRule('none');
45 testCursorRule('copy'); 46 testCursorRule('copy');
46 testCursorRule('zoom-in'); 47 testCursorRule('zoom-in');
47 testCursorRule('zoom-out'); 48 testCursorRule('zoom-out');
48 testCursorRule('-webkit-grabbing'); 49 testCursorRule('-webkit-grabbing');
49 testCursorRule('-webkit-zoom-in'); 50 testCursorRule('-webkit-zoom-in');
50 testCursorRule('-webkit-zoom-out'); 51 testCursorRule('-webkit-zoom-out');
51 testCursorRule('url(file:///foo.png), crosshair'); 52 testCursorRule('url("file:///foo.png"), crosshair');
52 testCursorRule('url(file:///foo.png), url(file:///foo2.png), pointer'); 53 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") 12 3, pointer');
54 testCursorRule('url(file:///foo.png) 0 0, pointer'); 55 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'); 56 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');
57 testCursorRule('url(file:///foo.png) 2 -3, pointer'); 58 testCursorRule('url("file:///foo.png") 2 -3, pointer');
58 testCursorRule('url(file:///foo.png) -1 -1, pointer'); 59 testCursorRule('url("file:///foo.png") -1 -1, pointer');
59 60
60 debug(''); 61 debug('');
61 debug('Test a bunch of invalid cursor rules which shouldn\'t parse at all.'); 62 debug('Test a bunch of invalid cursor rules which shouldn\'t parse at all.');
62 testInvalidCursorRule('nonexistent'); 63 testInvalidCursorRule('nonexistent');
63 testInvalidCursorRule('ltr'); 64 testInvalidCursorRule('ltr');
64 testInvalidCursorRule('inline'); 65 testInvalidCursorRule('inline');
65 testInvalidCursorRule('hand'); 66 testInvalidCursorRule('hand');
66 testInvalidCursorRule('url(file:///foo.png)'); 67 testInvalidCursorRule('url("file:///foo.png")');
67 testInvalidCursorRule('url(file:///foo.png), url(file:///foo2.png)'); 68 testInvalidCursorRule('url("file:///foo.png"), url("file:///foo2.png")');
68 testInvalidCursorRule('url(file:///foo.png) 12'); 69 testInvalidCursorRule('url("file:///foo.png") 12');
69 testInvalidCursorRule('url(file:///foo.png) 12 3 5'); 70 testInvalidCursorRule('url("file:///foo.png") 12 3 5');
70 testInvalidCursorRule('url(file:///foo.png) x y'); 71 testInvalidCursorRule('url("file:///foo.png") x y');
71 testInvalidCursorRule('url(file:///foo.png) auto'); 72 testInvalidCursorRule('url("file:///foo.png") auto');
72 73
73 successfullyParsed = true; 74 successfullyParsed = true;
74 </script> 75 </script>
75 </body> 76 </body>
76 </html> 77 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698