| 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() { | 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. | 23 // Test the case where a non-favicon URL is passed. |
| 24 function testGetFaviconImageSet_Origin() { | 24 function testGetFaviconImageSet_NonFavicon() { |
| 25 var url = 'http://foo.com'; | 25 var url = 'http://foo.com'; |
| 26 var expectedDesktop = '-webkit-image-set(' + | 26 var expectedDesktop = '-webkit-image-set(' + |
| 27 'url("chrome://favicon/size/16@1x/origin/http://foo.com") 1x, ' + | 27 'url("chrome://favicon/size/16@1x/http://foo.com") 1x, ' + |
| 28 'url("chrome://favicon/size/16@2x/origin/http://foo.com") 2x)'; | 28 'url("chrome://favicon/size/16@2x/http://foo.com") 2x)'; |
| 29 var expectedOther = '-webkit-image-set(' + | 29 var expectedOther = '-webkit-image-set(' + |
| 30 'url("chrome://favicon/size/16@1x/origin/http://foo.com") ' + | 30 'url("chrome://favicon/size/16@1x/http://foo.com") ' + |
| 31 window.devicePixelRatio + 'x)'; | 31 window.devicePixelRatio + 'x)'; |
| 32 | 32 |
| 33 var isDesktop = cr.isMac || cr.isChromeOS || cr.isWindows || cr.isLinux; | 33 var isDesktop = cr.isMac || cr.isChromeOS || cr.isWindows || cr.isLinux; |
| 34 var expected = isDesktop ? expectedDesktop : expectedOther; | 34 var expected = isDesktop ? expectedDesktop : expectedOther; |
| 35 assertEquals(expected, getFaviconImageSet(url)); | 35 assertEquals(expected, getFaviconImageSet(url)); |
| 36 } | 36 } |
| 37 | 37 |
| 38 // Test the case where the favicon URL is passed. | 38 // Test the case where the favicon URL is passed. |
| 39 function testGetFaviconImageSet_IconUrl() { | 39 function testGetFaviconImageSet_IconUrl() { |
| 40 var url = 'http://foo.com/foo.ico'; | 40 var url = 'http://foo.com/foo.ico'; |
| 41 var expectedDesktop = '-webkit-image-set(' + | 41 var expectedDesktop = '-webkit-image-set(' + |
| 42 'url("chrome://favicon/size/16@1x/iconurl/http://foo.com/foo.ico") 1x, ' + | 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)'; | 43 'url("chrome://favicon/size/16@2x/iconurl/http://foo.com/foo.ico") 2x)'; |
| 44 var expectedOther = '-webkit-image-set(' + | 44 var expectedOther = '-webkit-image-set(' + |
| 45 'url("chrome://favicon/size/16@1x/iconurl/http://foo.com/foo.ico") ' + | 45 'url("chrome://favicon/size/16@1x/iconurl/http://foo.com/foo.ico") ' + |
| 46 window.devicePixelRatio + 'x)'; | 46 window.devicePixelRatio + 'x)'; |
| 47 | 47 |
| 48 var isDesktop = cr.isMac || cr.isChromeOS || cr.isWindows || cr.isLinux; | 48 var isDesktop = cr.isMac || cr.isChromeOS || cr.isWindows || cr.isLinux; |
| 49 var expected = isDesktop ? expectedDesktop : expectedOther; | 49 var expected = isDesktop ? expectedDesktop : expectedOther; |
| 50 assertEquals(expected, getFaviconImageSet(url)); | 50 assertEquals(expected, getFaviconImageSet(url)); |
| 51 } | 51 } |
| 52 | 52 |
| 53 </script> | 53 </script> |
| 54 </body> | 54 </body> |
| 55 </html> | 55 </html> |
| OLD | NEW |