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

Side by Side Diff: chrome/test/data/webui/util_test.html

Issue 1914073005: Make getFaviconImageSet work with all expected URL types. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: case insensitive Created 4 years, 7 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 <body> 3 <body>
4 <script> 4 <script>
5 5
6 function testQuoteString() { 6 function testQuoteString() {
7 // Basic cases. 7 // Basic cases.
8 assertEquals('\"test\"', quoteString('"test"')); 8 assertEquals('\"test\"', quoteString('"test"'));
9 assertEquals('\\!\\?', quoteString('!?')); 9 assertEquals('\\!\\?', quoteString('!?'));
10 assertEquals('\\(\\._\\.\\) \\( \\:l \\) \\(\\.-\\.\\)', 10 assertEquals('\\(\\._\\.\\) \\( \\:l \\) \\(\\.-\\.\\)',
11 quoteString('(._.) ( :l ) (.-.)')); 11 quoteString('(._.) ( :l ) (.-.)'));
12 12
13 // Using the output as a regex. 13 // Using the output as a regex.
14 var re = new RegExp(quoteString('"hello"'), 'gim'); 14 var re = new RegExp(quoteString('"hello"'), 'gim');
15 var match = re.exec('She said "Hello" loudly'); 15 var match = re.exec('She said "Hello" loudly');
16 assertEquals(9, match.index); 16 assertEquals(9, match.index);
17 17
18 re = new RegExp(quoteString('Hello, .*'), 'gim'); 18 re = new RegExp(quoteString('Hello, .*'), 'gim');
19 match = re.exec('Hello, world'); 19 match = re.exec('Hello, world');
20 assertEquals(null, match); 20 assertEquals(null, match);
21 } 21 }
22 22
23 // Test the case where the origin URL is passed.
24 function testGetFaviconImageSet_Origin() {
25 var url = 'http://foo.com';
26 var expectedDesktop = '-webkit-image-set(' +
27 'url("chrome://favicon/size/16@1x/origin/http://foo.com") 1x, ' +
28 'url("chrome://favicon/size/16@2x/origin/http://foo.com") 2x)';
29 var expectedOther = '-webkit-image-set(' +
30 'url("chrome://favicon/size/16@1x/origin/http://foo.com") ' +
31 window.devicePixelRatio + 'x)';
32
33 var isDesktop = cr.isMac || cr.isChromeOS || cr.isWindows || cr.isLinux;
34 var expected = isDesktop ? expectedDesktop : expectedOther;
35 assertEquals(expected, getFaviconImageSet(url));
36 }
37
38 // Test the case where the favicon URL is passed.
39 function testGetFaviconImageSet_IconUrl() {
40 var url = 'http://foo.com/foo.ico';
41 var expectedDesktop = '-webkit-image-set(' +
42 'url("chrome://favicon/size/16@1x/iconurl/http://foo.com/foo.ico") 1x, ' +
43 'url("chrome://favicon/size/16@2x/iconurl/http://foo.com/foo.ico") 2x)';
44 var expectedOther = '-webkit-image-set(' +
45 'url("chrome://favicon/size/16@1x/iconurl/http://foo.com/foo.ico") ' +
46 window.devicePixelRatio + 'x)';
47
48 var isDesktop = cr.isMac || cr.isChromeOS || cr.isWindows || cr.isLinux;
49 var expected = isDesktop ? expectedDesktop : expectedOther;
50 assertEquals(expected, getFaviconImageSet(url));
51 }
52
23 </script> 53 </script>
24 </body> 54 </body>
25 </html> 55 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698