From 6b8833e7662a5a0a0dd82c0b6bb87ebd82f2b65a Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Fri, 23 Sep 2016 23:29:54 +0200 Subject: playground files --- lib/wallet/chromeBadge.ts | 18 +++++++++++------- playground/README | 1 + playground/animation.html | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 7 deletions(-) create mode 100644 playground/README create mode 100644 playground/animation.html 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() { diff --git a/playground/README b/playground/README new file mode 100644 index 000000000..9c3d9704a --- /dev/null +++ b/playground/README @@ -0,0 +1 @@ +Contains files with small experiments / prototypes for designers. diff --git a/playground/animation.html b/playground/animation.html new file mode 100644 index 000000000..eec913c65 --- /dev/null +++ b/playground/animation.html @@ -0,0 +1,34 @@ + + + + Spinner playground + + + +
+ +
+
+
+ +
+ + + + -- cgit v1.2.3