JavaScript

Save image from a <canvas>-element

var canvas = document.querySelector('.widget-scene-canvas')
var image = canvas.toDataURL("image/png").replace("image/png", "image/octet-stream");
window.location.href = image;

Breakpoint on object property changed

Mozilla suggest to do this via Proxy-object since they removed console.watch an non standard interfaces.

var console = console || {}; // just in case
console.watch = function(oObj, sProp) {
   var sPrivateProp = "$_"+sProp+"_$"; // to minimize the name clash risk
   oObj[sPrivateProp] = oObj[sProp];

   // overwrite with accessor
   Object.defineProperty(oObj, sProp, {
       get: function () {
           return oObj[sPrivateProp];
       },

       set: function (value) {
           console.log("setting " + sProp + " to " + value); 
           console.trace()
           // debugger; // sets breakpoint
           oObj[sPrivateProp] = value;
       }
   });
}

Invocation:

console.watch(obj, “someProp”);
“`