mercredi 22 avril 2015

Trying to mock an HTML5 canvas with JsMockito

I'm trying to use JsMockito to mock the HTML5 canvas object so that I can assert and verify interactions with the canvas and the context.

Can't really explain it any better than what you see in the fiddle: http://ift.tt/1JedVur

Javascript:

var canvas = document.getElementById('myCanvas');
var mockCanvas = spy(canvas);

I get different error messages in Chrome and Firefox.

Chrome Error message: Failed to set the 'contentEditable' property on 'HTMLElement'

FF Error message: 'width' setter called on an object that does not implement interface HTMLCanvasElement.

I'm not really clear on what is happening here. Any ideas?

Aucun commentaire:

Enregistrer un commentaire