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