Browse Source

Fixed Image#{width,height} initialization to 0

v1.x
Tj Holowaychuk 14 years ago
parent
commit
b25d3e02fc
  1. 1
      src/Image.cc
  2. 18
      test/image.test.js

1
src/Image.cc

@ -149,6 +149,7 @@ Image::Image() {
complete = false; complete = false;
filename = (char *) ""; filename = (char *) "";
_surface = NULL; _surface = NULL;
width = height = 0;
} }
/* /*

18
test/image.test.js

@ -53,6 +53,24 @@ module.exports = {
img.src = png + 's'; img.src = png + 's';
assert.equal(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(){ beforeExit(function(){
assert.equal(1, n); assert.equal(1, n);
}); });

Loading…
Cancel
Save