diff --git a/src/Image.cc b/src/Image.cc index 5a85f3b..2412d08 100644 --- a/src/Image.cc +++ b/src/Image.cc @@ -149,6 +149,7 @@ Image::Image() { complete = false; filename = (char *) ""; _surface = NULL; + width = height = 0; } /* diff --git a/test/image.test.js b/test/image.test.js index 57a7146..0c66119 100644 --- a/test/image.test.js +++ b/test/image.test.js @@ -53,6 +53,24 @@ module.exports = { img.src = png + 's'; assert.equal(img.src, png + 's'); + beforeExit(function(){ + assert.equal(1, n); + }); + }, + + 'test Image#{width,height}': function(assert, beforeExit){ + var img = new Image + , n = 0; + + assert.strictEqual(0, img.width); + assert.strictEqual(0, img.height); + img.onload = function(){ + ++n; + assert.strictEqual(150, img.width); + assert.strictEqual(150, img.height); + }; + img.src = png; + beforeExit(function(){ assert.equal(1, n); });