1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
6 // Tests loading a standard 128px icon.
8 url: 'chrome://extension-icon/gbmgkahjioeacddebbnengilkgbkhodg/128/0',
11 // Tests loading a standard 48px icon with a MATCH_SMALLER.
12 // This should not be resized to 48px.
14 url: 'chrome://extension-icon/gbmgkahjioeacddebbnengilkgbkhodg/48/2',
17 // Tests loading a standard 32px icon, grayscale. We assume that we actually
18 // got a grayscale image back here.
20 url: 'chrome://extension-icon/gbmgkahjioeacddebbnengilkgbkhodg/' +
21 '32/1?grayscale=true',
24 // Tests loading a 16px by resizing the 32px version (MATCH_BIGGER).
25 // This should be resized to 16px.
27 url: 'chrome://extension-icon/gbmgkahjioeacddebbnengilkgbkhodg/16/1',
32 var loadedImageCount = 0;
34 TEST_CASES.forEach(function(testCase) {
35 var img = document.createElement('img');
36 img.onload = function() {
37 if (img.naturalWidth != testCase.expectedSize ||
38 img.naturalHeight != testCase.expectedSize) {
39 document.title = 'Incorrect size on ' + testCase.url +
40 ' Expected: ' + testCase.expectedSize + 'x' + testCase.expectedSize +
41 ' Actual: ' + img.naturalWidth + 'x' + img.naturalHeight;
45 if (++loadedImageCount == TEST_CASES.length) {
46 document.title = 'Loaded';
49 img.onerror = function() {
50 // We failed to load an image that should have loaded.
51 document.title = 'Couldn\'t load ' + testCase.url;
53 img.src = testCase.url;
54 document.body.appendChild(img);