summaryrefslogtreecommitdiff
path: root/objects.js
diff options
context:
space:
mode:
authorjmoenig <jens@moenig.org>2013-09-18 15:34:59 +0200
committerjmoenig <jens@moenig.org>2013-09-18 15:34:59 +0200
commite9afcc9ec3e990eb1ebc79790fcf5048372858c1 (patch)
treed1dbf920aa3b93174adb70e9d57cf60d9c01ad98 /objects.js
parentc0a0c1f4a7a9f3cfd055288817530cf7c46bb26d (diff)
downloadsnap-yow-e9afcc9ec3e990eb1ebc79790fcf5048372858c1.tar.gz
snap-yow-e9afcc9ec3e990eb1ebc79790fcf5048372858c1.zip
prevent costumes with imported CORS-tainted canvases
expected to fix #155, #154, #151, #148, #147, #127 for future projects
Diffstat (limited to 'objects.js')
-rw-r--r--objects.js20
1 files changed, 19 insertions, 1 deletions
diff --git a/objects.js b/objects.js
index 9e61d58..398a61d 100644
--- a/objects.js
+++ b/objects.js
@@ -124,7 +124,7 @@ PrototypeHatBlockMorph*/
// Global stuff ////////////////////////////////////////////////////////
-modules.objects = '2013-September-17';
+modules.objects = '2013-September-18';
var SpriteMorph;
var StageMorph;
@@ -5246,6 +5246,24 @@ Costume.prototype.thumbnail = function (extentPoint) {
return trg;
};
+// Costume catching "tainted" canvases
+
+Costume.prototype.isTainted = function () {
+ // find out whether the canvas has been tainted by cross-origin data
+ // assumes that if reading image data throws an error it is tainted
+ try {
+ this.contents.getContext('2d').getImageData(
+ 0,
+ 0,
+ this.contents.width,
+ this.contents.height
+ );
+ } catch (err) {
+ return true;
+ }
+ return false;
+};
+
// SVG_Costume /////////////////////////////////////////////////////////////
/*