OLD | NEW |
(Empty) | |
| 1 var TEST_CASES = [ |
| 2 // Tests loading a standard 128px icon. |
| 3 { |
| 4 url: 'chrome://extension-icon/gbmgkahjioeacddebbnengilkgbkhodg/128/0', |
| 5 expectedSize: 128 |
| 6 }, |
| 7 // Tests loading a standard 48px icon with a MATCH_SMALLER. |
| 8 // This should not be resized to 48px. |
| 9 { |
| 10 url: 'chrome://extension-icon/gbmgkahjioeacddebbnengilkgbkhodg/48/2', |
| 11 expectedSize: 32 |
| 12 }, |
| 13 // Tests loading a standard 32px icon, grayscale. We assume that we actually |
| 14 // got a grayscale image back here. |
| 15 { |
| 16 url: 'chrome://extension-icon/gbmgkahjioeacddebbnengilkgbkhodg/' + |
| 17 '32/1?grayscale=true', |
| 18 expectedSize: 32 |
| 19 }, |
| 20 // Tests loading a 16px by resizing the 32px version (MATCH_BIGGER). |
| 21 // This should be resized to 16px. |
| 22 { |
| 23 url: 'chrome://extension-icon/gbmgkahjioeacddebbnengilkgbkhodg/16/1', |
| 24 expectedSize: 16 |
| 25 } |
| 26 ]; |
| 27 |
| 28 var loadedImageCount = 0; |
| 29 |
| 30 TEST_CASES.forEach(function(testCase) { |
| 31 var img = document.createElement('img'); |
| 32 img.onload = function() { |
| 33 if (img.naturalWidth != testCase.expectedSize || |
| 34 img.naturalHeight != testCase.expectedSize) { |
| 35 document.title = 'Incorrect size on ' + testCase.url + |
| 36 ' Expected: ' + testCase.expectedSize + 'x' + testCase.expectedSize + |
| 37 ' Actual: ' + img.naturalWidth + 'x' + img.naturalHeight; |
| 38 return; |
| 39 } |
| 40 |
| 41 if (++loadedImageCount == TEST_CASES.length) { |
| 42 document.title = 'Loaded'; |
| 43 } |
| 44 }; |
| 45 img.onerror = function() { |
| 46 // We failed to load an image that should have loaded. |
| 47 document.title = 'Couldn\'t load ' + testCase.url; |
| 48 }; |
| 49 img.src = testCase.url; |
| 50 document.body.appendChild(img); |
| 51 }); |
OLD | NEW |