aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2016-09-23 23:29:54 +0200
committerFlorian Dold <florian.dold@gmail.com>2016-09-23 23:29:58 +0200
commit6b8833e7662a5a0a0dd82c0b6bb87ebd82f2b65a (patch)
treeafd2f639c263a832331442ff82ef3c7d27bbdec7 /lib
parent9305ae23843f6c8ee69ed7c2bea9079f5ceb9013 (diff)
playground files
Diffstat (limited to 'lib')
-rw-r--r--lib/wallet/chromeBadge.ts18
1 files changed, 11 insertions, 7 deletions
diff --git a/lib/wallet/chromeBadge.ts b/lib/wallet/chromeBadge.ts
index a6e17c3d9..3d1f816d9 100644
--- a/lib/wallet/chromeBadge.ts
+++ b/lib/wallet/chromeBadge.ts
@@ -44,8 +44,9 @@ export class ChromeBadge implements Badge {
rotationAngle: number = 0;
static rotationAngleMax = 1000;
- constructor() {
- let bg = chrome.extension.getBackgroundPage();
+ constructor(window?: Window) {
+ // Allow injecting another window for testing
+ let bg = window || chrome.extension.getBackgroundPage();
this.canvas = bg.document.createElement("canvas");
this.canvas.width = 32;
this.canvas.height = 32;
@@ -76,11 +77,14 @@ export class ChromeBadge implements Badge {
this.talerLogo.height,
0, 0, this.canvas.width, this.canvas.height);
- let imageData = this.ctx.getImageData(0,
- 0,
- this.canvas.width,
- this.canvas.height);
- chrome.browserAction.setIcon({imageData});
+ // Allow running outside the extension for testing
+ if (chrome && chrome.browserAction) {
+ let imageData = this.ctx.getImageData(0,
+ 0,
+ this.canvas.width,
+ this.canvas.height);
+ chrome.browserAction.setIcon({imageData});
+ }
}
private animate() {