Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(132)

Side by Side Diff: chrome/test/data/extensions/api_test/browser_action/no_icon/background.js

Issue 1580983002: Fix the dynamic browser action setIcon path to work with any size icon. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 var canvas = document.getElementById("canvas").getContext('2d'). 5 var canvas = document.getElementById("canvas").getContext('2d').
6 getImageData(0, 0, 19, 19); 6 getImageData(0, 0, 21, 21);
Devlin 2016/01/13 19:58:12 Were these chosen as sizes that are unused?
Evan Stade 2016/01/14 01:59:19 yea, pretty much arbitrary. As the comment in the
7 var canvasHD = document.getElementById("canvas").getContext('2d'). 7 var canvasHD = document.getElementById("canvas").getContext('2d').
8 getImageData(0, 0, 38, 38); 8 getImageData(0, 0, 42, 42);
9 9
10 var setIconParamQueue = [ 10 var setIconParamQueue = [
11 {imageData: canvas}, 11 {imageData: canvas},
12 {path: 'icon.png'}, 12 {path: 'icon.png'},
13 {imageData: {'19': canvas, '38': canvasHD}}, 13 {imageData: {'21': canvas, '42': canvasHD}},
14 {path: {'19': 'icon.png', '38': 'icon.png'}}, 14 {path: {'21': 'icon.png', '42': 'icon.png'}},
15 {imageData: {'19': canvas}}, 15 {imageData: {'21': canvas}},
16 {path: {'19': 'icon.png'}}, 16 {path: {'21': 'icon.png'}},
17 {imageData: {'38': canvasHD}}, 17 {imageData: {'42': canvasHD}},
18 {imageData: {}}, 18 {imageData: {}},
19 {path: {}}, 19 {path: {}},
20 ]; 20 ];
21 21
22 // Called when the user clicks on the browser action. 22 // Called when the user clicks on the browser action.
23 chrome.browserAction.onClicked.addListener(function(windowId) { 23 chrome.browserAction.onClicked.addListener(function(windowId) {
24 if (setIconParamQueue.length == 0) { 24 if (setIconParamQueue.length == 0) {
25 chrome.test.notifyFail("Queue of params for test cases unexpectedly empty"); 25 chrome.test.notifyFail("Queue of params for test cases unexpectedly empty");
26 return; 26 return;
27 } 27 }
28 28
29 try { 29 try {
30 chrome.browserAction.setIcon(setIconParamQueue.shift(), function() { 30 chrome.browserAction.setIcon(setIconParamQueue.shift(), function() {
31 chrome.test.notifyPass();}); 31 chrome.test.notifyPass();});
32 } catch (error) { 32 } catch (error) {
33 console.log(error.message); 33 console.log(error.message);
34 chrome.test.notifyFail(error.message); 34 chrome.test.notifyFail(error.message);
35 } 35 }
36 }); 36 });
37 37
38 chrome.test.notifyPass(); 38 chrome.test.notifyPass();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698