don't fail hard when getImageData is not allowed

This commit is contained in:
Florian Dold 2017-04-19 01:12:16 +02:00
parent 8d8f48fb14
commit e6e0cbc387
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B

View File

@ -150,11 +150,16 @@ export class ChromeBadge implements Badge {
// Allow running outside the extension for testing // Allow running outside the extension for testing
if (window["chrome"] && window.chrome["browserAction"]) { if (window["chrome"] && window.chrome["browserAction"]) {
let imageData = this.ctx.getImageData(0, try {
0, let imageData = this.ctx.getImageData(0,
this.canvas.width, 0,
this.canvas.height); this.canvas.width,
chrome.browserAction.setIcon({imageData}); this.canvas.height);
chrome.browserAction.setIcon({imageData});
} catch (e) {
// Might fail if browser has over-eager canvas fingerprinting countermeasures.
// There's nothing we can do then ...
}
} }
} }