Index: chrome/test/data/extensions/api_test/icons/extension_with_permission/index.js |
diff --git a/chrome/test/data/extensions/api_test/icons/extension_with_permission/index.js b/chrome/test/data/extensions/api_test/icons/extension_with_permission/index.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..f13ff376403e27a78cefaa46476879586ddc8ff5 |
--- /dev/null |
+++ b/chrome/test/data/extensions/api_test/icons/extension_with_permission/index.js |
@@ -0,0 +1,51 @@ |
+var TEST_CASES = [ |
+ // Tests loading a standard 128px icon. |
+ { |
+ url: 'chrome://extension-icon/gbmgkahjioeacddebbnengilkgbkhodg/128/0', |
+ expectedSize: 128 |
+ }, |
+ // Tests loading a standard 48px icon with a MATCH_SMALLER. |
+ // This should not be resized to 48px. |
+ { |
+ url: 'chrome://extension-icon/gbmgkahjioeacddebbnengilkgbkhodg/48/2', |
+ expectedSize: 32 |
+ }, |
+ // Tests loading a standard 32px icon, grayscale. We assume that we actually |
+ // got a grayscale image back here. |
+ { |
+ url: 'chrome://extension-icon/gbmgkahjioeacddebbnengilkgbkhodg/' + |
+ '32/1?grayscale=true', |
+ expectedSize: 32 |
+ }, |
+ // Tests loading a 16px by resizing the 32px version (MATCH_BIGGER). |
+ // This should be resized to 16px. |
+ { |
+ url: 'chrome://extension-icon/gbmgkahjioeacddebbnengilkgbkhodg/16/1', |
+ expectedSize: 16 |
+ } |
+]; |
+ |
+var loadedImageCount = 0; |
+ |
+TEST_CASES.forEach(function(testCase) { |
+ var img = document.createElement('img'); |
+ img.onload = function() { |
+ if (img.naturalWidth != testCase.expectedSize || |
+ img.naturalHeight != testCase.expectedSize) { |
+ document.title = 'Incorrect size on ' + testCase.url + |
+ ' Expected: ' + testCase.expectedSize + 'x' + testCase.expectedSize + |
+ ' Actual: ' + img.naturalWidth + 'x' + img.naturalHeight; |
+ return; |
+ } |
+ |
+ if (++loadedImageCount == TEST_CASES.length) { |
+ document.title = 'Loaded'; |
+ } |
+ }; |
+ img.onerror = function() { |
+ // We failed to load an image that should have loaded. |
+ document.title = 'Couldn\'t load ' + testCase.url; |
+ }; |
+ img.src = testCase.url; |
+ document.body.appendChild(img); |
+}); |