Update canvas tests to fix =~ usage and to mark passing tests as ok

This commit is contained in:
Vladimir Vukicevic 2010-03-03 16:40:27 -08:00
Родитель 90b432f3ea
Коммит 7e40b335aa
1 изменённых файлов: 49 добавлений и 48 удалений

Просмотреть файл

@ -3970,7 +3970,7 @@ var canvas = document.getElementById('c138');
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'rgba(255,255,255,0.45)';
ok(ctx.fillStyle =~ /^rgba\(255, 255, 255, 0\.4\d+\)$/, "ctx.fillStyle =~ /^rgba\\(255, 255, 255, 0\\.4\\d+\\)$/");
ok(/^rgba\(255, 255, 255, 0\.4\d+\)$/.test(ctx.fillStyle), "ctx.fillStyle =~ /^rgba\\(255, 255, 255, 0\\.4\\d+\\)$/");
}
@ -5411,7 +5411,7 @@ var ctx = canvas.getContext('2d');
ctx.fillStyle = '#f00';
ctx.fillStyle = 'ThreeDDarkShadow';
ok(ctx.fillStyle =~ /^#(?!(FF0000|ff0000|f00)$)/, "ctx.fillStyle =~ /^#(?!(FF0000|ff0000|f00)$)/"); // test that it's not red
ok(/^#(?!(FF0000|ff0000|f00)$)/.test(ctx.fillStyle), "ctx.fillStyle =~ /^#(?!(FF0000|ff0000|f00)$)/"); // test that it's not red
}
@ -7958,13 +7958,13 @@ var ctx = canvas.getContext('2d');
var _thrown = undefined; try {
ctx.getImageData(1, 1, 10, 0);
} catch (e) { _thrown = e }; todo(_thrown && _thrown.code == DOMException.INDEX_SIZE_ERR, "should throw INDEX_SIZE_ERR");
} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.INDEX_SIZE_ERR, "should throw INDEX_SIZE_ERR");
var _thrown = undefined; try {
ctx.getImageData(1, 1, 0, 10);
} catch (e) { _thrown = e }; todo(_thrown && _thrown.code == DOMException.INDEX_SIZE_ERR, "should throw INDEX_SIZE_ERR");
} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.INDEX_SIZE_ERR, "should throw INDEX_SIZE_ERR");
var _thrown = undefined; try {
ctx.getImageData(1, 1, 0, 0);
} catch (e) { _thrown = e }; todo(_thrown && _thrown.code == DOMException.INDEX_SIZE_ERR, "should throw INDEX_SIZE_ERR");
} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.INDEX_SIZE_ERR, "should throw INDEX_SIZE_ERR");
}
@ -7986,31 +7986,31 @@ var imgdata = ctx.getImageData(0, 0, 10, 10);
imgdata.data[0] = 100;
imgdata.data[0] = 300;
todo(imgdata.data[0] === 255, "imgdata.data[\""+(0)+"\"] === 255");
ok(imgdata.data[0] === 255, "imgdata.data[\""+(0)+"\"] === 255");
imgdata.data[0] = 100;
imgdata.data[0] = -100;
todo(imgdata.data[0] === 0, "imgdata.data[\""+(0)+"\"] === 0");
ok(imgdata.data[0] === 0, "imgdata.data[\""+(0)+"\"] === 0");
imgdata.data[0] = 100;
imgdata.data[0] = 200+Math.pow(2, 32);
todo(imgdata.data[0] === 255, "imgdata.data[\""+(0)+"\"] === 255");
ok(imgdata.data[0] === 255, "imgdata.data[\""+(0)+"\"] === 255");
imgdata.data[0] = 100;
imgdata.data[0] = -200-Math.pow(2, 32);
todo(imgdata.data[0] === 0, "imgdata.data[\""+(0)+"\"] === 0");
ok(imgdata.data[0] === 0, "imgdata.data[\""+(0)+"\"] === 0");
imgdata.data[0] = 100;
imgdata.data[0] = Math.pow(10, 39);
todo(imgdata.data[0] === 255, "imgdata.data[\""+(0)+"\"] === 255");
ok(imgdata.data[0] === 255, "imgdata.data[\""+(0)+"\"] === 255");
imgdata.data[0] = 100;
imgdata.data[0] = -Math.pow(10, 39);
todo(imgdata.data[0] === 0, "imgdata.data[\""+(0)+"\"] === 0");
ok(imgdata.data[0] === 0, "imgdata.data[\""+(0)+"\"] === 0");
imgdata.data[0] = 100;
imgdata.data[0] = -Infinity;
todo(imgdata.data[0] === 0, "imgdata.data[\""+(0)+"\"] === 0");
ok(imgdata.data[0] === 0, "imgdata.data[\""+(0)+"\"] === 0");
imgdata.data[0] = 100;
imgdata.data[0] = Infinity;
todo(imgdata.data[0] === 255, "imgdata.data[\""+(0)+"\"] === 255");
ok(imgdata.data[0] === 255, "imgdata.data[\""+(0)+"\"] === 255");
}
@ -8052,10 +8052,10 @@ var ctx = canvas.getContext('2d');
var imgdata = ctx.getImageData(0, 0, 10, 10);
imgdata.data[0] = 100;
imgdata.data[0] = NaN;
todo(imgdata.data[0] === 0, "imgdata.data[\""+(0)+"\"] === 0");
ok(imgdata.data[0] === 0, "imgdata.data[\""+(0)+"\"] === 0");
imgdata.data[0] = 100;
imgdata.data[0] = "cheese";
todo(imgdata.data[0] === 0, "imgdata.data[\""+(0)+"\"] === 0");
ok(imgdata.data[0] === 0, "imgdata.data[\""+(0)+"\"] === 0");
}
@ -8101,13 +8101,13 @@ var d = imgdata.data;
imgdata.width = 123;
imgdata.height = 123;
imgdata.data = [100,100,100,100];
todo(imgdata.width === w, "imgdata.width === w");
todo(imgdata.height === h, "imgdata.height === h");
todo(imgdata.data === d, "imgdata.data === d");
todo(imgdata.data[0] === 0, "imgdata.data[\""+(0)+"\"] === 0");
todo(imgdata.data[1] === 0, "imgdata.data[\""+(1)+"\"] === 0");
todo(imgdata.data[2] === 0, "imgdata.data[\""+(2)+"\"] === 0");
todo(imgdata.data[3] === 0, "imgdata.data[\""+(3)+"\"] === 0");
ok(imgdata.width === w, "imgdata.width === w");
ok(imgdata.height === h, "imgdata.height === h");
ok(imgdata.data === d, "imgdata.data === d");
ok(imgdata.data[0] === 0, "imgdata.data[\""+(0)+"\"] === 0");
ok(imgdata.data[1] === 0, "imgdata.data[\""+(1)+"\"] === 0");
ok(imgdata.data[2] === 0, "imgdata.data[\""+(2)+"\"] === 0");
ok(imgdata.data[3] === 0, "imgdata.data[\""+(3)+"\"] === 0");
}
@ -8127,27 +8127,27 @@ var ctx = canvas.getContext('2d');
var imgdata = ctx.getImageData(0, 0, 10, 10);
imgdata.data[0] = 0.499;
todo(imgdata.data[0] === 0, "imgdata.data[\""+(0)+"\"] === 0");
ok(imgdata.data[0] === 0, "imgdata.data[\""+(0)+"\"] === 0");
imgdata.data[0] = 0.5;
todo(imgdata.data[0] === 0, "imgdata.data[\""+(0)+"\"] === 0");
ok(imgdata.data[0] === 0, "imgdata.data[\""+(0)+"\"] === 0");
imgdata.data[0] = 0.501;
todo(imgdata.data[0] === 1, "imgdata.data[\""+(0)+"\"] === 1");
ok(imgdata.data[0] === 1, "imgdata.data[\""+(0)+"\"] === 1");
imgdata.data[0] = 1.499;
todo(imgdata.data[0] === 1, "imgdata.data[\""+(0)+"\"] === 1");
ok(imgdata.data[0] === 1, "imgdata.data[\""+(0)+"\"] === 1");
imgdata.data[0] = 1.5;
todo(imgdata.data[0] === 2, "imgdata.data[\""+(0)+"\"] === 2");
ok(imgdata.data[0] === 2, "imgdata.data[\""+(0)+"\"] === 2");
imgdata.data[0] = 1.501;
todo(imgdata.data[0] === 2, "imgdata.data[\""+(0)+"\"] === 2");
ok(imgdata.data[0] === 2, "imgdata.data[\""+(0)+"\"] === 2");
imgdata.data[0] = 2.5;
todo(imgdata.data[0] === 2, "imgdata.data[\""+(0)+"\"] === 2");
ok(imgdata.data[0] === 2, "imgdata.data[\""+(0)+"\"] === 2");
imgdata.data[0] = 3.5;
todo(imgdata.data[0] === 4, "imgdata.data[\""+(0)+"\"] === 4");
ok(imgdata.data[0] === 4, "imgdata.data[\""+(0)+"\"] === 4");
imgdata.data[0] = 252.5;
todo(imgdata.data[0] === 252, "imgdata.data[\""+(0)+"\"] === 252");
ok(imgdata.data[0] === 252, "imgdata.data[\""+(0)+"\"] === 252");
imgdata.data[0] = 253.5;
todo(imgdata.data[0] === 254, "imgdata.data[\""+(0)+"\"] === 254");
ok(imgdata.data[0] === 254, "imgdata.data[\""+(0)+"\"] === 254");
imgdata.data[0] = 254.5;
todo(imgdata.data[0] === 254, "imgdata.data[\""+(0)+"\"] === 254");
ok(imgdata.data[0] === 254, "imgdata.data[\""+(0)+"\"] === 254");
}
@ -8190,13 +8190,13 @@ var ctx = canvas.getContext('2d');
var imgdata = ctx.getImageData(0, 0, 10, 10);
imgdata.data[0] = 100;
imgdata.data[0] = "110";
todo(imgdata.data[0] === 110, "imgdata.data[\""+(0)+"\"] === 110");
ok(imgdata.data[0] === 110, "imgdata.data[\""+(0)+"\"] === 110");
imgdata.data[0] = 100;
imgdata.data[0] = "0x78";
todo(imgdata.data[0] === 120, "imgdata.data[\""+(0)+"\"] === 120");
ok(imgdata.data[0] === 120, "imgdata.data[\""+(0)+"\"] === 120");
imgdata.data[0] = 100;
imgdata.data[0] = " +130e0 ";
todo(imgdata.data[0] === 130, "imgdata.data[\""+(0)+"\"] === 130");
ok(imgdata.data[0] === 130, "imgdata.data[\""+(0)+"\"] === 130");
}
@ -8217,7 +8217,7 @@ var ctx = canvas.getContext('2d');
var imgdata = ctx.getImageData(0, 0, 10, 10);
imgdata.data[0] = 100;
imgdata.data[0] = undefined;
todo(imgdata.data[0] === 0, "imgdata.data[\""+(0)+"\"] === 0");
ok(imgdata.data[0] === 0, "imgdata.data[\""+(0)+"\"] === 0");
}
@ -8871,7 +8871,7 @@ var ctx = canvas.getContext('2d');
var _thrown = undefined; try {
ctx.putImageData(null, 0, 0);
} catch (e) { _thrown = e }; todo(_thrown && _thrown.code == DOMException.TYPE_MISMATCH_ERR, "should throw TYPE_MISMATCH_ERR");
} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.TYPE_MISMATCH_ERR, "should throw TYPE_MISMATCH_ERR");
}
@ -8986,10 +8986,10 @@ var _thrown = undefined; try {
} catch (e) { _thrown = e }; todo(_thrown && _thrown.code == DOMException.TYPE_MISMATCH_ERR, "should throw TYPE_MISMATCH_ERR");
var _thrown = undefined; try {
ctx.putImageData("cheese", 0, 0);
} catch (e) { _thrown = e }; todo(_thrown && _thrown.code == DOMException.TYPE_MISMATCH_ERR, "should throw TYPE_MISMATCH_ERR");
} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.TYPE_MISMATCH_ERR, "should throw TYPE_MISMATCH_ERR");
var _thrown = undefined; try {
ctx.putImageData(42, 0, 0);
} catch (e) { _thrown = e }; todo(_thrown && _thrown.code == DOMException.TYPE_MISMATCH_ERR, "should throw TYPE_MISMATCH_ERR");
} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.TYPE_MISMATCH_ERR, "should throw TYPE_MISMATCH_ERR");
}
@ -20461,7 +20461,7 @@ var _thrown_outer = false;
try {
var data = canvas.toDataURL('image/png', 'another argument that should not raise an exception');
ok(data =~ /^data:image\/png[;,]/, "data =~ /^data:image\\/png[;,]/");
ok(/^data:image\/png[;,]/.test(data), "data =~ /^data:image\\/png[;,]/");
} catch (e) {
_thrown_outer = true;
@ -20488,7 +20488,7 @@ var _thrown_outer = false;
try {
var data = canvas.toDataURL('image/png', 'another argument that should not raise an exception', 'and another');
ok(data =~ /^data:image\/png[;,]/, "data =~ /^data:image\\/png[;,]/");
ok(/^data:image\/png[;,]/.test(data), "data =~ /^data:image\\/png[;,]/");
} catch (e) {
_thrown_outer = true;
@ -20516,7 +20516,7 @@ try {
// More arguments that should not raise exceptions
var data = canvas.toDataURL('image/png', null, null, null);
ok(data =~ /^data:image\/png[;,]/, "data =~ /^data:image\\/png[;,]/");
ok(/^data:image\/png[;,]/.test(data), "data =~ /^data:image\\/png[;,]/");
} catch (e) {
_thrown_outer = true;
@ -20580,7 +20580,7 @@ var canvas = document.getElementById('c668');
var ctx = canvas.getContext('2d');
var data = canvas.toDataURL();
ok(data =~ /^data:image\/png[;,]/, "data =~ /^data:image\\/png[;,]/");
ok(/^data:image\/png[;,]/.test(data), "data =~ /^data:image\\/png[;,]/");
}
@ -20602,7 +20602,7 @@ var _thrown_outer = false;
try {
var data = canvas.toDataURL('ImAgE/PnG');
ok(data =~ /^data:image\/png[;,]/, "data =~ /^data:image\\/png[;,]/");
ok(/^data:image\/png[;,]/.test(data), "data =~ /^data:image\\/png[;,]/");
} catch (e) {
_thrown_outer = true;
@ -20626,8 +20626,9 @@ var canvas = document.getElementById('c670');
var ctx = canvas.getContext('2d');
var canvas2 = document.createElement('canvas');
var data = canvas2.toDataURL();
ok(data =~ /^data:image\/png[;,]/, "data =~ /^data:image\\/png[;,]/");
ok(/^data:image\/png[;,]/.test(data), "data =~ /^data:image\\/png[;,]/");
}
@ -20646,7 +20647,7 @@ var canvas = document.getElementById('c671');
var ctx = canvas.getContext('2d');
var data = canvas.toDataURL('image/png');
ok(data =~ /^data:image\/png[;,]/, "data =~ /^data:image\\/png[;,]/");
ok(/^data:image\/png[;,]/.test(data), "data =~ /^data:image\\/png[;,]/");
}
@ -20709,7 +20710,7 @@ var _thrown_outer = false;
try {
var data = canvas.toDataURL('image/example');
ok(data =~ /^data:image\/png[;,]/, "data =~ /^data:image\\/png[;,]/");
ok(/^data:image\/png[;,]/.test(data), "data =~ /^data:image\\/png[;,]/");
} catch (e) {
_thrown_outer = true;