Skip to content

Commit 1d915fb

Browse files
committed
Fix bug with displaying browser extension icon
Resolves issue microsoft#1391 by updating `browserAction` to `action` and changing `document.createElement('canvas')` to `new offscreenCanvas(200, 200);`
1 parent cd6eddf commit 1d915fb

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

5-browser-extension/3-background-tasks-and-performance/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,12 @@ And finally, in `/dist/background.js`, add the listener for these background act
115115
```JavaScript
116116
chrome.runtime.onMessage.addListener(function (msg, sender, sendResponse) {
117117
if (msg.action === 'updateIcon') {
118-
chrome.browserAction.setIcon({ imageData: drawIcon(msg.value) });
118+
chrome.action.setIcon({ imageData: drawIcon(msg.value) });
119119
}
120120
});
121121
//borrowed from energy lollipop extension, nice feature!
122122
function drawIcon(value) {
123-
let canvas = document.createElement('canvas');
123+
let canvas = new OffscreenCanvas(200, 200);
124124
let context = canvas.getContext('2d');
125125

126126
context.beginPath();

5-browser-extension/solution/dist/background.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
chrome.runtime.onMessage.addListener(function (msg, sender, sendResponse) {
22
if (msg.action === 'updateIcon') {
3-
chrome.browserAction.setIcon({ imageData: drawIcon(msg.value) });
3+
chrome.action.setIcon({ imageData: drawIcon(msg.value) });
44
}
55
});
66
//borrowed from energy lollipop extension, nice feature!
77
function drawIcon(value) {
8-
let canvas = document.createElement('canvas');
8+
let canvas = new OffscreenCanvas(200, 200);
99
let context = canvas.getContext('2d');
1010

1111
context.beginPath();

0 commit comments

Comments
 (0)