Quellcode-Bibliothek test_canvas.html
Sprache: HTML
|
|
| products/Sources/formale Sprachen/C/Firefox/dom/canvas/test/test_canvas.html |
 |
<!DOCTYPE HTML>
<title>Canvas Tests</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" href="/tests/SimpleTest/test.css">
<body>
<script>
SimpleTest.waitForExplicitFinish();
SimpleTest.requestFlakyTimeout("untriaged");
const Cc = SpecialPowers.Cc;
const Cr = SpecialPowers.Cr;
function IsD2DEnabled() {
var enabled = false;
try {
enabled = Cc["@mozilla.org/gfx/info;1"].getService(SpecialPowers.Ci.nsIGfxInfo).D2DEnabled;
} catch(e) {}
return enabled;
}
function IsLinux() {
var os = "";
try {
os = Cc["@mozilla.org/xre/app-info;1"]
.getService(SpecialPowers.Ci.nsIXULRuntime).OS;
} catch (e) {}
return os.indexOf("Linux") == 0 &&
!navigator.appVersion.includes("Android");
}
function IsWindows() {
var os = "";
try {
os = Cc["@mozilla.org/xre/app-info;1"]
.getService(SpecialPowers.Ci.nsIXULRuntime).OS;
} catch (e) {}
return os.indexOf("WINNT") == 0;
}
function IsAzureSkia() {
var enabled = false;
try {
var backend = Cc["@mozilla.org/gfx/info;1"].getService(SpecialPowers.Ci.nsIGfxInfo).AzureCanvasBackend;
enabled = (backend == "skia");
} catch (e) { }
return enabled;
}
function IsAzureCairo() {
var enabled = false;
try {
var backend = Cc["@mozilla.org/gfx/info;1"].getService(SpecialPowers.Ci.nsIGfxInfo).AzureCanvasBackend;
enabled = (backend == "cairo");
} catch (e) { }
return enabled;
}
</script>
<!-- Includes all the tests in the dom/canvas/tests except for test_bug397524.html -->
<!-- [[[ test_2d.canvas.readonly.html ]]] -->
<p>Canvas test: 2d.canvas.readonly</p>
<!-- Testing: CanvasRenderingContext2D.canvas is readonly -->
<canvas id="c1" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_canvas_readonly() {
var canvas = document.getElementById('c1');
var ctx = canvas.getContext('2d');
var c = document.createElement('canvas');
var d = ctx.canvas;
ok(c !== d, "c !== d");
try { ctx.canvas = c; } catch (e) {} // not sure whether this should throw or not...
ok(ctx.canvas === d, "ctx.canvas === d");
}
</script>
<!-- [[[ test_2d.canvas.reference.html ]]] -->
<p>Canvas test: 2d.canvas.reference</p>
<!-- Testing: CanvasRenderingContext2D.canvas refers back to its canvas -->
<canvas id="c2" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_canvas_reference() {
var canvas = document.getElementById('c2');
var ctx = canvas.getContext('2d');
ok(ctx.canvas === canvas, "ctx.canvas === canvas");
}
</script>
<!-- [[[ test_2d.clearRect.basic.html ]]] -->
<p>Canvas test: 2d.clearRect.basic</p>
<canvas id="c3" width="100" height="50" style="background: #0f0"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function isPixel(ctx, x,y, r,g,b,a, d) {
var pos = x + "," + y;
var colour = r + "," + g + "," + b + "," + a;
var pixel = ctx.getImageData(x, y, 1, 1);
var pr = pixel.data[0],
pg = pixel.data[1],
pb = pixel.data[2],
pa = pixel.data[3];
ok(r-d <= pr && pr <= r+d &&
g-d <= pg && pg <= g+d &&
b-d <= pb && pb <= b+d &&
a-d <= pa && pa <= a+d,
"pixel "+pos+" of "+ctx.canvas.id+" is "+pr+","+pg+","+pb+","+pa+"; expected "+colour+" +/- "+d);
}
function test_2d_clearRect_basic() {
var canvas = document.getElementById('c3');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#f00';
ctx.fillRect(0, 0, 100, 50);
ctx.clearRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,0,0,0, 0);
}
</script>
<!-- [[[ test_2d.clearRect.clip.html ]]] -->
<p>Canvas test: 2d.clearRect.clip</p>
<canvas id="c4" width="100" height="50" style="background: #f00"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_clearRect_clip() {
var canvas = document.getElementById('c4');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#0f0';
ctx.fillRect(0, 0, 100, 50);
ctx.beginPath();
ctx.rect(0, 0, 16, 16);
ctx.clip();
ctx.clearRect(0, 0, 100, 50);
ctx.fillStyle = '#0f0';
ctx.fillRect(0, 0, 16, 16);
isPixel(ctx, 50,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.clearRect.globalalpha.html ]]] -->
<p>Canvas test: 2d.clearRect.globalalpha</p>
<canvas id="c5" width="100" height="50" style="background: #0f0"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_clearRect_globalalpha() {
var canvas = document.getElementById('c5');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#f00';
ctx.fillRect(0, 0, 100, 50);
ctx.globalAlpha = 0.1;
ctx.clearRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,0,0,0, 0);
}
</script>
<!-- [[[ test_2d.clearRect.globalcomposite.html ]]] -->
<p>Canvas test: 2d.clearRect.globalcomposite</p>
<canvas id="c6" width="100" height="50" style="background: #0f0"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_clearRect_globalcomposite() {
var canvas = document.getElementById('c6');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#f00';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'destination-atop';
ctx.clearRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,0,0,0, 0);
}
</script>
<!-- [[[ test_2d.clearRect.negative.html ]]] -->
<p>Canvas test: 2d.clearRect.negative</p>
<canvas id="c7" width="100" height="50" style="background: #0f0"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_clearRect_negative() {
var canvas = document.getElementById('c7');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#f00';
ctx.fillRect(0, 0, 100, 50);
ctx.clearRect(0, 0, 50, 25);
ctx.clearRect(100, 0, -50, 25);
ctx.clearRect(0, 50, 50, -25);
ctx.clearRect(100, 50, -50, -25);
isPixel(ctx, 25,12, 0,0,0,0, 0);
isPixel(ctx, 75,12, 0,0,0,0, 0);
isPixel(ctx, 25,37, 0,0,0,0, 0);
isPixel(ctx, 75,37, 0,0,0,0, 0);
}
</script>
<!-- [[[ test_2d.clearRect.nonfinite.html ]]] -->
<p>Canvas test: 2d.clearRect.nonfinite</p>
<!-- Testing: clearRect() with Infinity/NaN is ignored -->
<canvas id="c8" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_clearRect_nonfinite() {
var canvas = document.getElementById('c8');
var ctx = canvas.getContext('2d');
var _thrown_outer = false;
try {
ctx.fillStyle = '#0f0';
ctx.fillRect(0, 0, 100, 50);
ctx.clearRect(Infinity, 0, 100, 50);
ctx.clearRect(-Infinity, 0, 100, 50);
ctx.clearRect(NaN, 0, 100, 50);
ctx.clearRect(0, Infinity, 100, 50);
ctx.clearRect(0, -Infinity, 100, 50);
ctx.clearRect(0, NaN, 100, 50);
ctx.clearRect(0, 0, Infinity, 50);
ctx.clearRect(0, 0, -Infinity, 50);
ctx.clearRect(0, 0, NaN, 50);
ctx.clearRect(0, 0, 100, Infinity);
ctx.clearRect(0, 0, 100, -Infinity);
ctx.clearRect(0, 0, 100, NaN);
ctx.clearRect(Infinity, Infinity, 100, 50);
ctx.clearRect(Infinity, Infinity, Infinity, 50);
ctx.clearRect(Infinity, Infinity, Infinity, Infinity);
ctx.clearRect(Infinity, Infinity, 100, Infinity);
ctx.clearRect(Infinity, 0, Infinity, 50);
ctx.clearRect(Infinity, 0, Infinity, Infinity);
ctx.clearRect(Infinity, 0, 100, Infinity);
ctx.clearRect(0, Infinity, Infinity, 50);
ctx.clearRect(0, Infinity, Infinity, Infinity);
ctx.clearRect(0, Infinity, 100, Infinity);
ctx.clearRect(0, 0, Infinity, Infinity);
isPixel(ctx, 50,25, 0,255,0,255, 0);
} catch (e) {
_thrown_outer = true;
}
ok(!_thrown_outer, ctx.canvas.id + ' should not throw exception');
}
</script>
<!-- [[[ test_2d.clearRect.path.html ]]] -->
<p>Canvas test: 2d.clearRect.path</p>
<canvas id="c9" width="100" height="50" style="background: #f00"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_clearRect_path() {
var canvas = document.getElementById('c9');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#0f0';
ctx.beginPath();
ctx.rect(0, 0, 100, 50);
ctx.clearRect(0, 0, 16, 16);
ctx.fill();
isPixel(ctx, 50,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.clearRect.shadow.html ]]] -->
<p>Canvas test: 2d.clearRect.shadow</p>
<canvas id="c10" width="100" height="50" style="background: #f00"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_clearRect_shadow() {
var canvas = document.getElementById('c10');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#0f0';
ctx.fillRect(0, 0, 100, 50);
ctx.shadowColor = '#f00';
ctx.shadowBlur = 0;
ctx.shadowOffsetX = 0;
ctx.shadowOffsetY = 50;
ctx.clearRect(0, -50, 100, 50);
isPixel(ctx, 50,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.clearRect.transform.html ]]] -->
<p>Canvas test: 2d.clearRect.transform</p>
<canvas id="c11" width="100" height="50" style="background: #0f0"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_clearRect_transform() {
var canvas = document.getElementById('c11');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#f00';
ctx.fillRect(0, 0, 100, 50);
ctx.scale(10, 10);
ctx.translate(0, 5);
ctx.clearRect(0, -5, 10, 5);
isPixel(ctx, 50,25, 0,0,0,0, 0);
}
</script>
<!-- [[[ test_2d.clearRect.zero.html ]]] -->
<p>Canvas test: 2d.clearRect.zero</p>
<canvas id="c12" width="100" height="50" style="background: #f00"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_clearRect_zero() {
var canvas = document.getElementById('c12');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#0f0';
ctx.fillRect(0, 0, 100, 50);
ctx.clearRect(0, 0, 100, 0);
ctx.clearRect(0, 0, 0, 50);
ctx.clearRect(0, 0, 0, 0);
isPixel(ctx, 50,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.composite.canvas.copy.html ]]] -->
<p>Canvas test: 2d.composite.canvas.copy</p>
<canvas id="c13" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_canvas_copy() {
var canvas = document.getElementById('c13');
var ctx = canvas.getContext('2d');
var canvas2 = document.createElement('canvas');
canvas2.width = canvas.width;
canvas2.height = canvas.height;
var ctx2 = canvas2.getContext('2d');
ctx2.drawImage(document.getElementById('yellow75_1.png'), 0, 0);
ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'copy';
ctx.drawImage(canvas2, 0, 0);
isPixel(ctx, 50,25, 255,255,0,191, 5);
}
</script>
<img src="image_yellow75.png" id="yellow75_1.png" class="resource">
<!-- [[[ test_2d.composite.canvas.destination-atop.html ]]] -->
<p>Canvas test: 2d.composite.canvas.destination-atop</p>
<canvas id="c14" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_canvas_destination_atop() {
var canvas = document.getElementById('c14');
var ctx = canvas.getContext('2d');
var canvas2 = document.createElement('canvas');
canvas2.width = canvas.width;
canvas2.height = canvas.height;
var ctx2 = canvas2.getContext('2d');
ctx2.drawImage(document.getElementById('yellow75_2.png'), 0, 0);
ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'destination-atop';
ctx.drawImage(canvas2, 0, 0);
isPixel(ctx, 50,25, 127,255,127,191, 5);
}
</script>
<img src="image_yellow75.png" id="yellow75_2.png" class="resource">
<!-- [[[ test_2d.composite.canvas.destination-in.html ]]] -->
<p>Canvas test: 2d.composite.canvas.destination-in</p>
<canvas id="c15" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_canvas_destination_in() {
var canvas = document.getElementById('c15');
var ctx = canvas.getContext('2d');
var canvas2 = document.createElement('canvas');
canvas2.width = canvas.width;
canvas2.height = canvas.height;
var ctx2 = canvas2.getContext('2d');
ctx2.drawImage(document.getElementById('yellow75_3.png'), 0, 0);
ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'destination-in';
ctx.drawImage(canvas2, 0, 0);
isPixel(ctx, 50,25, 0,255,255,95, 5);
}
</script>
<img src="image_yellow75.png" id="yellow75_3.png" class="resource">
<!-- [[[ test_2d.composite.canvas.destination-out.html ]]] -->
<p>Canvas test: 2d.composite.canvas.destination-out</p>
<canvas id="c16" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_canvas_destination_out() {
var canvas = document.getElementById('c16');
var ctx = canvas.getContext('2d');
var canvas2 = document.createElement('canvas');
canvas2.width = canvas.width;
canvas2.height = canvas.height;
var ctx2 = canvas2.getContext('2d');
ctx2.drawImage(document.getElementById('yellow75_4.png'), 0, 0);
ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'destination-out';
ctx.drawImage(canvas2, 0, 0);
isPixel(ctx, 50,25, 0,255,255,31, 5);
}
</script>
<img src="image_yellow75.png" id="yellow75_4.png" class="resource">
<!-- [[[ test_2d.composite.canvas.destination-over.html ]]] -->
<p>Canvas test: 2d.composite.canvas.destination-over</p>
<canvas id="c17" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_canvas_destination_over() {
var canvas = document.getElementById('c17');
var ctx = canvas.getContext('2d');
var canvas2 = document.createElement('canvas');
canvas2.width = canvas.width;
canvas2.height = canvas.height;
var ctx2 = canvas2.getContext('2d');
ctx2.drawImage(document.getElementById('yellow75_5.png'), 0, 0);
ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'destination-over';
ctx.drawImage(canvas2, 0, 0);
isPixel(ctx, 50,25, 109,255,145,223, 5);
}
</script>
<img src="image_yellow75.png" id="yellow75_5.png" class="resource">
<!-- [[[ test_2d.composite.canvas.lighter.html ]]] -->
<p>Canvas test: 2d.composite.canvas.lighter</p>
<canvas id="c18" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_canvas_lighter() {
var canvas = document.getElementById('c18');
var ctx = canvas.getContext('2d');
var canvas2 = document.createElement('canvas');
canvas2.width = canvas.width;
canvas2.height = canvas.height;
var ctx2 = canvas2.getContext('2d');
ctx2.drawImage(document.getElementById('yellow75_6.png'), 0, 0);
ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'lighter';
ctx.drawImage(canvas2, 0, 0);
isPixel(ctx, 50,25, 191,255,127,255, 5);
}
</script>
<img src="image_yellow75.png" id="yellow75_6.png" class="resource">
<!-- [[[ test_2d.composite.canvas.source-atop.html ]]] -->
<p>Canvas test: 2d.composite.canvas.source-atop</p>
<canvas id="c19" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_canvas_source_atop() {
var canvas = document.getElementById('c19');
var ctx = canvas.getContext('2d');
var canvas2 = document.createElement('canvas');
canvas2.width = canvas.width;
canvas2.height = canvas.height;
var ctx2 = canvas2.getContext('2d');
ctx2.drawImage(document.getElementById('yellow75_7.png'), 0, 0);
ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'source-atop';
ctx.drawImage(canvas2, 0, 0);
isPixel(ctx, 50,25, 191,255,63,127, 5);
}
</script>
<img src="image_yellow75.png" id="yellow75_7.png" class="resource">
<!-- [[[ test_2d.composite.canvas.source-in.html ]]] -->
<p>Canvas test: 2d.composite.canvas.source-in</p>
<canvas id="c20" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_canvas_source_in() {
var canvas = document.getElementById('c20');
var ctx = canvas.getContext('2d');
var canvas2 = document.createElement('canvas');
canvas2.width = canvas.width;
canvas2.height = canvas.height;
var ctx2 = canvas2.getContext('2d');
ctx2.drawImage(document.getElementById('yellow75_8.png'), 0, 0);
ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'source-in';
ctx.drawImage(canvas2, 0, 0);
isPixel(ctx, 50,25, 255,255,0,95, 5);
}
</script>
<img src="image_yellow75.png" id="yellow75_8.png" class="resource">
<!-- [[[ test_2d.composite.canvas.source-out.html ]]] -->
<p>Canvas test: 2d.composite.canvas.source-out</p>
<canvas id="c21" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_canvas_source_out() {
var canvas = document.getElementById('c21');
var ctx = canvas.getContext('2d');
var canvas2 = document.createElement('canvas');
canvas2.width = canvas.width;
canvas2.height = canvas.height;
var ctx2 = canvas2.getContext('2d');
ctx2.drawImage(document.getElementById('yellow75_9.png'), 0, 0);
ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'source-out';
ctx.drawImage(canvas2, 0, 0);
isPixel(ctx, 50,25, 255,255,0,95, 5);
}
</script>
<img src="image_yellow75.png" id="yellow75_9.png" class="resource">
<!-- [[[ test_2d.composite.canvas.source-over.html ]]] -->
<p>Canvas test: 2d.composite.canvas.source-over</p>
<canvas id="c22" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_canvas_source_over() {
var canvas = document.getElementById('c22');
var ctx = canvas.getContext('2d');
var canvas2 = document.createElement('canvas');
canvas2.width = canvas.width;
canvas2.height = canvas.height;
var ctx2 = canvas2.getContext('2d');
ctx2.drawImage(document.getElementById('yellow75_10.png'), 0, 0);
ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'source-over';
ctx.drawImage(canvas2, 0, 0);
isPixel(ctx, 50,25, 218,255,36,223, 5);
}
</script>
<img src="image_yellow75.png" id="yellow75_10.png" class="resource">
<!-- [[[ test_2d.composite.canvas.xor.html ]]] -->
<p>Canvas test: 2d.composite.canvas.xor</p>
<canvas id="c23" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_canvas_xor() {
var canvas = document.getElementById('c23');
var ctx = canvas.getContext('2d');
var canvas2 = document.createElement('canvas');
canvas2.width = canvas.width;
canvas2.height = canvas.height;
var ctx2 = canvas2.getContext('2d');
ctx2.drawImage(document.getElementById('yellow75_11.png'), 0, 0);
ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'xor';
ctx.drawImage(canvas2, 0, 0);
isPixel(ctx, 50,25, 191,255,63,127, 5);
}
</script>
<img src="image_yellow75.png" id="yellow75_11.png" class="resource">
<!-- [[[ test_2d.composite.clip.copy.html ]]] -->
<p>Canvas test: 2d.composite.clip.copy</p>
<!-- Testing: fill() does not affect pixels outside the clip region. -->
<canvas id="c24" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_clip_copy() {
var canvas = document.getElementById('c24');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#0f0';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'copy';
ctx.rect(-20, -20, 10, 10);
ctx.clip();
ctx.fillStyle = '#f00';
ctx.fillRect(0, 0, 50, 50);
isPixel(ctx, 25,25, 0,255,0,255, 0);
isPixel(ctx, 75,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.composite.clip.destination-atop.html ]]] -->
<p>Canvas test: 2d.composite.clip.destination-atop</p>
<!-- Testing: fill() does not affect pixels outside the clip region. -->
<canvas id="c25" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_clip_destination_atop() {
var canvas = document.getElementById('c25');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#0f0';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'destination-atop';
ctx.rect(-20, -20, 10, 10);
ctx.clip();
ctx.fillStyle = '#f00';
ctx.fillRect(0, 0, 50, 50);
isPixel(ctx, 25,25, 0,255,0,255, 0);
isPixel(ctx, 75,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.composite.clip.destination-in.html ]]] -->
<p>Canvas test: 2d.composite.clip.destination-in</p>
<!-- Testing: fill() does not affect pixels outside the clip region. -->
<canvas id="c26" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_clip_destination_in() {
var canvas = document.getElementById('c26');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#0f0';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'destination-in';
ctx.rect(-20, -20, 10, 10);
ctx.clip();
ctx.fillStyle = '#f00';
ctx.fillRect(0, 0, 50, 50);
isPixel(ctx, 25,25, 0,255,0,255, 0);
isPixel(ctx, 75,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.composite.clip.destination-out.html ]]] -->
<p>Canvas test: 2d.composite.clip.destination-out</p>
<!-- Testing: fill() does not affect pixels outside the clip region. -->
<canvas id="c27" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_clip_destination_out() {
var canvas = document.getElementById('c27');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#0f0';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'destination-out';
ctx.rect(-20, -20, 10, 10);
ctx.clip();
ctx.fillStyle = '#f00';
ctx.fillRect(0, 0, 50, 50);
isPixel(ctx, 25,25, 0,255,0,255, 0);
isPixel(ctx, 75,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.composite.clip.destination-over.html ]]] -->
<p>Canvas test: 2d.composite.clip.destination-over</p>
<!-- Testing: fill() does not affect pixels outside the clip region. -->
<canvas id="c28" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_clip_destination_over() {
var canvas = document.getElementById('c28');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#0f0';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'destination-over';
ctx.rect(-20, -20, 10, 10);
ctx.clip();
ctx.fillStyle = '#f00';
ctx.fillRect(0, 0, 50, 50);
isPixel(ctx, 25,25, 0,255,0,255, 0);
isPixel(ctx, 75,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.composite.clip.lighter.html ]]] -->
<p>Canvas test: 2d.composite.clip.lighter</p>
<!-- Testing: fill() does not affect pixels outside the clip region. -->
<canvas id="c29" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_clip_lighter() {
var canvas = document.getElementById('c29');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#0f0';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'lighter';
ctx.rect(-20, -20, 10, 10);
ctx.clip();
ctx.fillStyle = '#f00';
ctx.fillRect(0, 0, 50, 50);
isPixel(ctx, 25,25, 0,255,0,255, 0);
isPixel(ctx, 75,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.composite.clip.source-atop.html ]]] -->
<p>Canvas test: 2d.composite.clip.source-atop</p>
<!-- Testing: fill() does not affect pixels outside the clip region. -->
<canvas id="c30" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_clip_source_atop() {
var canvas = document.getElementById('c30');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#0f0';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'source-atop';
ctx.rect(-20, -20, 10, 10);
ctx.clip();
ctx.fillStyle = '#f00';
ctx.fillRect(0, 0, 50, 50);
isPixel(ctx, 25,25, 0,255,0,255, 0);
isPixel(ctx, 75,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.composite.clip.source-in.html ]]] -->
<p>Canvas test: 2d.composite.clip.source-in</p>
<!-- Testing: fill() does not affect pixels outside the clip region. -->
<canvas id="c31" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_clip_source_in() {
var canvas = document.getElementById('c31');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#0f0';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'source-in';
ctx.rect(-20, -20, 10, 10);
ctx.clip();
ctx.fillStyle = '#f00';
ctx.fillRect(0, 0, 50, 50);
isPixel(ctx, 25,25, 0,255,0,255, 0);
isPixel(ctx, 75,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.composite.clip.source-out.html ]]] -->
<p>Canvas test: 2d.composite.clip.source-out</p>
<!-- Testing: fill() does not affect pixels outside the clip region. -->
<canvas id="c32" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_clip_source_out() {
var canvas = document.getElementById('c32');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#0f0';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'source-out';
ctx.rect(-20, -20, 10, 10);
ctx.clip();
ctx.fillStyle = '#f00';
ctx.fillRect(0, 0, 50, 50);
isPixel(ctx, 25,25, 0,255,0,255, 0);
isPixel(ctx, 75,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.composite.clip.source-over.html ]]] -->
<p>Canvas test: 2d.composite.clip.source-over</p>
<!-- Testing: fill() does not affect pixels outside the clip region. -->
<canvas id="c33" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_clip_source_over() {
var canvas = document.getElementById('c33');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#0f0';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'source-over';
ctx.rect(-20, -20, 10, 10);
ctx.clip();
ctx.fillStyle = '#f00';
ctx.fillRect(0, 0, 50, 50);
isPixel(ctx, 25,25, 0,255,0,255, 0);
isPixel(ctx, 75,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.composite.clip.xor.html ]]] -->
<p>Canvas test: 2d.composite.clip.xor</p>
<!-- Testing: fill() does not affect pixels outside the clip region. -->
<canvas id="c34" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_clip_xor() {
var canvas = document.getElementById('c34');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#0f0';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'xor';
ctx.rect(-20, -20, 10, 10);
ctx.clip();
ctx.fillStyle = '#f00';
ctx.fillRect(0, 0, 50, 50);
isPixel(ctx, 25,25, 0,255,0,255, 0);
isPixel(ctx, 75,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.composite.globalAlpha.canvas.html ]]] -->
<p>Canvas test: 2d.composite.globalAlpha.canvas</p>
<canvas id="c35" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_globalAlpha_canvas() {
var canvas = document.getElementById('c35');
var ctx = canvas.getContext('2d');
var canvas2 = document.createElement('canvas');
canvas2.width = 100;
canvas2.height = 50;
var ctx2 = canvas2.getContext('2d');
ctx2.fillStyle = '#f00';
ctx2.fillRect(0, 0, 100, 50);
ctx.fillStyle = '#0f0';
ctx.fillRect(0, 0, 100, 50);
ctx.globalAlpha = 0.01; // avoid any potential alpha=0 optimisations
ctx.drawImage(canvas2, 0, 0);
isPixel(ctx, 50,25, 2,253,0,255, 2);
}
</script>
<!-- [[[ test_2d.composite.globalAlpha.canvaspattern.html ]]] -->
<p>Canvas test: 2d.composite.globalAlpha.canvaspattern - bug 401790</p>
<canvas id="c36" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function todo_isPixel(ctx, x,y, r,g,b,a, d) {
var pos = x + "," + y;
var colour = r + "," + g + "," + b + "," + a;
var pixel = ctx.getImageData(x, y, 1, 1);
var pr = pixel.data[0],
pg = pixel.data[1],
pb = pixel.data[2],
pa = pixel.data[3];
todo(r-d <= pr && pr <= r+d &&
g-d <= pg && pg <= g+d &&
b-d <= pb && pb <= b+d &&
a-d <= pa && pa <= a+d,
"pixel "+pos+" of "+ctx.canvas.id+" is "+pr+","+pg+","+pb+","+pa+" (marked todo); expected "+colour+" +/- " + d);
}
function test_2d_composite_globalAlpha_canvaspattern() {
var canvas = document.getElementById('c36');
var ctx = canvas.getContext('2d');
var canvas2 = document.createElement('canvas');
canvas2.width = 100;
canvas2.height = 50;
var ctx2 = canvas2.getContext('2d');
ctx2.fillStyle = '#f00';
ctx2.fillRect(0, 0, 100, 50);
ctx.fillStyle = '#0f0';
ctx.fillRect(0, 0, 100, 50);
ctx.fillStyle = ctx.createPattern(canvas2, 'no-repeat');
ctx.globalAlpha = 0.01; // avoid any potential alpha=0 optimisations
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 2,253,0,255, 2);
}
</script>
<!-- [[[ test_2d.composite.globalAlpha.default.html ]]] -->
<p>Canvas test: 2d.composite.globalAlpha.default</p>
<canvas id="c37" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_globalAlpha_default() {
var canvas = document.getElementById('c37');
var ctx = canvas.getContext('2d');
ok(ctx.globalAlpha === 1.0, "ctx.globalAlpha === 1.0");
}
</script>
<!-- [[[ test_2d.composite.globalAlpha.fill.html ]]] -->
<p>Canvas test: 2d.composite.globalAlpha.fill</p>
<canvas id="c38" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_globalAlpha_fill() {
var canvas = document.getElementById('c38');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#0f0';
ctx.fillRect(0, 0, 100, 50);
ctx.globalAlpha = 0.01; // avoid any potential alpha=0 optimisations
ctx.fillStyle = '#f00';
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 2,253,0,255, 2);
}
</script>
<!-- [[[ test_2d.composite.globalAlpha.image.html ]]] -->
<p>Canvas test: 2d.composite.globalAlpha.image</p>
<canvas id="c39" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_globalAlpha_image() {
var canvas = document.getElementById('c39');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#0f0';
ctx.fillRect(0, 0, 100, 50);
ctx.globalAlpha = 0.01; // avoid any potential alpha=0 optimisations
ctx.drawImage(document.getElementById('red_1.png'), 0, 0);
isPixel(ctx, 50,25, 2,253,0,255, 2);
}
</script>
<img src="image_red.png" id="red_1.png" class="resource">
<!-- [[[ test_2d.composite.globalAlpha.imagepattern.html ]]] -->
<p>Canvas test: 2d.composite.globalAlpha.imagepattern - bug 401790</p>
<canvas id="c40" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_globalAlpha_imagepattern() {
var canvas = document.getElementById('c40');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#0f0';
ctx.fillRect(0, 0, 100, 50);
ctx.fillStyle = ctx.createPattern(document.getElementById('red_2.png'), 'no-repeat');
ctx.globalAlpha = 0.01; // avoid any potential alpha=0 optimisations
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 2,253,0,255, 2);
}
</script>
<img src="image_red.png" id="red_2.png" class="resource">
<!-- [[[ test_2d.composite.globalAlpha.invalid.html ]]] -->
<p>Canvas test: 2d.composite.globalAlpha.invalid</p>
<canvas id="c41" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_globalAlpha_invalid() {
var canvas = document.getElementById('c41');
var ctx = canvas.getContext('2d');
ctx.globalAlpha = 0.5;
var a = ctx.globalAlpha; // might not be exactly 0.5, if it is rounded/quantised, so remember for future comparisons
ctx.globalAlpha = Infinity;
ok(ctx.globalAlpha === a, "ctx.globalAlpha === a");
ctx.globalAlpha = -Infinity;
ok(ctx.globalAlpha === a, "ctx.globalAlpha === a");
ctx.globalAlpha = NaN;
ok(ctx.globalAlpha === a, "ctx.globalAlpha === a");
}
</script>
<!-- [[[ test_2d.composite.globalAlpha.range.html ]]] -->
<p>Canvas test: 2d.composite.globalAlpha.range</p>
<canvas id="c42" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_globalAlpha_range() {
var canvas = document.getElementById('c42');
var ctx = canvas.getContext('2d');
ctx.globalAlpha = 0.5;
var a = ctx.globalAlpha; // might not be exactly 0.5, if it is rounded/quantised, so remember for future comparisons
ctx.globalAlpha = 1.1;
ok(ctx.globalAlpha == a, "ctx.globalAlpha == a");
ctx.globalAlpha = -0.1;
ok(ctx.globalAlpha == a, "ctx.globalAlpha == a");
ctx.globalAlpha = 0;
ok(ctx.globalAlpha == 0, "ctx.globalAlpha == 0");
ctx.globalAlpha = 1;
ok(ctx.globalAlpha == 1, "ctx.globalAlpha == 1");
}
</script>
<!-- [[[ test_2d.composite.image.copy.html ]]] -->
<p>Canvas test: 2d.composite.image.copy</p>
<canvas id="c43" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_image_copy() {
var canvas = document.getElementById('c43');
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'copy';
ctx.drawImage(document.getElementById('yellow75_12.png'), 0, 0);
isPixel(ctx, 50,25, 255,255,0,191, 5);
}
</script>
<img src="image_yellow75.png" id="yellow75_12.png" class="resource">
<!-- [[[ test_2d.composite.image.destination-atop.html ]]] -->
<p>Canvas test: 2d.composite.image.destination-atop</p>
<canvas id="c44" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_image_destination_atop() {
var canvas = document.getElementById('c44');
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'destination-atop';
ctx.drawImage(document.getElementById('yellow75_13.png'), 0, 0);
isPixel(ctx, 50,25, 127,255,127,191, 5);
}
</script>
<img src="image_yellow75.png" id="yellow75_13.png" class="resource">
<!-- [[[ test_2d.composite.image.destination-in.html ]]] -->
<p>Canvas test: 2d.composite.image.destination-in</p>
<canvas id="c45" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_image_destination_in() {
var canvas = document.getElementById('c45');
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'destination-in';
ctx.drawImage(document.getElementById('yellow75_14.png'), 0, 0);
isPixel(ctx, 50,25, 0,255,255,95, 5);
}
</script>
<img src="image_yellow75.png" id="yellow75_14.png" class="resource">
<!-- [[[ test_2d.composite.image.destination-out.html ]]] -->
<p>Canvas test: 2d.composite.image.destination-out</p>
<canvas id="c46" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_image_destination_out() {
var canvas = document.getElementById('c46');
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'destination-out';
ctx.drawImage(document.getElementById('yellow75_15.png'), 0, 0);
isPixel(ctx, 50,25, 0,255,255,31, 5);
}
</script>
<img src="image_yellow75.png" id="yellow75_15.png" class="resource">
<!-- [[[ test_2d.composite.image.destination-over.html ]]] -->
<p>Canvas test: 2d.composite.image.destination-over</p>
<canvas id="c47" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_image_destination_over() {
var canvas = document.getElementById('c47');
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'destination-over';
ctx.drawImage(document.getElementById('yellow75_16.png'), 0, 0);
isPixel(ctx, 50,25, 109,255,145,223, 5);
}
</script>
<img src="image_yellow75.png" id="yellow75_16.png" class="resource">
<!-- [[[ test_2d.composite.image.lighter.html ]]] -->
<p>Canvas test: 2d.composite.image.lighter</p>
<canvas id="c48" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_image_lighter() {
var canvas = document.getElementById('c48');
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'lighter';
ctx.drawImage(document.getElementById('yellow75_17.png'), 0, 0);
isPixel(ctx, 50,25, 191,255,127,255, 5);
}
</script>
<img src="image_yellow75.png" id="yellow75_17.png" class="resource">
<!-- [[[ test_2d.composite.image.source-atop.html ]]] -->
<p>Canvas test: 2d.composite.image.source-atop</p>
<canvas id="c49" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_image_source_atop() {
var canvas = document.getElementById('c49');
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'source-atop';
ctx.drawImage(document.getElementById('yellow75_18.png'), 0, 0);
isPixel(ctx, 50,25, 191,255,63,127, 5);
}
</script>
<img src="image_yellow75.png" id="yellow75_18.png" class="resource">
<!-- [[[ test_2d.composite.image.source-in.html ]]] -->
<p>Canvas test: 2d.composite.image.source-in</p>
<canvas id="c50" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_image_source_in() {
var canvas = document.getElementById('c50');
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'source-in';
ctx.drawImage(document.getElementById('yellow75_19.png'), 0, 0);
isPixel(ctx, 50,25, 255,255,0,95, 5);
}
</script>
<img src="image_yellow75.png" id="yellow75_19.png" class="resource">
<!-- [[[ test_2d.composite.image.source-out.html ]]] -->
<p>Canvas test: 2d.composite.image.source-out</p>
<canvas id="c51" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_image_source_out() {
var canvas = document.getElementById('c51');
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'source-out';
ctx.drawImage(document.getElementById('yellow75_20.png'), 0, 0);
isPixel(ctx, 50,25, 255,255,0,95, 5);
}
</script>
<img src="image_yellow75.png" id="yellow75_20.png" class="resource">
<!-- [[[ test_2d.composite.image.source-over.html ]]] -->
<p>Canvas test: 2d.composite.image.source-over</p>
<canvas id="c52" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_image_source_over() {
var canvas = document.getElementById('c52');
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'source-over';
ctx.drawImage(document.getElementById('yellow75_21.png'), 0, 0);
isPixel(ctx, 50,25, 218,255,36,223, 5);
}
</script>
<img src="image_yellow75.png" id="yellow75_21.png" class="resource">
<!-- [[[ test_2d.composite.image.xor.html ]]] -->
<p>Canvas test: 2d.composite.image.xor</p>
<canvas id="c53" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_image_xor() {
var canvas = document.getElementById('c53');
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'xor';
ctx.drawImage(document.getElementById('yellow75_22.png'), 0, 0);
isPixel(ctx, 50,25, 191,255,63,127, 5);
}
</script>
<img src="image_yellow75.png" id="yellow75_22.png" class="resource">
<!-- [[[ test_2d.composite.operation.casesensitive.html ]]] -->
<p>Canvas test: 2d.composite.operation.casesensitive - bug 401788</p>
<canvas id="c54" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_operation_casesensitive() {
var canvas = document.getElementById('c54');
var ctx = canvas.getContext('2d');
var _thrown_outer = false;
try {
ctx.globalCompositeOperation = 'xor';
ctx.globalCompositeOperation = 'Source-over';
ok(ctx.globalCompositeOperation == 'xor', "ctx.globalCompositeOperation == 'xor'");
} catch (e) {
_thrown_outer = true;
}
ok(!_thrown_outer, ctx.canvas.id + ' should not throw exception');
}
</script>
<!-- [[[ test_2d.composite.operation.darker.html ]]] -->
<p>Canvas test: 2d.composite.operation.darker</p>
<canvas id="c56" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_operation_darker() {
var canvas = document.getElementById('c56');
var ctx = canvas.getContext('2d');
ctx.globalCompositeOperation = 'xor';
ctx.globalCompositeOperation = 'darker';
ok(ctx.globalCompositeOperation == 'xor', "ctx.globalCompositeOperation == 'xor'");
}
</script>
<!-- [[[ test_2d.composite.operation.default.html ]]] -->
<p>Canvas test: 2d.composite.operation.default</p>
<canvas id="c57" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_operation_default() {
var canvas = document.getElementById('c57');
var ctx = canvas.getContext('2d');
ok(ctx.globalCompositeOperation == 'source-over', "ctx.globalCompositeOperation == 'source-over'");
}
</script>
<!-- [[[ test_2d.composite.operation.get.html ]]] -->
<p>Canvas test: 2d.composite.operation.get</p>
<canvas id="c58" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_operation_get() {
var canvas = document.getElementById('c58');
var ctx = canvas.getContext('2d');
var modes = ['source-atop', 'source-in', 'source-out', 'source-over',
'destination-atop', 'destination-in', 'destination-out', 'destination-over',
'lighter', 'copy', 'xor'];
for (var i = 0; i < modes.length; ++i)
{
ctx.globalCompositeOperation = modes[i];
ok(ctx.globalCompositeOperation == modes[i], "ctx.globalCompositeOperation == modes[\""+(i)+"\"]");
}
}
</script>
<!-- [[[ test_2d.composite.operation.highlight.html ]]] -->
<p>Canvas test: 2d.composite.operation.highlight - bug 401788</p>
<canvas id="c59" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_operation_highlight() {
var canvas = document.getElementById('c59');
var ctx = canvas.getContext('2d');
var _thrown_outer = false;
try {
ctx.globalCompositeOperation = 'xor';
ctx.globalCompositeOperation = 'highlight';
ok(ctx.globalCompositeOperation == 'xor', "ctx.globalCompositeOperation == 'xor'");
} catch (e) {
_thrown_outer = true;
}
ok(!_thrown_outer, ctx.canvas.id + ' should not throw exception');
}
</script>
<!-- [[[ test_2d.composite.operation.nullsuffix.html ]]] -->
<p>Canvas test: 2d.composite.operation.nullsuffix - bug 401788</p>
<canvas id="c60" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_operation_nullsuffix() {
var canvas = document.getElementById('c60');
var ctx = canvas.getContext('2d');
var _thrown_outer = false;
try {
ctx.globalCompositeOperation = 'xor';
ctx.globalCompositeOperation = 'source-over\0';
ok(ctx.globalCompositeOperation == 'xor', "ctx.globalCompositeOperation == 'xor'");
} catch (e) {
_thrown_outer = true;
}
ok(!_thrown_outer, ctx.canvas.id + ' should not throw exception');
}
</script>
<!-- [[[ test_2d.composite.operation.over.html ]]] -->
<p>Canvas test: 2d.composite.operation.over</p>
<canvas id="c61" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_operation_over() {
var canvas = document.getElementById('c61');
var ctx = canvas.getContext('2d');
ctx.globalCompositeOperation = 'xor';
ctx.globalCompositeOperation = 'over';
ok(ctx.globalCompositeOperation == 'xor', "ctx.globalCompositeOperation == 'xor'");
}
</script>
<!-- [[[ test_2d.composite.operation.unrecognised.html ]]] -->
<p>Canvas test: 2d.composite.operation.unrecognised - bug 401788</p>
<canvas id="c62" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_operation_unrecognised() {
var canvas = document.getElementById('c62');
var ctx = canvas.getContext('2d');
var _thrown_outer = false;
try {
ctx.globalCompositeOperation = 'xor';
ctx.globalCompositeOperation = 'nonexistent';
ok(ctx.globalCompositeOperation == 'xor', "ctx.globalCompositeOperation == 'xor'");
} catch (e) {
_thrown_outer = true;
}
ok(!_thrown_outer, ctx.canvas.id + ' should not throw exception');
}
</script>
<!-- [[[ test_2d.composite.solid.copy.html ]]] -->
<p>Canvas test: 2d.composite.solid.copy</p>
<canvas id="c63" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_solid_copy() {
var canvas = document.getElementById('c63');
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'rgba(0, 255, 255, 1.0)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'copy';
ctx.fillStyle = 'rgba(255, 255, 0, 1.0)';
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 255,255,0,255, 5);
}
</script>
<!-- [[[ test_2d.composite.solid.destination-atop.html ]]] -->
<p>Canvas test: 2d.composite.solid.destination-atop</p>
<canvas id="c64" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_solid_destination_atop() {
var canvas = document.getElementById('c64');
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'rgba(0, 255, 255, 1.0)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'destination-atop';
ctx.fillStyle = 'rgba(255, 255, 0, 1.0)';
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,255,255,255, 5);
}
</script>
<!-- [[[ test_2d.composite.solid.destination-in.html ]]] -->
<p>Canvas test: 2d.composite.solid.destination-in</p>
<canvas id="c65" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_solid_destination_in() {
var canvas = document.getElementById('c65');
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'rgba(0, 255, 255, 1.0)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'destination-in';
ctx.fillStyle = 'rgba(255, 255, 0, 1.0)';
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,255,255,255, 5);
}
</script>
<!-- [[[ test_2d.composite.solid.destination-out.html ]]] -->
<p>Canvas test: 2d.composite.solid.destination-out</p>
<canvas id="c66" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_solid_destination_out() {
var canvas = document.getElementById('c66');
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'rgba(0, 255, 255, 1.0)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'destination-out';
ctx.fillStyle = 'rgba(255, 255, 0, 1.0)';
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,0,0,0, 5);
}
</script>
<!-- [[[ test_2d.composite.solid.destination-over.html ]]] -->
<p>Canvas test: 2d.composite.solid.destination-over</p>
<canvas id="c67" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_solid_destination_over() {
var canvas = document.getElementById('c67');
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'rgba(0, 255, 255, 1.0)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'destination-over';
ctx.fillStyle = 'rgba(255, 255, 0, 1.0)';
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,255,255,255, 5);
}
</script>
<!-- [[[ test_2d.composite.solid.lighter.html ]]] -->
<p>Canvas test: 2d.composite.solid.lighter</p>
<canvas id="c68" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_solid_lighter() {
var canvas = document.getElementById('c68');
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'rgba(0, 255, 255, 1.0)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'lighter';
ctx.fillStyle = 'rgba(255, 255, 0, 1.0)';
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 255,255,255,255, 5);
}
</script>
<!-- [[[ test_2d.composite.solid.source-atop.html ]]] -->
<p>Canvas test: 2d.composite.solid.source-atop</p>
<canvas id="c69" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_solid_source_atop() {
var canvas = document.getElementById('c69');
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'rgba(0, 255, 255, 1.0)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'source-atop';
ctx.fillStyle = 'rgba(255, 255, 0, 1.0)';
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 255,255,0,255, 5);
}
</script>
<!-- [[[ test_2d.composite.solid.source-in.html ]]] -->
<p>Canvas test: 2d.composite.solid.source-in</p>
<canvas id="c70" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_solid_source_in() {
var canvas = document.getElementById('c70');
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'rgba(0, 255, 255, 1.0)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'source-in';
ctx.fillStyle = 'rgba(255, 255, 0, 1.0)';
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 255,255,0,255, 5);
}
</script>
<!-- [[[ test_2d.composite.solid.source-out.html ]]] -->
<p>Canvas test: 2d.composite.solid.source-out</p>
<canvas id="c71" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_solid_source_out() {
var canvas = document.getElementById('c71');
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'rgba(0, 255, 255, 1.0)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'source-out';
ctx.fillStyle = 'rgba(255, 255, 0, 1.0)';
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,0,0,0, 5);
}
</script>
<!-- [[[ test_2d.composite.solid.source-over.html ]]] -->
<p>Canvas test: 2d.composite.solid.source-over</p>
<canvas id="c72" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_solid_source_over() {
var canvas = document.getElementById('c72');
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'rgba(0, 255, 255, 1.0)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'source-over';
ctx.fillStyle = 'rgba(255, 255, 0, 1.0)';
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 255,255,0,255, 5);
}
</script>
<!-- [[[ test_2d.composite.solid.xor.html ]]] -->
<p>Canvas test: 2d.composite.solid.xor</p>
<canvas id="c73" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_solid_xor() {
var canvas = document.getElementById('c73');
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'rgba(0, 255, 255, 1.0)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'xor';
ctx.fillStyle = 'rgba(255, 255, 0, 1.0)';
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,0,0,0, 5);
}
</script>
<!-- [[[ test_2d.composite.transparent.copy.html ]]] -->
<p>Canvas test: 2d.composite.transparent.copy</p>
<canvas id="c74" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_transparent_copy() {
var canvas = document.getElementById('c74');
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'rgba(0, 255, 0, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'copy';
ctx.fillStyle = 'rgba(0, 0, 255, 0.75)';
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,0,255,191, 5);
}
</script>
<!-- [[[ test_2d.composite.transparent.destination-atop.html ]]] -->
<p>Canvas test: 2d.composite.transparent.destination-atop</p>
<canvas id="c75" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_transparent_destination_atop() {
var canvas = document.getElementById('c75');
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'rgba(0, 255, 0, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'destination-atop';
ctx.fillStyle = 'rgba(0, 0, 255, 0.75)';
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,127,127,191, 5);
}
</script>
<!-- [[[ test_2d.composite.transparent.destination-in.html ]]] -->
<p>Canvas test: 2d.composite.transparent.destination-in</p>
<canvas id="c76" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_transparent_destination_in() {
var canvas = document.getElementById('c76');
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'rgba(0, 255, 0, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'destination-in';
ctx.fillStyle = 'rgba(0, 0, 255, 0.75)';
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,255,0,95, 5);
}
</script>
<!-- [[[ test_2d.composite.transparent.destination-out.html ]]] -->
<p>Canvas test: 2d.composite.transparent.destination-out</p>
<canvas id="c77" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_transparent_destination_out() {
var canvas = document.getElementById('c77');
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'rgba(0, 255, 0, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'destination-out';
ctx.fillStyle = 'rgba(0, 0, 255, 0.75)';
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,255,0,31, 5);
}
</script>
<!-- [[[ test_2d.composite.transparent.destination-over.html ]]] -->
<p>Canvas test: 2d.composite.transparent.destination-over</p>
<canvas id="c78" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_transparent_destination_over() {
var canvas = document.getElementById('c78');
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'rgba(0, 255, 0, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'destination-over';
ctx.fillStyle = 'rgba(0, 0, 255, 0.75)';
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,145,109,223, 5);
}
</script>
<!-- [[[ test_2d.composite.transparent.lighter.html ]]] -->
<p>Canvas test: 2d.composite.transparent.lighter</p>
<canvas id="c79" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_transparent_lighter() {
var canvas = document.getElementById('c79');
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'rgba(0, 255, 0, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'lighter';
ctx.fillStyle = 'rgba(0, 0, 255, 0.75)';
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,127,191,255, 5);
}
</script>
<!-- [[[ test_2d.composite.transparent.source-atop.html ]]] -->
<p>Canvas test: 2d.composite.transparent.source-atop</p>
<canvas id="c80" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_transparent_source_atop() {
var canvas = document.getElementById('c80');
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'rgba(0, 255, 0, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'source-atop';
ctx.fillStyle = 'rgba(0, 0, 255, 0.75)';
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,63,191,127, 5);
}
</script>
<!-- [[[ test_2d.composite.transparent.source-in.html ]]] -->
<p>Canvas test: 2d.composite.transparent.source-in</p>
<canvas id="c81" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_transparent_source_in() {
var canvas = document.getElementById('c81');
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'rgba(0, 255, 0, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'source-in';
ctx.fillStyle = 'rgba(0, 0, 255, 0.75)';
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,0,255,95, 5);
}
</script>
<!-- [[[ test_2d.composite.transparent.source-out.html ]]] -->
<p>Canvas test: 2d.composite.transparent.source-out</p>
<canvas id="c82" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_transparent_source_out() {
var canvas = document.getElementById('c82');
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'rgba(0, 255, 0, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'source-out';
ctx.fillStyle = 'rgba(0, 0, 255, 0.75)';
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,0,255,95, 5);
}
</script>
<!-- [[[ test_2d.composite.transparent.source-over.html ]]] -->
<p>Canvas test: 2d.composite.transparent.source-over</p>
<canvas id="c83" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_transparent_source_over() {
var canvas = document.getElementById('c83');
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'rgba(0, 255, 0, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'source-over';
ctx.fillStyle = 'rgba(0, 0, 255, 0.75)';
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,36,218,223, 5);
}
</script>
<!-- [[[ test_2d.composite.transparent.xor.html ]]] -->
<p>Canvas test: 2d.composite.transparent.xor</p>
<canvas id="c84" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_transparent_xor() {
var canvas = document.getElementById('c84');
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'rgba(0, 255, 0, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'xor';
ctx.fillStyle = 'rgba(0, 0, 255, 0.75)';
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,63,191,127, 5);
}
</script>
<!-- [[[ test_2d.composite.uncovered.fill.copy.html ]]] -->
<p>Canvas test: 2d.composite.uncovered.fill.copy</p>
<!-- Testing: fill() draws pixels not covered by the source object as (0,0,0,0), and does not leave the pixels unchanged. -->
<canvas id="c85" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_uncovered_fill_copy() {
var canvas = document.getElementById('c85');
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'rgba(0, 255, 0, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'copy';
ctx.fillStyle = 'rgba(0, 0, 255, 0.75)';
ctx.translate(0, 25);
ctx.fillRect(0, 50, 100, 50);
isPixel(ctx, 50,25, 0,0,0,0, 5);
}
</script>
<!-- [[[ test_2d.composite.uncovered.fill.destination-atop.html ]]] -->
<p>Canvas test: 2d.composite.uncovered.fill.destination-atop</p>
<!-- Testing: fill() draws pixels not covered by the source object as (0,0,0,0), and does not leave the pixels unchanged. -->
<canvas id="c86" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_uncovered_fill_destination_atop() {
var canvas = document.getElementById('c86');
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'rgba(0, 255, 0, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'destination-atop';
ctx.fillStyle = 'rgba(0, 0, 255, 0.75)';
ctx.translate(0, 25);
ctx.fillRect(0, 50, 100, 50);
isPixel(ctx, 50,25, 0,0,0,0, 5);
}
</script>
<!-- [[[ test_2d.composite.uncovered.fill.destination-in.html ]]] -->
<p>Canvas test: 2d.composite.uncovered.fill.destination-in</p>
<!-- Testing: fill() draws pixels not covered by the source object as (0,0,0,0), and does not leave the pixels unchanged. -->
<canvas id="c87" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_uncovered_fill_destination_in() {
var canvas = document.getElementById('c87');
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'rgba(0, 255, 0, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'destination-in';
ctx.fillStyle = 'rgba(0, 0, 255, 0.75)';
ctx.translate(0, 25);
ctx.fillRect(0, 50, 100, 50);
isPixel(ctx, 50,25, 0,0,0,0, 5);
}
</script>
<!-- [[[ test_2d.composite.uncovered.fill.source-in.html ]]] -->
<p>Canvas test: 2d.composite.uncovered.fill.source-in</p>
<!-- Testing: fill() draws pixels not covered by the source object as (0,0,0,0), and does not leave the pixels unchanged. -->
<canvas id="c88" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_uncovered_fill_source_in() {
var canvas = document.getElementById('c88');
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'rgba(0, 255, 0, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'source-in';
ctx.fillStyle = 'rgba(0, 0, 255, 0.75)';
ctx.translate(0, 25);
ctx.fillRect(0, 50, 100, 50);
isPixel(ctx, 50,25, 0,0,0,0, 5);
}
</script>
<!-- [[[ test_2d.composite.uncovered.fill.source-out.html ]]] -->
<p>Canvas test: 2d.composite.uncovered.fill.source-out</p>
<!-- Testing: fill() draws pixels not covered by the source object as (0,0,0,0), and does not leave the pixels unchanged. -->
<canvas id="c89" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_uncovered_fill_source_out() {
var canvas = document.getElementById('c89');
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'rgba(0, 255, 0, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'source-out';
ctx.fillStyle = 'rgba(0, 0, 255, 0.75)';
ctx.translate(0, 25);
ctx.fillRect(0, 50, 100, 50);
isPixel(ctx, 50,25, 0,0,0,0, 5);
}
</script>
<!-- [[[ test_2d.composite.uncovered.image.copy.html ]]] -->
<p>Canvas test: 2d.composite.uncovered.image.copy</p>
<!-- Testing: drawImage() draws pixels not covered by the source object as (0,0,0,0), and does not leave the pixels unchanged. -->
<canvas id="c90" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_uncovered_image_copy() {
var canvas = document.getElementById('c90');
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'copy';
ctx.drawImage(document.getElementById('yellow_1.png'), 40, 40, 10, 10, 40, 50, 10, 10);
isPixel(ctx, 15,15, 0,0,0,0, 5);
isPixel(ctx, 50,25, 0,0,0,0, 5);
}
</script>
<img src="image_yellow.png" id="yellow_1.png" class="resource">
<!-- [[[ test_2d.composite.uncovered.image.destination-atop.html ]]] -->
<p>Canvas test: 2d.composite.uncovered.image.destination-atop</p>
<!-- Testing: drawImage() draws pixels not covered by the source object as (0,0,0,0), and does not leave the pixels unchanged. -->
<canvas id="c91" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_uncovered_image_destination_atop() {
var canvas = document.getElementById('c91');
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'destination-atop';
ctx.drawImage(document.getElementById('yellow_2.png'), 40, 40, 10, 10, 40, 50, 10, 10);
isPixel(ctx, 15,15, 0,0,0,0, 5);
isPixel(ctx, 50,25, 0,0,0,0, 5);
}
</script>
<img src="image_yellow.png" id="yellow_2.png" class="resource">
<!-- [[[ test_2d.composite.uncovered.image.destination-in.html ]]] -->
<p>Canvas test: 2d.composite.uncovered.image.destination-in</p>
<!-- Testing: drawImage() draws pixels not covered by the source object as (0,0,0,0), and does not leave the pixels unchanged. -->
<canvas id="c92" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_uncovered_image_destination_in() {
var canvas = document.getElementById('c92');
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'destination-in';
ctx.drawImage(document.getElementById('yellow_3.png'), 40, 40, 10, 10, 40, 50, 10, 10);
isPixel(ctx, 15,15, 0,0,0,0, 5);
isPixel(ctx, 50,25, 0,0,0,0, 5);
}
</script>
<img src="image_yellow.png" id="yellow_3.png" class="resource">
<!-- [[[ test_2d.composite.uncovered.image.source-in.html ]]] -->
<p>Canvas test: 2d.composite.uncovered.image.source-in</p>
<!-- Testing: drawImage() draws pixels not covered by the source object as (0,0,0,0), and does not leave the pixels unchanged. -->
<canvas id="c93" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_uncovered_image_source_in() {
var canvas = document.getElementById('c93');
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'source-in';
ctx.drawImage(document.getElementById('yellow_4.png'), 40, 40, 10, 10, 40, 50, 10, 10);
isPixel(ctx, 15,15, 0,0,0,0, 5);
isPixel(ctx, 50,25, 0,0,0,0, 5);
}
</script>
<img src="image_yellow.png" id="yellow_4.png" class="resource">
<!-- [[[ test_2d.composite.uncovered.image.source-out.html ]]] -->
<p>Canvas test: 2d.composite.uncovered.image.source-out</p>
<!-- Testing: drawImage() draws pixels not covered by the source object as (0,0,0,0), and does not leave the pixels unchanged. -->
<canvas id="c94" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_uncovered_image_source_out() {
var canvas = document.getElementById('c94');
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'source-out';
ctx.drawImage(document.getElementById('yellow_5.png'), 40, 40, 10, 10, 40, 50, 10, 10);
isPixel(ctx, 15,15, 0,0,0,0, 5);
isPixel(ctx, 50,25, 0,0,0,0, 5);
}
</script>
<img src="image_yellow.png" id="yellow_5.png" class="resource">
<!-- [[[ test_2d.composite.uncovered.pattern.copy.html ]]] -->
<p>Canvas test: 2d.composite.uncovered.pattern.copy</p>
<!-- Testing: Pattern fill() draws pixels not covered by the source object as (0,0,0,0), and does not leave the pixels unchanged. -->
<canvas id="c95" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_uncovered_pattern_copy() {
var canvas = document.getElementById('c95');
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'copy';
ctx.fillStyle = ctx.createPattern(document.getElementById('yellow_6.png'), 'no-repeat');
ctx.fillRect(0, 50, 100, 50);
isPixel(ctx, 50,25, 0,0,0,0, 5);
}
</script>
<img src="image_yellow.png" id="yellow_6.png" class="resource">
<!-- [[[ test_2d.composite.uncovered.pattern.destination-atop.html ]]] -->
<p>Canvas test: 2d.composite.uncovered.pattern.destination-atop</p>
<!-- Testing: Pattern fill() draws pixels not covered by the source object as (0,0,0,0), and does not leave the pixels unchanged. -->
<canvas id="c96" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_uncovered_pattern_destination_atop() {
var canvas = document.getElementById('c96');
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'destination-atop';
ctx.fillStyle = ctx.createPattern(document.getElementById('yellow_7.png'), 'no-repeat');
ctx.fillRect(0, 50, 100, 50);
isPixel(ctx, 50,25, 0,0,0,0, 5);
}
</script>
<img src="image_yellow.png" id="yellow_7.png" class="resource">
<!-- [[[ test_2d.composite.uncovered.pattern.destination-in.html ]]] -->
<p>Canvas test: 2d.composite.uncovered.pattern.destination-in</p>
<!-- Testing: Pattern fill() draws pixels not covered by the source object as (0,0,0,0), and does not leave the pixels unchanged. -->
<canvas id="c97" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_uncovered_pattern_destination_in() {
var canvas = document.getElementById('c97');
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'destination-in';
ctx.fillStyle = ctx.createPattern(document.getElementById('yellow_8.png'), 'no-repeat');
ctx.fillRect(0, 50, 100, 50);
isPixel(ctx, 50,25, 0,0,0,0, 5);
}
</script>
<img src="image_yellow.png" id="yellow_8.png" class="resource">
<!-- [[[ test_2d.composite.uncovered.pattern.source-in.html ]]] -->
<p>Canvas test: 2d.composite.uncovered.pattern.source-in</p>
<!-- Testing: Pattern fill() draws pixels not covered by the source object as (0,0,0,0), and does not leave the pixels unchanged. -->
<canvas id="c98" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_uncovered_pattern_source_in() {
var canvas = document.getElementById('c98');
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'source-in';
ctx.fillStyle = ctx.createPattern(document.getElementById('yellow_9.png'), 'no-repeat');
ctx.fillRect(0, 50, 100, 50);
isPixel(ctx, 50,25, 0,0,0,0, 5);
}
</script>
<img src="image_yellow.png" id="yellow_9.png" class="resource">
<!-- [[[ test_2d.composite.uncovered.pattern.source-out.html ]]] -->
<p>Canvas test: 2d.composite.uncovered.pattern.source-out</p>
<!-- Testing: Pattern fill() draws pixels not covered by the source object as (0,0,0,0), and does not leave the pixels unchanged. -->
<canvas id="c99" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_composite_uncovered_pattern_source_out() {
var canvas = document.getElementById('c99');
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'source-out';
ctx.fillStyle = ctx.createPattern(document.getElementById('yellow_10.png'), 'no-repeat');
ctx.fillRect(0, 50, 100, 50);
isPixel(ctx, 50,25, 0,0,0,0, 5);
}
</script>
<img src="image_yellow.png" id="yellow_10.png" class="resource">
<!-- [[[ test_2d.drawImage.3arg.html ]]] -->
<p>Canvas test: 2d.drawImage.3arg</p>
<canvas id="c100" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_drawImage_3arg() {
var canvas = document.getElementById('c100');
var ctx = canvas.getContext('2d');
ctx.drawImage(document.getElementById('green_1.png'), 0, 0);
ctx.drawImage(document.getElementById('red_3.png'), -100, 0);
ctx.drawImage(document.getElementById('red_3.png'), 100, 0);
ctx.drawImage(document.getElementById('red_3.png'), 0, -50);
ctx.drawImage(document.getElementById('red_3.png'), 0, 50);
isPixel(ctx, 0,0, 0,255,0,255, 2);
isPixel(ctx, 99,0, 0,255,0,255, 2);
isPixel(ctx, 0,49, 0,255,0,255, 2);
isPixel(ctx, 99,49, 0,255,0,255, 2);
}
</script>
<img src="image_red.png" id="red_3.png" class="resource">
<img src="image_green.png" id="green_1.png" class="resource">
<!-- [[[ test_2d.drawImage.5arg.html ]]] -->
<p>Canvas test: 2d.drawImage.5arg</p>
<canvas id="c101" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_drawImage_5arg() {
var canvas = document.getElementById('c101');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#f00';
ctx.fillRect(0, 0, 100, 50);
ctx.drawImage(document.getElementById('green_2.png'), 50, 0, 50, 50);
ctx.drawImage(document.getElementById('red_4.png'), 0, 0, 50, 50);
ctx.fillStyle = '#0f0';
ctx.fillRect(0, 0, 50, 50);
isPixel(ctx, 0,0, 0,255,0,255, 2);
isPixel(ctx, 99,0, 0,255,0,255, 2);
isPixel(ctx, 0,49, 0,255,0,255, 2);
isPixel(ctx, 99,49, 0,255,0,255, 2);
}
</script>
<img src="image_red.png" id="red_4.png" class="resource">
<img src="image_green.png" id="green_2.png" class="resource">
<!-- [[[ test_2d.drawImage.9arg.basic.html ]]] -->
<p>Canvas test: 2d.drawImage.9arg.basic</p>
<canvas id="c102" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_drawImage_9arg_basic() {
var canvas = document.getElementById('c102');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#f00';
ctx.fillRect(0, 0, 100, 50);
ctx.drawImage(document.getElementById('green_3.png'), 0, 0, 100, 50, 0, 0, 100, 50);
isPixel(ctx, 0,0, 0,255,0,255, 2);
isPixel(ctx, 99,0, 0,255,0,255, 2);
isPixel(ctx, 0,49, 0,255,0,255, 2);
isPixel(ctx, 99,49, 0,255,0,255, 2);
}
</script>
<img src="image_green.png" id="green_3.png" class="resource">
<!-- [[[ test_2d.drawImage.9arg.destpos.html ]]] -->
<p>Canvas test: 2d.drawImage.9arg.destpos</p>
<canvas id="c103" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_drawImage_9arg_destpos() {
var canvas = document.getElementById('c103');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#f00';
ctx.fillRect(0, 0, 100, 50);
ctx.drawImage(document.getElementById('green_4.png'), 0, 0, 100, 50, 0, 0, 100, 50);
ctx.drawImage(document.getElementById('red_5.png'), 0, 0, 100, 50, -100, 0, 100, 50);
ctx.drawImage(document.getElementById('red_5.png'), 0, 0, 100, 50, 100, 0, 100, 50);
ctx.drawImage(document.getElementById('red_5.png'), 0, 0, 100, 50, 0, -50, 100, 50);
ctx.drawImage(document.getElementById('red_5.png'), 0, 0, 100, 50, 0, 50, 100, 50);
isPixel(ctx, 0,0, 0,255,0,255, 2);
isPixel(ctx, 99,0, 0,255,0,255, 2);
isPixel(ctx, 0,49, 0,255,0,255, 2);
isPixel(ctx, 99,49, 0,255,0,255, 2);
}
</script>
<img src="image_red.png" id="red_5.png" class="resource">
<img src="image_green.png" id="green_4.png" class="resource">
<!-- [[[ test_2d.drawImage.9arg.destsize.html ]]] -->
<p>Canvas test: 2d.drawImage.9arg.destsize</p>
<canvas id="c104" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_drawImage_9arg_destsize() {
var canvas = document.getElementById('c104');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#f00';
ctx.fillRect(0, 0, 100, 50);
ctx.drawImage(document.getElementById('green_5.png'), 1, 1, 1, 1, 0, 0, 100, 50);
ctx.drawImage(document.getElementById('red_6.png'), 0, 0, 100, 50, -50, 0, 50, 50);
ctx.drawImage(document.getElementById('red_6.png'), 0, 0, 100, 50, 100, 0, 50, 50);
ctx.drawImage(document.getElementById('red_6.png'), 0, 0, 100, 50, 0, -25, 100, 25);
ctx.drawImage(document.getElementById('red_6.png'), 0, 0, 100, 50, 0, 50, 100, 25);
isPixel(ctx, 0,0, 0,255,0,255, 2);
isPixel(ctx, 99,0, 0,255,0,255, 2);
isPixel(ctx, 0,49, 0,255,0,255, 2);
isPixel(ctx, 99,49, 0,255,0,255, 2);
}
</script>
<img src="image_red.png" id="red_6.png" class="resource">
<img src="image_green.png" id="green_5.png" class="resource">
<!-- [[[ test_2d.drawImage.9arg.sourcepos.html ]]] -->
<p>Canvas test: 2d.drawImage.9arg.sourcepos</p>
<canvas id="c105" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_drawImage_9arg_sourcepos() {
var canvas = document.getElementById('c105');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#f00';
ctx.fillRect(0, 0, 100, 50);
ctx.drawImage(document.getElementById('rgrg-256x256_1.png'), 140, 20, 100, 50, 0, 0, 100, 50);
isPixel(ctx, 0,0, 0,255,0,255, 2);
isPixel(ctx, 99,0, 0,255,0,255, 2);
isPixel(ctx, 0,49, 0,255,0,255, 2);
isPixel(ctx, 99,49, 0,255,0,255, 2);
}
</script>
<img src="image_rgrg-256x256.png" id="rgrg-256x256_1.png" class="resource">
<!-- [[[ test_2d.drawImage.9arg.sourcesize.html ]]] -->
<p>Canvas test: 2d.drawImage.9arg.sourcesize</p>
<canvas id="c106" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_drawImage_9arg_sourcesize() {
var canvas = document.getElementById('c106');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#f00';
ctx.fillRect(0, 0, 100, 50);
ctx.drawImage(document.getElementById('rgrg-256x256_2.png'), 0, 0, 256, 256, 0, 0, 100, 50);
ctx.fillStyle = '#0f0';
ctx.fillRect(0, 0, 51, 26);
ctx.fillRect(49, 24, 51, 26);
isPixel(ctx, 0,0, 0,255,0,255, 3);
isPixel(ctx, 99,0, 0,255,0,255, 3);
isPixel(ctx, 0,49, 0,255,0,255, 3);
isPixel(ctx, 99,49, 0,255,0,255, 3);
isPixel(ctx, 20,20, 0,255,0,255, 3);
isPixel(ctx, 80,20, 0,255,0,255, 3);
isPixel(ctx, 20,30, 0,255,0,255, 3);
isPixel(ctx, 80,30, 0,255,0,255, 3);
}
</script>
<img src="image_rgrg-256x256.png" id="rgrg-256x256_2.png" class="resource">
<!-- [[[ test_2d.drawImage.alpha.html ]]] -->
<p>Canvas test: 2d.drawImage.alpha</p>
<canvas id="c107" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_drawImage_alpha() {
var canvas = document.getElementById('c107');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#0f0';
ctx.fillRect(0, 0, 100, 50);
ctx.globalAlpha = 0;
ctx.drawImage(document.getElementById('red_7.png'), 0, 0);
isPixel(ctx, 50,25, 0,255,0,255, 2);
}
</script>
<img src="image_red.png" id="red_7.png" class="resource">
<!-- [[[ test_2d.drawImage.animated.apng.html ]]] -->
<p>Canvas test: 2d.drawImage.animated.apng</p>
<!-- Testing: drawImage() of an APNG with no poster frame draws the first frame -->
<canvas id="c108" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function deferTest() {
_deferred = true;
}
function wrapFunction(f) {
return function () {
f.apply(null, arguments);
};
}
var canvas108 = document.getElementById('c108');
var ctx108 = canvas108.getContext('2d');
var isDone_test_2d_drawImage_animated_apng = false;
function test_2d_drawImage_animated_apng() {
deferTest();
setTimeout(wrapFunction(function () {
ctx108.drawImage(document.getElementById('anim-gr_1.png'), 0, 0);
isPixel(ctx108, 50,25, 0,255,0,255, 2);
isDone_test_2d_drawImage_animated_apng = true;
}), 5000);
}
</script>
<img src="image_anim-gr.png" id="anim-gr_1.png" class="resource">
<!-- [[[ test_2d.drawImage.animated.gif.html ]]] -->
<p>Canvas test: 2d.drawImage.animated.gif</p>
<!-- Testing: drawImage() of an animated GIF draws the first frame -->
<canvas id="c109" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
var canvas109 = document.getElementById('c109');
var ctx109 = canvas109.getContext('2d');
var isDone_test_2d_drawImage_animated_gif = false;
function test_2d_drawImage_animated_gif() {
deferTest();
setTimeout(wrapFunction(function () {
ctx109.drawImage(document.getElementById('anim-gr_1.gif'), 0, 0);
isPixel(ctx109, 50,25, 0,255,0,255, 2);
isDone_test_2d_drawImage_animated_gif = true;
}), 5000);
}
</script>
<img src="image_anim-gr.gif" id="anim-gr_1.gif" class="resource">
<!-- [[[ test_2d.drawImage.animated.poster.html ]]] -->
<p>Canvas test: 2d.drawImage.animated.poster</p>
<!-- Testing: drawImage() of an APNG draws the poster frame -->
<canvas id="c110" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
var canvas110 = document.getElementById('c110');
var ctx110 = canvas110.getContext('2d');
function test_2d_drawImage_animated_poster() {
ctx110.drawImage(document.getElementById('anim-poster-gr_1.png'), 0, 0);
todo_isPixel(ctx110, 50,25, 0,255,0,255, 2);
}
</script>
<img src="image_anim-poster-gr.png" id="anim-poster-gr_1.png" class="resource">
<!-- [[[ test_2d.drawImage.broken.html ]]] -->
<p>Canvas test: 2d.drawImage.broken</p>
<canvas id="c111" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_drawImage_broken() {
var canvas = document.getElementById('c111');
var ctx = canvas.getContext('2d');
var img = document.getElementById('broken_1.png');
todo(img.complete === false, "img.complete === false");
var _thrown = undefined; try {
ctx.drawImage(img, 0, 0);
} catch (e) { _thrown = e }; todo(_thrown && _thrown.name == "InvalidStateError" && _thrown.code == DOMException.INVALID_STATE_ERR, "should throw InvalidStateError");
}
</script>
<img src="image_broken.png" id="broken_1.png" class="resource">
<!-- [[[ test_2d.drawImage.canvas.html ]]] -->
<p>Canvas test: 2d.drawImage.canvas</p>
<canvas id="c112" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_drawImage_canvas() {
var canvas = document.getElementById('c112');
var ctx = canvas.getContext('2d');
var canvas2 = document.createElement('canvas');
canvas2.width = 100;
canvas2.height = 50;
var ctx2 = canvas2.getContext('2d');
ctx2.fillStyle = '#0f0';
ctx2.fillRect(0, 0, 100, 50);
ctx.fillStyle = '#f00';
ctx.drawImage(canvas2, 0, 0);
isPixel(ctx, 0,0, 0,255,0,255, 2);
isPixel(ctx, 99,0, 0,255,0,255, 2);
isPixel(ctx, 0,49, 0,255,0,255, 2);
isPixel(ctx, 99,49, 0,255,0,255, 2);
}
</script>
<!-- [[[ test_2d.drawImage.clip.html ]]] -->
<p>Canvas test: 2d.drawImage.clip</p>
<canvas id="c113" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_drawImage_clip() {
var canvas = document.getElementById('c113');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#0f0';
ctx.fillRect(0, 0, 100, 50);
ctx.rect(-10, -10, 1, 1);
ctx.clip();
ctx.drawImage(document.getElementById('red_8.png'), 0, 0);
isPixel(ctx, 50,25, 0,255,0,255, 2);
}
</script>
<img src="image_red.png" id="red_8.png" class="resource">
<!-- [[[ test_2d.drawImage.composite.html ]]] -->
<p>Canvas test: 2d.drawImage.composite</p>
<canvas id="c114" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_drawImage_composite() {
var canvas = document.getElementById('c114');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#0f0';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'destination-over';
ctx.drawImage(document.getElementById('red_9.png'), 0, 0);
isPixel(ctx, 50,25, 0,255,0,255, 2);
}
</script>
<img src="image_red.png" id="red_9.png" class="resource">
<!-- [[[ test_2d.drawImage.floatsource.html ]]] -->
<p>Canvas test: 2d.drawImage.floatsource</p>
<canvas id="c115" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_drawImage_floatsource() {
var canvas = document.getElementById('c115');
var ctx = canvas.getContext('2d');
ctx.drawImage(document.getElementById('green_6.png'), 10.1, 10.1, 0.1, 0.1, 0, 0, 100, 50);
isPixel(ctx, 50,25, 0,255,0,255, 2);
}
</script>
<img src="image_green.png" id="green_6.png" class="resource">
<!-- [[[ test_2d.drawImage.incomplete.html ]]] -->
<p>Canvas test: 2d.drawImage.incomplete</p>
<canvas id="c116" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_drawImage_incomplete() {
var canvas = document.getElementById('c116');
var ctx = canvas.getContext('2d');
var img = new Image();
todo(img.complete === false, "img.complete === false");
var _thrown = undefined; try {
ctx.drawImage(img, 0, 0);
} catch (e) { _thrown = e }; todo(_thrown && _thrown.name == "InvalidStateError" && _thrown.code == DOMException.INVALID_STATE_ERR, "should throw InvalidStateError");
}
</script>
<!-- [[[ test_2d.drawImage.negativedest.html ]]] -->
<p>Canvas test: 2d.drawImage.negativedest</p>
<canvas id="c117" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_drawImage_negativedest() {
var canvas = document.getElementById('c117');
var ctx = canvas.getContext('2d');
var _thrown_outer = false;
try {
ctx.fillStyle = '#f00';
ctx.fillRect(0, 0, 100, 50);
ctx.drawImage(document.getElementById('ggrr-256x256_1.png'), 100, 78, 50, 50, 0, 50, 50, -50);
ctx.drawImage(document.getElementById('ggrr-256x256_1.png'), 100, 128, 50, -50, 100, 50, -50, -50);
isPixel(ctx, 1,1, 0,255,0,255, 2);
isPixel(ctx, 1,48, 0,255,0,255, 2);
isPixel(ctx, 98,1, 0,255,0,255, 2);
isPixel(ctx, 98,48, 0,255,0,255, 2);
isPixel(ctx, 48,1, 0,255,0,255, 2);
isPixel(ctx, 48,48, 0,255,0,255, 2);
isPixel(ctx, 51,1, 0,255,0,255, 2);
isPixel(ctx, 51,48, 0,255,0,255, 2);
isPixel(ctx, 25,25, 0,255,0,255, 2);
isPixel(ctx, 75,25, 0,255,0,255, 2);
} catch (e) {
_thrown_outer = true;
}
ok(!_thrown_outer, 'should not throw exception');
}
</script>
<img src="image_ggrr-256x256.png" id="ggrr-256x256_1.png" class="resource">
<!-- [[[ test_2d.drawImage.negativesource.html ]]] -->
<p>Canvas test: 2d.drawImage.negativesource</p>
<canvas id="c118" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_drawImage_negativesource() {
var canvas = document.getElementById('c118');
var ctx = canvas.getContext('2d');
var _thrown_outer = false;
try {
ctx.fillStyle = '#f00';
ctx.fillRect(0, 0, 100, 50);
ctx.drawImage(document.getElementById('ggrr-256x256_2.png'), 100, 78, -100, 50, 0, 0, 50, 50);
ctx.drawImage(document.getElementById('ggrr-256x256_2.png'), 100, 128, -100, -50, 50, 0, 50, 50);
isPixel(ctx, 1,1, 0,255,0,255, 2);
isPixel(ctx, 1,48, 0,255,0,255, 2);
isPixel(ctx, 98,1, 0,255,0,255, 2);
isPixel(ctx, 98,48, 0,255,0,255, 2);
isPixel(ctx, 48,1, 0,255,0,255, 2);
isPixel(ctx, 48,48, 0,255,0,255, 2);
isPixel(ctx, 51,1, 0,255,0,255, 2);
isPixel(ctx, 51,48, 0,255,0,255, 2);
isPixel(ctx, 25,25, 0,255,0,255, 2);
isPixel(ctx, 75,25, 0,255,0,255, 2);
} catch (e) {
_thrown_outer = true;
}
ok(!_thrown_outer, 'should not throw exception');
}
</script>
<img src="image_ggrr-256x256.png" id="ggrr-256x256_2.png" class="resource">
<!-- [[[ test_2d.drawImage.nonfinite.html ]]] -->
<p>Canvas test: 2d.drawImage.nonfinite</p>
<!-- Testing: drawImage() with Infinity/NaN is ignored -->
<canvas id="c119" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_drawImage_nonfinite() {
var canvas = document.getElementById('c119');
var ctx = canvas.getContext('2d');
var _thrown_outer = false;
try {
ctx.fillStyle = '#0f0';
ctx.fillRect(0, 0, 100, 50);
var red = document.getElementById('red_10.png');
ctx.drawImage(red, Infinity, 0);
ctx.drawImage(red, -Infinity, 0);
ctx.drawImage(red, NaN, 0);
ctx.drawImage(red, 0, Infinity);
ctx.drawImage(red, 0, -Infinity);
ctx.drawImage(red, 0, NaN);
ctx.drawImage(red, Infinity, Infinity);
ctx.drawImage(red, Infinity, 0, 100, 50);
ctx.drawImage(red, -Infinity, 0, 100, 50);
ctx.drawImage(red, NaN, 0, 100, 50);
ctx.drawImage(red, 0, Infinity, 100, 50);
ctx.drawImage(red, 0, -Infinity, 100, 50);
ctx.drawImage(red, 0, NaN, 100, 50);
ctx.drawImage(red, 0, 0, Infinity, 50);
ctx.drawImage(red, 0, 0, -Infinity, 50);
ctx.drawImage(red, 0, 0, NaN, 50);
ctx.drawImage(red, 0, 0, 100, Infinity);
ctx.drawImage(red, 0, 0, 100, -Infinity);
ctx.drawImage(red, 0, 0, 100, NaN);
ctx.drawImage(red, Infinity, Infinity, 100, 50);
ctx.drawImage(red, Infinity, Infinity, Infinity, 50);
ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity);
ctx.drawImage(red, Infinity, Infinity, 100, Infinity);
ctx.drawImage(red, Infinity, 0, Infinity, 50);
ctx.drawImage(red, Infinity, 0, Infinity, Infinity);
ctx.drawImage(red, Infinity, 0, 100, Infinity);
ctx.drawImage(red, 0, Infinity, Infinity, 50);
ctx.drawImage(red, 0, Infinity, Infinity, Infinity);
ctx.drawImage(red, 0, Infinity, 100, Infinity);
ctx.drawImage(red, 0, 0, Infinity, Infinity);
ctx.drawImage(red, Infinity, 0, 100, 50, 0, 0, 100, 50);
ctx.drawImage(red, -Infinity, 0, 100, 50, 0, 0, 100, 50);
ctx.drawImage(red, NaN, 0, 100, 50, 0, 0, 100, 50);
ctx.drawImage(red, 0, Infinity, 100, 50, 0, 0, 100, 50);
ctx.drawImage(red, 0, -Infinity, 100, 50, 0, 0, 100, 50);
ctx.drawImage(red, 0, NaN, 100, 50, 0, 0, 100, 50);
ctx.drawImage(red, 0, 0, Infinity, 50, 0, 0, 100, 50);
ctx.drawImage(red, 0, 0, -Infinity, 50, 0, 0, 100, 50);
ctx.drawImage(red, 0, 0, NaN, 50, 0, 0, 100, 50);
ctx.drawImage(red, 0, 0, 100, Infinity, 0, 0, 100, 50);
ctx.drawImage(red, 0, 0, 100, -Infinity, 0, 0, 100, 50);
ctx.drawImage(red, 0, 0, 100, NaN, 0, 0, 100, 50);
ctx.drawImage(red, 0, 0, 100, 50, Infinity, 0, 100, 50);
ctx.drawImage(red, 0, 0, 100, 50, -Infinity, 0, 100, 50);
ctx.drawImage(red, 0, 0, 100, 50, NaN, 0, 100, 50);
ctx.drawImage(red, 0, 0, 100, 50, 0, Infinity, 100, 50);
ctx.drawImage(red, 0, 0, 100, 50, 0, -Infinity, 100, 50);
ctx.drawImage(red, 0, 0, 100, 50, 0, NaN, 100, 50);
ctx.drawImage(red, 0, 0, 100, 50, 0, 0, Infinity, 50);
ctx.drawImage(red, 0, 0, 100, 50, 0, 0, -Infinity, 50);
ctx.drawImage(red, 0, 0, 100, 50, 0, 0, NaN, 50);
ctx.drawImage(red, 0, 0, 100, 50, 0, 0, 100, Infinity);
ctx.drawImage(red, 0, 0, 100, 50, 0, 0, 100, -Infinity);
ctx.drawImage(red, 0, 0, 100, 50, 0, 0, 100, NaN);
ctx.drawImage(red, Infinity, Infinity, 100, 50, 0, 0, 100, 50);
ctx.drawImage(red, Infinity, Infinity, Infinity, 50, 0, 0, 100, 50);
ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, 0, 0, 100, 50);
ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, Infinity, 0, 100, 50);
ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, 100, 50);
ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, 50);
ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity);
ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, 100, Infinity);
ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, Infinity, 0, Infinity, 50);
ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, Infinity, 0, Infinity, Infinity);
ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, Infinity, 0, 100, Infinity);
ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, 0, Infinity, 100, 50);
ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, 0, Infinity, Infinity, 50);
ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, 0, Infinity, Infinity, Infinity);
ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, 0, Infinity, 100, Infinity);
ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, 0, 0, Infinity, 50);
ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, 0, 0, Infinity, Infinity);
ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, 0, 0, 100, Infinity);
ctx.drawImage(red, Infinity, Infinity, Infinity, 50, Infinity, 0, 100, 50);
ctx.drawImage(red, Infinity, Infinity, Infinity, 50, Infinity, Infinity, 100, 50);
ctx.drawImage(red, Infinity, Infinity, Infinity, 50, Infinity, Infinity, Infinity, 50);
ctx.drawImage(red, Infinity, Infinity, Infinity, 50, Infinity, Infinity, Infinity, Infinity);
ctx.drawImage(red, Infinity, Infinity, Infinity, 50, Infinity, Infinity, 100, Infinity);
ctx.drawImage(red, Infinity, Infinity, Infinity, 50, Infinity, 0, Infinity, 50);
ctx.drawImage(red, Infinity, Infinity, Infinity, 50, Infinity, 0, Infinity, Infinity);
ctx.drawImage(red, Infinity, Infinity, Infinity, 50, Infinity, 0, 100, Infinity);
ctx.drawImage(red, Infinity, Infinity, Infinity, 50, 0, Infinity, 100, 50);
ctx.drawImage(red, Infinity, Infinity, Infinity, 50, 0, Infinity, Infinity, 50);
ctx.drawImage(red, Infinity, Infinity, Infinity, 50, 0, Infinity, Infinity, Infinity);
ctx.drawImage(red, Infinity, Infinity, Infinity, 50, 0, Infinity, 100, Infinity);
ctx.drawImage(red, Infinity, Infinity, Infinity, 50, 0, 0, Infinity, 50);
ctx.drawImage(red, Infinity, Infinity, Infinity, 50, 0, 0, Infinity, Infinity);
ctx.drawImage(red, Infinity, Infinity, Infinity, 50, 0, 0, 100, Infinity);
ctx.drawImage(red, Infinity, Infinity, 100, Infinity, 0, 0, 100, 50);
ctx.drawImage(red, Infinity, Infinity, 100, Infinity, Infinity, 0, 100, 50);
ctx.drawImage(red, Infinity, Infinity, 100, Infinity, Infinity, Infinity, 100, 50);
ctx.drawImage(red, Infinity, Infinity, 100, Infinity, Infinity, Infinity, Infinity, 50);
ctx.drawImage(red, Infinity, Infinity, 100, Infinity, Infinity, Infinity, Infinity, Infinity);
ctx.drawImage(red, Infinity, Infinity, 100, Infinity, Infinity, Infinity, 100, Infinity);
ctx.drawImage(red, Infinity, Infinity, 100, Infinity, Infinity, 0, Infinity, 50);
ctx.drawImage(red, Infinity, Infinity, 100, Infinity, Infinity, 0, Infinity, Infinity);
ctx.drawImage(red, Infinity, Infinity, 100, Infinity, Infinity, 0, 100, Infinity);
ctx.drawImage(red, Infinity, Infinity, 100, Infinity, 0, Infinity, 100, 50);
ctx.drawImage(red, Infinity, Infinity, 100, Infinity, 0, Infinity, Infinity, 50);
ctx.drawImage(red, Infinity, Infinity, 100, Infinity, 0, Infinity, Infinity, Infinity);
ctx.drawImage(red, Infinity, Infinity, 100, Infinity, 0, Infinity, 100, Infinity);
ctx.drawImage(red, Infinity, Infinity, 100, Infinity, 0, 0, Infinity, 50);
ctx.drawImage(red, Infinity, Infinity, 100, Infinity, 0, 0, Infinity, Infinity);
ctx.drawImage(red, Infinity, Infinity, 100, Infinity, 0, 0, 100, Infinity);
ctx.drawImage(red, Infinity, Infinity, 100, 50, Infinity, 0, 100, 50);
ctx.drawImage(red, Infinity, Infinity, 100, 50, Infinity, Infinity, 100, 50);
ctx.drawImage(red, Infinity, Infinity, 100, 50, Infinity, Infinity, Infinity, 50);
ctx.drawImage(red, Infinity, Infinity, 100, 50, Infinity, Infinity, Infinity, Infinity);
ctx.drawImage(red, Infinity, Infinity, 100, 50, Infinity, Infinity, 100, Infinity);
ctx.drawImage(red, Infinity, Infinity, 100, 50, Infinity, 0, Infinity, 50);
ctx.drawImage(red, Infinity, Infinity, 100, 50, Infinity, 0, Infinity, Infinity);
ctx.drawImage(red, Infinity, Infinity, 100, 50, Infinity, 0, 100, Infinity);
ctx.drawImage(red, Infinity, Infinity, 100, 50, 0, Infinity, 100, 50);
ctx.drawImage(red, Infinity, Infinity, 100, 50, 0, Infinity, Infinity, 50);
ctx.drawImage(red, Infinity, Infinity, 100, 50, 0, Infinity, Infinity, Infinity);
ctx.drawImage(red, Infinity, Infinity, 100, 50, 0, Infinity, 100, Infinity);
ctx.drawImage(red, Infinity, Infinity, 100, 50, 0, 0, Infinity, 50);
ctx.drawImage(red, Infinity, Infinity, 100, 50, 0, 0, Infinity, Infinity);
ctx.drawImage(red, Infinity, Infinity, 100, 50, 0, 0, 100, Infinity);
ctx.drawImage(red, Infinity, 0, Infinity, 50, 0, 0, 100, 50);
ctx.drawImage(red, Infinity, 0, Infinity, Infinity, 0, 0, 100, 50);
ctx.drawImage(red, Infinity, 0, Infinity, Infinity, Infinity, 0, 100, 50);
ctx.drawImage(red, Infinity, 0, Infinity, Infinity, Infinity, Infinity, 100, 50);
ctx.drawImage(red, Infinity, 0, Infinity, Infinity, Infinity, Infinity, Infinity, 50);
ctx.drawImage(red, Infinity, 0, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity);
ctx.drawImage(red, Infinity, 0, Infinity, Infinity, Infinity, Infinity, 100, Infinity);
ctx.drawImage(red, Infinity, 0, Infinity, Infinity, Infinity, 0, Infinity, 50);
ctx.drawImage(red, Infinity, 0, Infinity, Infinity, Infinity, 0, Infinity, Infinity);
ctx.drawImage(red, Infinity, 0, Infinity, Infinity, Infinity, 0, 100, Infinity);
ctx.drawImage(red, Infinity, 0, Infinity, Infinity, 0, Infinity, 100, 50);
ctx.drawImage(red, Infinity, 0, Infinity, Infinity, 0, Infinity, Infinity, 50);
ctx.drawImage(red, Infinity, 0, Infinity, Infinity, 0, Infinity, Infinity, Infinity);
ctx.drawImage(red, Infinity, 0, Infinity, Infinity, 0, Infinity, 100, Infinity);
ctx.drawImage(red, Infinity, 0, Infinity, Infinity, 0, 0, Infinity, 50);
ctx.drawImage(red, Infinity, 0, Infinity, Infinity, 0, 0, Infinity, Infinity);
ctx.drawImage(red, Infinity, 0, Infinity, Infinity, 0, 0, 100, Infinity);
ctx.drawImage(red, Infinity, 0, Infinity, 50, Infinity, 0, 100, 50);
ctx.drawImage(red, Infinity, 0, Infinity, 50, Infinity, Infinity, 100, 50);
ctx.drawImage(red, Infinity, 0, Infinity, 50, Infinity, Infinity, Infinity, 50);
ctx.drawImage(red, Infinity, 0, Infinity, 50, Infinity, Infinity, Infinity, Infinity);
ctx.drawImage(red, Infinity, 0, Infinity, 50, Infinity, Infinity, 100, Infinity);
ctx.drawImage(red, Infinity, 0, Infinity, 50, Infinity, 0, Infinity, 50);
ctx.drawImage(red, Infinity, 0, Infinity, 50, Infinity, 0, Infinity, Infinity);
ctx.drawImage(red, Infinity, 0, Infinity, 50, Infinity, 0, 100, Infinity);
ctx.drawImage(red, Infinity, 0, Infinity, 50, 0, Infinity, 100, 50);
ctx.drawImage(red, Infinity, 0, Infinity, 50, 0, Infinity, Infinity, 50);
ctx.drawImage(red, Infinity, 0, Infinity, 50, 0, Infinity, Infinity, Infinity);
ctx.drawImage(red, Infinity, 0, Infinity, 50, 0, Infinity, 100, Infinity);
ctx.drawImage(red, Infinity, 0, Infinity, 50, 0, 0, Infinity, 50);
ctx.drawImage(red, Infinity, 0, Infinity, 50, 0, 0, Infinity, Infinity);
ctx.drawImage(red, Infinity, 0, Infinity, 50, 0, 0, 100, Infinity);
ctx.drawImage(red, Infinity, 0, 100, Infinity, 0, 0, 100, 50);
ctx.drawImage(red, Infinity, 0, 100, Infinity, Infinity, 0, 100, 50);
ctx.drawImage(red, Infinity, 0, 100, Infinity, Infinity, Infinity, 100, 50);
ctx.drawImage(red, Infinity, 0, 100, Infinity, Infinity, Infinity, Infinity, 50);
ctx.drawImage(red, Infinity, 0, 100, Infinity, Infinity, Infinity, Infinity, Infinity);
ctx.drawImage(red, Infinity, 0, 100, Infinity, Infinity, Infinity, 100, Infinity);
ctx.drawImage(red, Infinity, 0, 100, Infinity, Infinity, 0, Infinity, 50);
ctx.drawImage(red, Infinity, 0, 100, Infinity, Infinity, 0, Infinity, Infinity);
ctx.drawImage(red, Infinity, 0, 100, Infinity, Infinity, 0, 100, Infinity);
ctx.drawImage(red, Infinity, 0, 100, Infinity, 0, Infinity, 100, 50);
ctx.drawImage(red, Infinity, 0, 100, Infinity, 0, Infinity, Infinity, 50);
ctx.drawImage(red, Infinity, 0, 100, Infinity, 0, Infinity, Infinity, Infinity);
ctx.drawImage(red, Infinity, 0, 100, Infinity, 0, Infinity, 100, Infinity);
ctx.drawImage(red, Infinity, 0, 100, Infinity, 0, 0, Infinity, 50);
ctx.drawImage(red, Infinity, 0, 100, Infinity, 0, 0, Infinity, Infinity);
ctx.drawImage(red, Infinity, 0, 100, Infinity, 0, 0, 100, Infinity);
ctx.drawImage(red, Infinity, 0, 100, 50, Infinity, 0, 100, 50);
ctx.drawImage(red, Infinity, 0, 100, 50, Infinity, Infinity, 100, 50);
ctx.drawImage(red, Infinity, 0, 100, 50, Infinity, Infinity, Infinity, 50);
ctx.drawImage(red, Infinity, 0, 100, 50, Infinity, Infinity, Infinity, Infinity);
ctx.drawImage(red, Infinity, 0, 100, 50, Infinity, Infinity, 100, Infinity);
ctx.drawImage(red, Infinity, 0, 100, 50, Infinity, 0, Infinity, 50);
ctx.drawImage(red, Infinity, 0, 100, 50, Infinity, 0, Infinity, Infinity);
ctx.drawImage(red, Infinity, 0, 100, 50, Infinity, 0, 100, Infinity);
ctx.drawImage(red, Infinity, 0, 100, 50, 0, Infinity, 100, 50);
ctx.drawImage(red, Infinity, 0, 100, 50, 0, Infinity, Infinity, 50);
ctx.drawImage(red, Infinity, 0, 100, 50, 0, Infinity, Infinity, Infinity);
ctx.drawImage(red, Infinity, 0, 100, 50, 0, Infinity, 100, Infinity);
ctx.drawImage(red, Infinity, 0, 100, 50, 0, 0, Infinity, 50);
ctx.drawImage(red, Infinity, 0, 100, 50, 0, 0, Infinity, Infinity);
ctx.drawImage(red, Infinity, 0, 100, 50, 0, 0, 100, Infinity);
ctx.drawImage(red, 0, Infinity, Infinity, 50, 0, 0, 100, 50);
ctx.drawImage(red, 0, Infinity, Infinity, Infinity, 0, 0, 100, 50);
ctx.drawImage(red, 0, Infinity, Infinity, Infinity, Infinity, 0, 100, 50);
ctx.drawImage(red, 0, Infinity, Infinity, Infinity, Infinity, Infinity, 100, 50);
ctx.drawImage(red, 0, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, 50);
ctx.drawImage(red, 0, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity);
ctx.drawImage(red, 0, Infinity, Infinity, Infinity, Infinity, Infinity, 100, Infinity);
ctx.drawImage(red, 0, Infinity, Infinity, Infinity, Infinity, 0, Infinity, 50);
ctx.drawImage(red, 0, Infinity, Infinity, Infinity, Infinity, 0, Infinity, Infinity);
ctx.drawImage(red, 0, Infinity, Infinity, Infinity, Infinity, 0, 100, Infinity);
ctx.drawImage(red, 0, Infinity, Infinity, Infinity, 0, Infinity, 100, 50);
ctx.drawImage(red, 0, Infinity, Infinity, Infinity, 0, Infinity, Infinity, 50);
ctx.drawImage(red, 0, Infinity, Infinity, Infinity, 0, Infinity, Infinity, Infinity);
ctx.drawImage(red, 0, Infinity, Infinity, Infinity, 0, Infinity, 100, Infinity);
ctx.drawImage(red, 0, Infinity, Infinity, Infinity, 0, 0, Infinity, 50);
ctx.drawImage(red, 0, Infinity, Infinity, Infinity, 0, 0, Infinity, Infinity);
ctx.drawImage(red, 0, Infinity, Infinity, Infinity, 0, 0, 100, Infinity);
ctx.drawImage(red, 0, Infinity, Infinity, 50, Infinity, 0, 100, 50);
ctx.drawImage(red, 0, Infinity, Infinity, 50, Infinity, Infinity, 100, 50);
ctx.drawImage(red, 0, Infinity, Infinity, 50, Infinity, Infinity, Infinity, 50);
ctx.drawImage(red, 0, Infinity, Infinity, 50, Infinity, Infinity, Infinity, Infinity);
ctx.drawImage(red, 0, Infinity, Infinity, 50, Infinity, Infinity, 100, Infinity);
ctx.drawImage(red, 0, Infinity, Infinity, 50, Infinity, 0, Infinity, 50);
ctx.drawImage(red, 0, Infinity, Infinity, 50, Infinity, 0, Infinity, Infinity);
ctx.drawImage(red, 0, Infinity, Infinity, 50, Infinity, 0, 100, Infinity);
ctx.drawImage(red, 0, Infinity, Infinity, 50, 0, Infinity, 100, 50);
ctx.drawImage(red, 0, Infinity, Infinity, 50, 0, Infinity, Infinity, 50);
ctx.drawImage(red, 0, Infinity, Infinity, 50, 0, Infinity, Infinity, Infinity);
ctx.drawImage(red, 0, Infinity, Infinity, 50, 0, Infinity, 100, Infinity);
ctx.drawImage(red, 0, Infinity, Infinity, 50, 0, 0, Infinity, 50);
ctx.drawImage(red, 0, Infinity, Infinity, 50, 0, 0, Infinity, Infinity);
ctx.drawImage(red, 0, Infinity, Infinity, 50, 0, 0, 100, Infinity);
ctx.drawImage(red, 0, Infinity, 100, Infinity, 0, 0, 100, 50);
ctx.drawImage(red, 0, Infinity, 100, Infinity, Infinity, 0, 100, 50);
ctx.drawImage(red, 0, Infinity, 100, Infinity, Infinity, Infinity, 100, 50);
ctx.drawImage(red, 0, Infinity, 100, Infinity, Infinity, Infinity, Infinity, 50);
ctx.drawImage(red, 0, Infinity, 100, Infinity, Infinity, Infinity, Infinity, Infinity);
ctx.drawImage(red, 0, Infinity, 100, Infinity, Infinity, Infinity, 100, Infinity);
ctx.drawImage(red, 0, Infinity, 100, Infinity, Infinity, 0, Infinity, 50);
ctx.drawImage(red, 0, Infinity, 100, Infinity, Infinity, 0, Infinity, Infinity);
ctx.drawImage(red, 0, Infinity, 100, Infinity, Infinity, 0, 100, Infinity);
ctx.drawImage(red, 0, Infinity, 100, Infinity, 0, Infinity, 100, 50);
ctx.drawImage(red, 0, Infinity, 100, Infinity, 0, Infinity, Infinity, 50);
ctx.drawImage(red, 0, Infinity, 100, Infinity, 0, Infinity, Infinity, Infinity);
ctx.drawImage(red, 0, Infinity, 100, Infinity, 0, Infinity, 100, Infinity);
ctx.drawImage(red, 0, Infinity, 100, Infinity, 0, 0, Infinity, 50);
ctx.drawImage(red, 0, Infinity, 100, Infinity, 0, 0, Infinity, Infinity);
ctx.drawImage(red, 0, Infinity, 100, Infinity, 0, 0, 100, Infinity);
ctx.drawImage(red, 0, Infinity, 100, 50, Infinity, 0, 100, 50);
ctx.drawImage(red, 0, Infinity, 100, 50, Infinity, Infinity, 100, 50);
ctx.drawImage(red, 0, Infinity, 100, 50, Infinity, Infinity, Infinity, 50);
ctx.drawImage(red, 0, Infinity, 100, 50, Infinity, Infinity, Infinity, Infinity);
ctx.drawImage(red, 0, Infinity, 100, 50, Infinity, Infinity, 100, Infinity);
ctx.drawImage(red, 0, Infinity, 100, 50, Infinity, 0, Infinity, 50);
ctx.drawImage(red, 0, Infinity, 100, 50, Infinity, 0, Infinity, Infinity);
ctx.drawImage(red, 0, Infinity, 100, 50, Infinity, 0, 100, Infinity);
ctx.drawImage(red, 0, Infinity, 100, 50, 0, Infinity, 100, 50);
ctx.drawImage(red, 0, Infinity, 100, 50, 0, Infinity, Infinity, 50);
ctx.drawImage(red, 0, Infinity, 100, 50, 0, Infinity, Infinity, Infinity);
ctx.drawImage(red, 0, Infinity, 100, 50, 0, Infinity, 100, Infinity);
ctx.drawImage(red, 0, Infinity, 100, 50, 0, 0, Infinity, 50);
ctx.drawImage(red, 0, Infinity, 100, 50, 0, 0, Infinity, Infinity);
ctx.drawImage(red, 0, Infinity, 100, 50, 0, 0, 100, Infinity);
ctx.drawImage(red, 0, 0, Infinity, Infinity, 0, 0, 100, 50);
ctx.drawImage(red, 0, 0, Infinity, Infinity, Infinity, 0, 100, 50);
ctx.drawImage(red, 0, 0, Infinity, Infinity, Infinity, Infinity, 100, 50);
ctx.drawImage(red, 0, 0, Infinity, Infinity, Infinity, Infinity, Infinity, 50);
ctx.drawImage(red, 0, 0, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity);
ctx.drawImage(red, 0, 0, Infinity, Infinity, Infinity, Infinity, 100, Infinity);
ctx.drawImage(red, 0, 0, Infinity, Infinity, Infinity, 0, Infinity, 50);
ctx.drawImage(red, 0, 0, Infinity, Infinity, Infinity, 0, Infinity, Infinity);
ctx.drawImage(red, 0, 0, Infinity, Infinity, Infinity, 0, 100, Infinity);
ctx.drawImage(red, 0, 0, Infinity, Infinity, 0, Infinity, 100, 50);
ctx.drawImage(red, 0, 0, Infinity, Infinity, 0, Infinity, Infinity, 50);
ctx.drawImage(red, 0, 0, Infinity, Infinity, 0, Infinity, Infinity, Infinity);
ctx.drawImage(red, 0, 0, Infinity, Infinity, 0, Infinity, 100, Infinity);
ctx.drawImage(red, 0, 0, Infinity, Infinity, 0, 0, Infinity, 50);
ctx.drawImage(red, 0, 0, Infinity, Infinity, 0, 0, Infinity, Infinity);
ctx.drawImage(red, 0, 0, Infinity, Infinity, 0, 0, 100, Infinity);
ctx.drawImage(red, 0, 0, Infinity, 50, Infinity, 0, 100, 50);
ctx.drawImage(red, 0, 0, Infinity, 50, Infinity, Infinity, 100, 50);
ctx.drawImage(red, 0, 0, Infinity, 50, Infinity, Infinity, Infinity, 50);
ctx.drawImage(red, 0, 0, Infinity, 50, Infinity, Infinity, Infinity, Infinity);
ctx.drawImage(red, 0, 0, Infinity, 50, Infinity, Infinity, 100, Infinity);
ctx.drawImage(red, 0, 0, Infinity, 50, Infinity, 0, Infinity, 50);
ctx.drawImage(red, 0, 0, Infinity, 50, Infinity, 0, Infinity, Infinity);
ctx.drawImage(red, 0, 0, Infinity, 50, Infinity, 0, 100, Infinity);
ctx.drawImage(red, 0, 0, Infinity, 50, 0, Infinity, 100, 50);
ctx.drawImage(red, 0, 0, Infinity, 50, 0, Infinity, Infinity, 50);
ctx.drawImage(red, 0, 0, Infinity, 50, 0, Infinity, Infinity, Infinity);
ctx.drawImage(red, 0, 0, Infinity, 50, 0, Infinity, 100, Infinity);
ctx.drawImage(red, 0, 0, Infinity, 50, 0, 0, Infinity, 50);
ctx.drawImage(red, 0, 0, Infinity, 50, 0, 0, Infinity, Infinity);
ctx.drawImage(red, 0, 0, Infinity, 50, 0, 0, 100, Infinity);
ctx.drawImage(red, 0, 0, 100, Infinity, Infinity, 0, 100, 50);
ctx.drawImage(red, 0, 0, 100, Infinity, Infinity, Infinity, 100, 50);
ctx.drawImage(red, 0, 0, 100, Infinity, Infinity, Infinity, Infinity, 50);
ctx.drawImage(red, 0, 0, 100, Infinity, Infinity, Infinity, Infinity, Infinity);
ctx.drawImage(red, 0, 0, 100, Infinity, Infinity, Infinity, 100, Infinity);
ctx.drawImage(red, 0, 0, 100, Infinity, Infinity, 0, Infinity, 50);
ctx.drawImage(red, 0, 0, 100, Infinity, Infinity, 0, Infinity, Infinity);
ctx.drawImage(red, 0, 0, 100, Infinity, Infinity, 0, 100, Infinity);
ctx.drawImage(red, 0, 0, 100, Infinity, 0, Infinity, 100, 50);
ctx.drawImage(red, 0, 0, 100, Infinity, 0, Infinity, Infinity, 50);
ctx.drawImage(red, 0, 0, 100, Infinity, 0, Infinity, Infinity, Infinity);
ctx.drawImage(red, 0, 0, 100, Infinity, 0, Infinity, 100, Infinity);
ctx.drawImage(red, 0, 0, 100, Infinity, 0, 0, Infinity, 50);
ctx.drawImage(red, 0, 0, 100, Infinity, 0, 0, Infinity, Infinity);
ctx.drawImage(red, 0, 0, 100, Infinity, 0, 0, 100, Infinity);
ctx.drawImage(red, 0, 0, 100, 50, Infinity, Infinity, 100, 50);
ctx.drawImage(red, 0, 0, 100, 50, Infinity, Infinity, Infinity, 50);
ctx.drawImage(red, 0, 0, 100, 50, Infinity, Infinity, Infinity, Infinity);
ctx.drawImage(red, 0, 0, 100, 50, Infinity, Infinity, 100, Infinity);
ctx.drawImage(red, 0, 0, 100, 50, Infinity, 0, Infinity, 50);
ctx.drawImage(red, 0, 0, 100, 50, Infinity, 0, Infinity, Infinity);
ctx.drawImage(red, 0, 0, 100, 50, Infinity, 0, 100, Infinity);
ctx.drawImage(red, 0, 0, 100, 50, 0, Infinity, Infinity, 50);
ctx.drawImage(red, 0, 0, 100, 50, 0, Infinity, Infinity, Infinity);
ctx.drawImage(red, 0, 0, 100, 50, 0, Infinity, 100, Infinity);
ctx.drawImage(red, 0, 0, 100, 50, 0, 0, Infinity, Infinity);
isPixel(ctx, 50,25, 0,255,0,255, 0);
} catch (e) {
_thrown_outer = true;
}
ok(!_thrown_outer, 'should not throw exception');
}
</script>
<img src="image_red.png" id="red_10.png" class="resource">
<!-- [[[ test_2d.drawImage.nowrap.html ]]] -->
<p>Canvas test: 2d.drawImage.nowrap</p>
<!-- Testing: Stretched images do not get pixels wrapping around the edges -->
<canvas id="c120" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_drawImage_nowrap() {
var canvas = document.getElementById('c120');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#0f0';
ctx.fillRect(0, 0, 100, 50);
ctx.drawImage(document.getElementById('redtransparent_1.png'), -1950, 0, 2000, 50);
isPixel(ctx, 45,25, 0,255,0,255, 2);
isPixel(ctx, 50,25, 0,255,0,255, 2);
isPixel(ctx, 55,25, 0,255,0,255, 2);
}
</script>
<img src="image_redtransparent.png" id="redtransparent_1.png" class="resource">
<!-- [[[ test_2d.drawImage.null.html ]]] -->
<p>Canvas test: 2d.drawImage.null</p>
<canvas id="c121" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_drawImage_null() {
var canvas = document.getElementById('c121');
var ctx = canvas.getContext('2d');
var _thrown = undefined; try {
ctx.drawImage(null, 0, 0);
} catch (e) { _thrown = e };
ok(_thrown && _thrown.name == "TypeError", "should throw TypeError");
}
</script>
<!-- [[[ test_2d.drawImage.path.html ]]] -->
<p>Canvas test: 2d.drawImage.path</p>
<canvas id="c123" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_drawImage_path() {
var canvas = document.getElementById('c123');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#0f0';
ctx.rect(0, 0, 100, 50);
ctx.drawImage(document.getElementById('red_12.png'), 0, 0);
ctx.fill();
isPixel(ctx, 50,25, 0,255,0,255, 2);
}
</script>
<img src="image_red.png" id="red_12.png" class="resource">
<!-- [[[ test_2d.drawImage.self.1.html ]]] -->
<p>Canvas test: 2d.drawImage.self.1 - bug 433235</p>
<canvas id="c124" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_drawImage_self_1() {
var canvas = document.getElementById('c124');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#0f0';
ctx.fillRect(0, 0, 50, 50);
ctx.fillStyle = '#f00';
ctx.fillRect(50, 0, 50, 50);
ctx.drawImage(canvas, 50, 0);
isPixel(ctx, 0,0, 0,255,0,255, 2);
isPixel(ctx, 99,0, 0,255,0,255, 2);
isPixel(ctx, 0,49, 0,255,0,255, 2);
isPixel(ctx, 99,49, 0,255,0,255, 2);
}
</script>
<!-- [[[ test_2d.drawImage.self.2.html ]]] -->
<p>Canvas test: 2d.drawImage.self.2 - bug 433235</p>
<canvas id="c125" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_drawImage_self_2() {
var canvas = document.getElementById('c125');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#0f0';
ctx.fillRect(0, 1, 100, 49);
ctx.fillStyle = '#f00';
ctx.fillRect(0, 0, 100, 1);
ctx.drawImage(canvas, 0, 1);
ctx.fillStyle = '#0f0';
ctx.fillRect(0, 0, 100, 2);
isPixel(ctx, 0,0, 0,255,0,255, 2);
isPixel(ctx, 99,0, 0,255,0,255, 2);
isPixel(ctx, 0,49, 0,255,0,255, 2);
isPixel(ctx, 99,49, 0,255,0,255, 2);
}
</script>
<!-- [[[ test_2d.drawImage.transform.html ]]] -->
<p>Canvas test: 2d.drawImage.transform</p>
<canvas id="c126" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_drawImage_transform() {
var canvas = document.getElementById('c126');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#0f0';
ctx.fillRect(0, 0, 100, 50);
ctx.translate(100, 0);
ctx.drawImage(document.getElementById('red_13.png'), 0, 0);
isPixel(ctx, 50,25, 0,255,0,255, 2);
}
</script>
<img src="image_red.png" id="red_13.png" class="resource">
<!-- [[[ test_2d.drawImage.wrongtype.html ]]] -->
<p>Canvas test: 2d.drawImage.wrongtype</p>
<canvas id="c127" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_drawImage_wrongtype() {
var canvas = document.getElementById('c127');
var ctx = canvas.getContext('2d');
var _thrown = undefined; try {
ctx.drawImage(undefined, 0, 0);
} catch (e) { _thrown = e };
ok(_thrown && _thrown.name == "TypeError", "should throw TypeError");
var _thrown = undefined; try {
ctx.drawImage(0, 0, 0);
} catch (e) { _thrown = e };
ok(_thrown && _thrown.name == "TypeError", "should throw TypeError");
var _thrown = undefined; try {
ctx.drawImage("", 0, 0);
} catch (e) { _thrown = e };
ok(_thrown && _thrown.name == "TypeError", "should throw TypeError");
var _thrown = undefined; try {
ctx.drawImage(document.createElement('p'), 0, 0);
} catch (e) { _thrown = e };
ok(_thrown && _thrown.name == "TypeError", "should throw TypeError");
}
</script>
<!-- [[[ test_2d.drawImage.zerosource.html ]]] -->
<p>Canvas test: 2d.drawImage.zerosource</p>
<!-- Testing: drawImage with zero-sized source rectangle does nothing -->
<canvas id="c128" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_drawImage_zerosource() {
var canvas = document.getElementById('c128');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#0f0';
ctx.fillRect(0, 0, 100, 50);
ctx.drawImage(document.getElementById('red_14.png'), 10, 10, 0, 1, 0, 0, 100, 50);
ctx.drawImage(document.getElementById('red_14.png'), 10, 10, 1, 0, 0, 0, 100, 50);
ctx.drawImage(document.getElementById('red_14.png'), 10, 10, 0, 0, 0, 0, 100, 50);
isPixel(ctx, 50,25, 0,255,0,255, 2);
}
</script>
<img src="image_red.png" id="red_14.png" class="resource">
<!-- [[[ test_2d.fillRect.basic.html ]]] -->
<p>Canvas test: 2d.fillRect.basic</p>
<canvas id="c129" width="100" height="50" style="background: #f00"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillRect_basic() {
var canvas = document.getElementById('c129');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#0f0';
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.fillRect.clip.html ]]] -->
<p>Canvas test: 2d.fillRect.clip</p>
<canvas id="c130" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillRect_clip() {
var canvas = document.getElementById('c130');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#0f0';
ctx.fillRect(0, 0, 100, 50);
ctx.beginPath();
ctx.rect(0, 0, 16, 16);
ctx.clip();
ctx.fillStyle = '#f00';
ctx.fillRect(0, 0, 100, 50);
ctx.fillStyle = '#0f0';
ctx.fillRect(0, 0, 16, 16);
isPixel(ctx, 50,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.fillRect.negative.html ]]] -->
<p>Canvas test: 2d.fillRect.negative</p>
<canvas id="c131" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillRect_negative() {
var canvas = document.getElementById('c131');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#f00';
ctx.fillRect(0, 0, 100, 50);
ctx.fillStyle = '#0f0';
ctx.fillRect(0, 0, 50, 25);
ctx.fillRect(100, 0, -50, 25);
ctx.fillRect(0, 50, 50, -25);
ctx.fillRect(100, 50, -50, -25);
isPixel(ctx, 25,12, 0,255,0,255, 0);
isPixel(ctx, 75,12, 0,255,0,255, 0);
isPixel(ctx, 25,37, 0,255,0,255, 0);
isPixel(ctx, 75,37, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.fillRect.nonfinite.html ]]] -->
<p>Canvas test: 2d.fillRect.nonfinite</p>
<!-- Testing: fillRect() with Infinity/NaN is ignored -->
<canvas id="c132" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillRect_nonfinite() {
var canvas = document.getElementById('c132');
var ctx = canvas.getContext('2d');
var _thrown_outer = false;
try {
ctx.fillStyle = '#0f0';
ctx.fillRect(0, 0, 100, 50);
ctx.fillStyle = '#f00';
ctx.fillRect(Infinity, 0, 100, 50);
ctx.fillRect(-Infinity, 0, 100, 50);
ctx.fillRect(NaN, 0, 100, 50);
ctx.fillRect(0, Infinity, 100, 50);
ctx.fillRect(0, -Infinity, 100, 50);
ctx.fillRect(0, NaN, 100, 50);
ctx.fillRect(0, 0, Infinity, 50);
ctx.fillRect(0, 0, -Infinity, 50);
ctx.fillRect(0, 0, NaN, 50);
ctx.fillRect(0, 0, 100, Infinity);
ctx.fillRect(0, 0, 100, -Infinity);
ctx.fillRect(0, 0, 100, NaN);
ctx.fillRect(Infinity, Infinity, 100, 50);
ctx.fillRect(Infinity, Infinity, Infinity, 50);
ctx.fillRect(Infinity, Infinity, Infinity, Infinity);
ctx.fillRect(Infinity, Infinity, 100, Infinity);
ctx.fillRect(Infinity, 0, Infinity, 50);
ctx.fillRect(Infinity, 0, Infinity, Infinity);
ctx.fillRect(Infinity, 0, 100, Infinity);
ctx.fillRect(0, Infinity, Infinity, 50);
ctx.fillRect(0, Infinity, Infinity, Infinity);
ctx.fillRect(0, Infinity, 100, Infinity);
ctx.fillRect(0, 0, Infinity, Infinity);
isPixel(ctx, 50,25, 0,255,0,255, 0);
} catch (e) {
_thrown_outer = true;
}
ok(!_thrown_outer, ctx.canvas.id + ' should not throw exception');
}
</script>
<!-- [[[ test_2d.fillRect.path.html ]]] -->
<p>Canvas test: 2d.fillRect.path</p>
<canvas id="c133" width="100" height="50" style="background: #f00"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillRect_path() {
var canvas = document.getElementById('c133');
var ctx = canvas.getContext('2d');
ctx.beginPath();
ctx.rect(0, 0, 100, 50);
ctx.fillStyle = '#f00';
ctx.fillRect(0, 0, 16, 16);
ctx.fillStyle = '#0f0';
ctx.fill();
isPixel(ctx, 50,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.fillRect.shadow.html ]]] -->
<p>Canvas test: 2d.fillRect.shadow</p>
<canvas id="c134" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillRect_shadow() {
var canvas = document.getElementById('c134');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#0f0';
ctx.fillRect(0, 0, 100, 50);
ctx.fillStyle = '#f00';
ctx.shadowBlur = 0;
ctx.shadowOffsetX = 0;
ctx.shadowOffsetY = 50;
// Shadows are optional, so just test that if they apply to fill() then they apply to fillRect() too
ctx.beginPath();
ctx.rect(0, -50, 100, 50);
ctx.shadowColor = '#f00';
ctx.fill();
ctx.shadowColor = '#0f0';
ctx.fillRect(0, -50, 100, 50);
isPixel(ctx, 50,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.fillRect.transform.html ]]] -->
<p>Canvas test: 2d.fillRect.transform</p>
<canvas id="c135" width="100" height="50" style="background: #f00"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillRect_transform() {
var canvas = document.getElementById('c135');
var ctx = canvas.getContext('2d');
ctx.scale(10, 10);
ctx.translate(0, 5);
ctx.fillStyle = '#0f0';
ctx.fillRect(0, -5, 10, 5);
isPixel(ctx, 50,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.fillRect.zero.html ]]] -->
<p>Canvas test: 2d.fillRect.zero</p>
<canvas id="c136" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillRect_zero() {
var canvas = document.getElementById('c136');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#0f0';
ctx.fillRect(0, 0, 100, 50);
ctx.fillStyle = '#f00';
ctx.fillRect(0, 0, 100, 0);
ctx.fillRect(0, 0, 0, 50);
ctx.fillRect(0, 0, 0, 0);
isPixel(ctx, 50,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.fillStyle.default.html ]]] -->
<p>Canvas test: 2d.fillStyle.default</p>
<canvas id="c137" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_default() {
var canvas = document.getElementById('c137');
var ctx = canvas.getContext('2d');
ok(ctx.fillStyle == '#000000', "ctx.fillStyle == '#000000'");
}
</script>
<!-- [[[ test_2d.fillStyle.get.semitransparent.html ]]] -->
<p>Canvas test: 2d.fillStyle.get.semitransparent</p>
<canvas id="c138" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_get_semitransparent() {
var canvas = document.getElementById('c138');
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'rgba(255,255,255,0.45)';
ok(/^rgba\(255, 255, 255, 0\.4\d+\)$/.test(ctx.fillStyle), "ctx.fillStyle =~ /^rgba\\(255, 255, 255, 0\\.4\\d+\\)$/");
}
</script>
<!-- [[[ test_2d.fillStyle.get.solid.html ]]] -->
<p>Canvas test: 2d.fillStyle.get.solid</p>
<canvas id="c139" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_get_solid() {
var canvas = document.getElementById('c139');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#fa0';
ok(ctx.fillStyle === '#ffaa00', "ctx.fillStyle === '#ffaa00'");
}
</script>
<!-- [[[ test_2d.fillStyle.get.transparent.html ]]] -->
<p>Canvas test: 2d.fillStyle.get.transparent</p>
<canvas id="c140" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_get_transparent() {
var canvas = document.getElementById('c140');
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'rgba(0,0,0,0)';
is(ctx.fillStyle, 'rgba(0, 0, 0, 0)', "ctx.fillStyle should be what we set it to");
}
</script>
<!-- [[[ test_2d.fillStyle.invalidstring.html ]]] -->
<p>Canvas test: 2d.fillStyle.invalidstring</p>
<canvas id="c141" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_invalidstring() {
var canvas = document.getElementById('c141');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#f00';
ctx.fillRect(0, 0, 100, 50);
ctx.fillStyle = '#0f0';
ctx.fillStyle = 'invalid';
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.fillStyle.invalidtype.html ]]] -->
<p>Canvas test: 2d.fillStyle.invalidtype</p>
<canvas id="c142" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_invalidtype() {
var canvas = document.getElementById('c142');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#f00';
ctx.fillRect(0, 0, 100, 50);
ctx.fillStyle = '#0f0';
ctx.fillStyle = null;
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.fillStyle.parse.current.basic.html ]]] -->
<p>Canvas test: 2d.fillStyle.parse.current.basic</p>
<!-- Testing: currentColor is computed from the canvas element -->
<canvas id="c143" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_parse_current_basic() {
var canvas = document.getElementById('c143');
var ctx = canvas.getContext('2d');
canvas.setAttribute('style', 'color: #0f0');
ctx.fillStyle = '#f00';
ctx.fillStyle = 'currentColor';
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.fillStyle.parse.current.changed.html ]]] -->
<p>Canvas test: 2d.fillStyle.parse.current.changed</p>
<!-- Testing: currentColor is computed when the attribute is set, not when it is painted -->
<canvas id="c144" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_parse_current_changed() {
var canvas = document.getElementById('c144');
var ctx = canvas.getContext('2d');
canvas.setAttribute('style', 'color: #0f0');
ctx.fillStyle = '#f00';
ctx.fillStyle = 'currentColor';
canvas.setAttribute('style', 'color: #f00');
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.fillStyle.parse.current.removed.html ]]] -->
<p>Canvas test: 2d.fillStyle.parse.current.removed</p>
<!-- Testing: currentColor is solid black when the canvas element is not in a document -->
<canvas id="c145" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_parse_current_removed() {
var canvas = document.getElementById('c145');
var ctx = canvas.getContext('2d');
// Try not to let it undetectably incorrectly pick up opaque-black
// from other parts of the document:
document.body.parentNode.setAttribute('style', 'color: #f00');
document.body.setAttribute('style', 'color: #f00');
canvas.setAttribute('style', 'color: #f00');
var canvas2 = document.createElement('canvas');
var ctx2 = canvas2.getContext('2d');
ctx2.fillStyle = '#f00';
ctx2.fillStyle = 'currentColor';
ctx2.fillRect(0, 0, 100, 50);
ctx.drawImage(canvas2, 0, 0);
document.body.parentNode.removeAttribute('style');
document.body.removeAttribute('style');
isPixel(ctx, 50,25, 0,0,0,255, 0);
}
</script>
<!-- [[[ test_2d.fillStyle.parse.hex3.html ]]] -->
<p>Canvas test: 2d.fillStyle.parse.hex3</p>
<canvas id="c146" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_parse_hex3() {
var canvas = document.getElementById('c146');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#f00';
ctx.fillStyle = '#0f0';
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.fillStyle.parse.hex6.html ]]] -->
<p>Canvas test: 2d.fillStyle.parse.hex6</p>
<canvas id="c147" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_parse_hex6() {
var canvas = document.getElementById('c147');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#f00';
ctx.fillStyle = '#00fF00';
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.fillStyle.parse.hsl-1.html ]]] -->
<p>Canvas test: 2d.fillStyle.parse.hsl-1</p>
<canvas id="c148" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_parse_hsl_1() {
var canvas = document.getElementById('c148');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#f00';
ctx.fillStyle = 'hsl(120, 100%, 50%)';
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.fillStyle.parse.hsl-2.html ]]] -->
<p>Canvas test: 2d.fillStyle.parse.hsl-2</p>
<canvas id="c149" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_parse_hsl_2() {
var canvas = document.getElementById('c149');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#f00';
ctx.fillStyle = 'hsl( -240 , 100% , 50% )';
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.fillStyle.parse.hsl-3.html ]]] -->
<p>Canvas test: 2d.fillStyle.parse.hsl-3</p>
<canvas id="c150" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_parse_hsl_3() {
var canvas = document.getElementById('c150');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#f00';
ctx.fillStyle = 'hsl(360120, 100%, 50%)';
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.fillStyle.parse.hsl-4.html ]]] -->
<p>Canvas test: 2d.fillStyle.parse.hsl-4</p>
<canvas id="c151" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_parse_hsl_4() {
var canvas = document.getElementById('c151');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#f00';
ctx.fillStyle = 'hsl(-360240, 100%, 50%)';
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.fillStyle.parse.hsl-5.html ]]] -->
<p>Canvas test: 2d.fillStyle.parse.hsl-5</p>
<canvas id="c152" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_parse_hsl_5() {
var canvas = document.getElementById('c152');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#f00';
ctx.fillStyle = 'hsl(120.0, 100.0%, 50.0%)';
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.fillStyle.parse.hsl-clamp-1.html ]]] -->
<p>Canvas test: 2d.fillStyle.parse.hsl-clamp-1</p>
<canvas id="c153" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_parse_hsl_clamp_1() {
var canvas = document.getElementById('c153');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#f00';
ctx.fillStyle = 'hsl(120, 200%, 50%)';
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.fillStyle.parse.hsl-clamp-2.html ]]] -->
<p>Canvas test: 2d.fillStyle.parse.hsl-clamp-2</p>
<canvas id="c154" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_parse_hsl_clamp_2() {
var canvas = document.getElementById('c154');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#f00';
ctx.fillStyle = 'hsl(120, -200%, 49.9%)';
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 127,127,127,255, 0);
}
</script>
<!-- [[[ test_2d.fillStyle.parse.hsl-clamp-3.html ]]] -->
<p>Canvas test: 2d.fillStyle.parse.hsl-clamp-3</p>
<canvas id="c155" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_parse_hsl_clamp_3() {
var canvas = document.getElementById('c155');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#f00';
ctx.fillStyle = 'hsl(120, 100%, 200%)';
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 255,255,255,255, 0);
}
</script>
<!-- [[[ test_2d.fillStyle.parse.hsl-clamp-4.html ]]] -->
<p>Canvas test: 2d.fillStyle.parse.hsl-clamp-4</p>
<canvas id="c156" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_parse_hsl_clamp_4() {
var canvas = document.getElementById('c156');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#f00';
ctx.fillStyle = 'hsl(120, 100%, -200%)';
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,0,0,255, 0);
}
</script>
<!-- [[[ test_2d.fillStyle.parse.hsla-1.html ]]] -->
<p>Canvas test: 2d.fillStyle.parse.hsla-1</p>
<canvas id="c157" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_parse_hsla_1() {
var canvas = document.getElementById('c157');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#f00';
ctx.fillStyle = 'hsla(120, 100%, 50%, 0.499)';
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,255,0,127, 0);
}
</script>
<!-- [[[ test_2d.fillStyle.parse.hsla-2.html ]]] -->
<p>Canvas test: 2d.fillStyle.parse.hsla-2</p>
<canvas id="c158" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_parse_hsla_2() {
var canvas = document.getElementById('c158');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#f00';
ctx.fillStyle = 'hsla( 120.0 , 100.0% , 50.0% , 1 )';
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.fillStyle.parse.hsla-clamp-1.html ]]] -->
<p>Canvas test: 2d.fillStyle.parse.hsla-clamp-1</p>
<canvas id="c159" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_parse_hsla_clamp_1() {
var canvas = document.getElementById('c159');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#f00';
ctx.fillStyle = 'hsla(120, 200%, 50%, 1)';
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.fillStyle.parse.hsla-clamp-2.html ]]] -->
<p>Canvas test: 2d.fillStyle.parse.hsla-clamp-2</p>
<canvas id="c160" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_parse_hsla_clamp_2() {
var canvas = document.getElementById('c160');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#f00';
ctx.fillStyle = 'hsla(120, -200%, 49.9%, 1)';
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 127,127,127,255, 0);
}
</script>
<!-- [[[ test_2d.fillStyle.parse.hsla-clamp-3.html ]]] -->
<p>Canvas test: 2d.fillStyle.parse.hsla-clamp-3</p>
<canvas id="c161" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_parse_hsla_clamp_3() {
var canvas = document.getElementById('c161');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#f00';
ctx.fillStyle = 'hsla(120, 100%, 200%, 1)';
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 255,255,255,255, 0);
}
</script>
<!-- [[[ test_2d.fillStyle.parse.hsla-clamp-4.html ]]] -->
<p>Canvas test: 2d.fillStyle.parse.hsla-clamp-4</p>
<canvas id="c162" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_parse_hsla_clamp_4() {
var canvas = document.getElementById('c162');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#f00';
ctx.fillStyle = 'hsla(120, 100%, -200%, 1)';
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,0,0,255, 0);
}
</script>
<!-- [[[ test_2d.fillStyle.parse.hsla-clamp-5.html ]]] -->
<p>Canvas test: 2d.fillStyle.parse.hsla-clamp-5</p>
<canvas id="c163" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_parse_hsla_clamp_5() {
var canvas = document.getElementById('c163');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#f00';
ctx.fillStyle = 'hsla(120, 100%, 50%, 2)';
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.fillStyle.parse.hsla-clamp-6.html ]]] -->
<p>Canvas test: 2d.fillStyle.parse.hsla-clamp-6</p>
<canvas id="c164" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_parse_hsla_clamp_6() {
var canvas = document.getElementById('c164');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#f00';
ctx.fillStyle = 'hsla(120, 100%, 0%, -2)';
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,0,0,0, 0);
}
</script>
<!-- [[[ test_2d.fillStyle.parse.html4.html ]]] -->
<p>Canvas test: 2d.fillStyle.parse.html4</p>
<canvas id="c165" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_parse_html4() {
var canvas = document.getElementById('c165');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#f00';
ctx.fillStyle = 'limE';
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.fillStyle.parse.invalid.hex3.html ]]] -->
<p>Canvas test: 2d.fillStyle.parse.invalid.hex3</p>
<canvas id="c166" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_parse_invalid_hex3() {
var canvas = document.getElementById('c166');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#0f0';
try { ctx.fillStyle = '#g00'; } catch (e) { } // this shouldn't throw, but it shouldn't matter here if it does
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.fillStyle.parse.invalid.hex6.html ]]] -->
<p>Canvas test: 2d.fillStyle.parse.invalid.hex6</p>
<canvas id="c167" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_parse_invalid_hex6() {
var canvas = document.getElementById('c167');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#0f0';
try { ctx.fillStyle = '#fg0000'; } catch (e) { } // this shouldn't throw, but it shouldn't matter here if it does
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.fillStyle.parse.invalid.hsl-1.html ]]] -->
<p>Canvas test: 2d.fillStyle.parse.invalid.hsl-1</p>
<canvas id="c168" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_parse_invalid_hsl_1() {
var canvas = document.getElementById('c168');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#0f0';
try { ctx.fillStyle = 'hsl(0%, 100%, 50%)'; } catch (e) { } // this shouldn't throw, but it shouldn't matter here if it does
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.fillStyle.parse.invalid.hsl-2.html ]]] -->
<p>Canvas test: 2d.fillStyle.parse.invalid.hsl-2</p>
<canvas id="c169" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_parse_invalid_hsl_2() {
var canvas = document.getElementById('c169');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#0f0';
try { ctx.fillStyle = 'hsl(z, 100%, 50%)'; } catch (e) { } // this shouldn't throw, but it shouldn't matter here if it does
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.fillStyle.parse.invalid.hsl-3.html ]]] -->
<p>Canvas test: 2d.fillStyle.parse.invalid.hsl-3</p>
<canvas id="c170" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_parse_invalid_hsl_3() {
var canvas = document.getElementById('c170');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#0f0';
try { ctx.fillStyle = 'hsl(0, 0, 50%)'; } catch (e) { } // this shouldn't throw, but it shouldn't matter here if it does
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.fillStyle.parse.invalid.hsl-4.html ]]] -->
<p>Canvas test: 2d.fillStyle.parse.invalid.hsl-4</p>
<canvas id="c171" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_parse_invalid_hsl_4() {
var canvas = document.getElementById('c171');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#0f0';
try { ctx.fillStyle = 'hsl(0, 100%, 0)'; } catch (e) { } // this shouldn't throw, but it shouldn't matter here if it does
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.fillStyle.parse.invalid.hsl-5.html ]]] -->
<p>Canvas test: 2d.fillStyle.parse.invalid.hsl-5</p>
<canvas id="c172" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_parse_invalid_hsl_5() {
var canvas = document.getElementById('c172');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#0f0';
try { ctx.fillStyle = 'hsl(0, 100%, 100%,)'; } catch (e) { } // this shouldn't throw, but it shouldn't matter here if it does
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.fillStyle.parse.invalid.hsla-1.html ]]] -->
<p>Canvas test: 2d.fillStyle.parse.invalid.hsla-1</p>
<canvas id="c173" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_parse_invalid_hsla_1() {
var canvas = document.getElementById('c173');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#0f0';
try { ctx.fillStyle = 'hsla(0%, 100%, 50%, 1)'; } catch (e) { } // this shouldn't throw, but it shouldn't matter here if it does
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.fillStyle.parse.invalid.hsla-2.html ]]] -->
<p>Canvas test: 2d.fillStyle.parse.invalid.hsla-2</p>
<canvas id="c174" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_parse_invalid_hsla_2() {
var canvas = document.getElementById('c174');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#0f0';
try { ctx.fillStyle = 'hsla(0, 0, 50%, 1)'; } catch (e) { } // this shouldn't throw, but it shouldn't matter here if it does
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.fillStyle.parse.invalid.name-1.html ]]] -->
<p>Canvas test: 2d.fillStyle.parse.invalid.name-1</p>
<canvas id="c174a" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_parse_invalid_name_1() {
var canvas = document.getElementById('c174a');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#0f0';
try { ctx.fillStyle = 'darkbrown'; } catch (e) { } // this shouldn't throw, but it shouldn't matter here if it does
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.fillStyle.parse.invalid.name-2.html ]]] -->
<p>Canvas test: 2d.fillStyle.parse.invalid.name-2</p>
<canvas id="c174b" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_parse_invalid_name_2() {
var canvas = document.getElementById('c174b');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#0f0';
try { ctx.fillStyle = 'firebrick1'; } catch (e) { } // this shouldn't throw, but it shouldn't matter here if it does
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.fillStyle.parse.invalid.name-3.html ]]] -->
<p>Canvas test: 2d.fillStyle.parse.invalid.name-3</p>
<canvas id="c174c" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_parse_invalid_name_3() {
var canvas = document.getElementById('c174c');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#0f0';
try { ctx.fillStyle = 'red blue'; } catch (e) { } // this shouldn't throw, but it shouldn't matter here if it does
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.fillStyle.parse.invalid.rgb-1.html ]]] -->
<p>Canvas test: 2d.fillStyle.parse.invalid.rgb-1</p>
<canvas id="c175" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_parse_invalid_rgb_1() {
var canvas = document.getElementById('c175');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#0f0';
try { ctx.fillStyle = 'rgb(255.0, 0%, 0)'; } catch (e) { } // this shouldn't throw, but it shouldn't matter here if it does
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.fillStyle.parse.invalid.rgb-2.html ]]] -->
<p>Canvas test: 2d.fillStyle.parse.invalid.rgb-2</p>
<canvas id="c176" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_parse_invalid_rgb_2() {
var canvas = document.getElementById('c176');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#0f0';
try { ctx.fillStyle = 'rgb(255%, 0.0, 0)'; } catch (e) { } // this shouldn't throw, but it shouldn't matter here if it does
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.fillStyle.parse.invalid.rgb-3.html ]]] -->
<p>Canvas test: 2d.fillStyle.parse.invalid.rgb-3</p>
<canvas id="c177" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_parse_invalid_rgb_3() {
var canvas = document.getElementById('c177');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#0f0';
try { ctx.fillStyle = 'rgb(255.0, 0, 0,)'; } catch (e) { } // this shouldn't throw, but it shouldn't matter here if it does
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.fillStyle.parse.invalid.rgb-4.html ]]] -->
<p>Canvas test: 2d.fillStyle.parse.invalid.rgb-4</p>
<canvas id="c178" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_parse_invalid_rgb_4() {
var canvas = document.getElementById('c178');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#0f0';
try { ctx.fillStyle = 'rgb(100%, 0, 0)'; } catch (e) { } // this shouldn't throw, but it shouldn't matter here if it does
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.fillStyle.parse.invalid.rgb-5.html ]]] -->
<p>Canvas test: 2d.fillStyle.parse.invalid.rgb-5</p>
<canvas id="c179" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_parse_invalid_rgb_5() {
var canvas = document.getElementById('c179');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#0f0';
try { ctx.fillStyle = 'rgb(255, 0 0)'; } catch (e) { } // this shouldn't throw, but it shouldn't matter here if it does
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.fillStyle.parse.invalid.rgb-6.html ]]] -->
<p>Canvas test: 2d.fillStyle.parse.invalid.rgb-6</p>
<canvas id="c180" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_parse_invalid_rgb_6() {
var canvas = document.getElementById('c180');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#0f0';
try { ctx.fillStyle = 'rgb(255, - 1, 0)'; } catch (e) { } // this shouldn't throw, but it shouldn't matter here if it does
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.fillStyle.parse.invalid.rgb-7.html ]]] -->
<p>Canvas test: 2d.fillStyle.parse.invalid.rgb-7</p>
<canvas id="c181" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_parse_invalid_rgb_7() {
var canvas = document.getElementById('c181');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#0f0';
try { ctx.fillStyle = 'rgb(255, 0, 0, 1,)'; } catch (e) { } // this shouldn't throw, but it shouldn't matter here if it does
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.fillStyle.parse.invalid.rgba-1.html ]]] -->
<p>Canvas test: 2d.fillStyle.parse.invalid.rgba-1</p>
<canvas id="c182" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_parse_invalid_rgba_1() {
var canvas = document.getElementById('c182');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#0f0';
try { ctx.fillStyle = 'rgba(255, 0, 0,)'; } catch (e) { } // this shouldn't throw, but it shouldn't matter here if it does
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.fillStyle.parse.invalid.rgba-2.html ]]] -->
<p>Canvas test: 2d.fillStyle.parse.invalid.rgba-2</p>
<canvas id="c183" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_parse_invalid_rgba_2() {
var canvas = document.getElementById('c183');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#0f0';
try { ctx.fillStyle = 'rgba(255.0, 0, 0, 1,)'; } catch (e) { } // this shouldn't throw, but it shouldn't matter here if it does
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.fillStyle.parse.invalid.rgba-3.html ]]] -->
<p>Canvas test: 2d.fillStyle.parse.invalid.rgba-3</p>
<canvas id="c184" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_parse_invalid_rgba_3() {
var canvas = document.getElementById('c184');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#0f0';
try { ctx.fillStyle = 'rgba(100%, 0, 0, 1)'; } catch (e) { } // this shouldn't throw, but it shouldn't matter here if it does
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.fillStyle.parse.invalid.rgba-4.html ]]] -->
<p>Canvas test: 2d.fillStyle.parse.invalid.rgba-4</p>
<canvas id="c185" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_parse_invalid_rgba_4() {
var canvas = document.getElementById('c185');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#0f0';
try { ctx.fillStyle = 'rgba(255, 0, 0, 100.%)'; } catch (e) { } // this shouldn't throw, but it shouldn't matter here if it does
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.fillStyle.parse.invalid.rgba-5.html ]]] -->
<p>Canvas test: 2d.fillStyle.parse.invalid.rgba-5</p>
<canvas id="c186" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_parse_invalid_rgba_5() {
var canvas = document.getElementById('c186');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#0f0';
try { ctx.fillStyle = 'rgba(255, 0, 0, 1. 0)'; } catch (e) { } // this shouldn't throw, but it shouldn't matter here if it does
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.fillStyle.parse.rgb-clamp-1.html ]]] -->
<p>Canvas test: 2d.fillStyle.parse.rgb-clamp-1</p>
<canvas id="c187" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_parse_rgb_clamp_1() {
var canvas = document.getElementById('c187');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#f00';
ctx.fillStyle = 'rgb(-1000, 1000, -1000)';
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.fillStyle.parse.rgb-clamp-2.html ]]] -->
<p>Canvas test: 2d.fillStyle.parse.rgb-clamp-2</p>
<canvas id="c188" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_parse_rgb_clamp_2() {
var canvas = document.getElementById('c188');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#f00';
ctx.fillStyle = 'rgb(-200%, 200%, -200%)';
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.fillStyle.parse.rgb-clamp-3.html ]]] -->
<p>Canvas test: 2d.fillStyle.parse.rgb-clamp-3</p>
<canvas id="c189" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_parse_rgb_clamp_3() {
var canvas = document.getElementById('c189');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#f00';
ctx.fillStyle = 'rgb(-2147483649, 4294967298, -18446744073709551619)';
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.fillStyle.parse.rgb-clamp-4.html ]]] -->
<p>Canvas test: 2d.fillStyle.parse.rgb-clamp-4</p>
<canvas id="c190" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_parse_rgb_clamp_4() {
var canvas = document.getElementById('c190');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#f00';
ctx.fillStyle = 'rgb(-1000000000000000000000000000000000000000, 1000000000000000000000000000000000000000, -1000000000000000000000000000000000000000)';
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.fillStyle.parse.rgb-clamp-5.html ]]] -->
<p>Canvas test: 2d.fillStyle.parse.rgb-clamp-5</p>
<canvas id="c191" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_parse_rgb_clamp_5() {
var canvas = document.getElementById('c191');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#f00';
ctx.fillStyle = 'rgb(-10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000, 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000, -10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000)';
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.fillStyle.parse.rgb-num.html ]]] -->
<p>Canvas test: 2d.fillStyle.parse.rgb-num</p>
<canvas id="c192" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_parse_rgb_num() {
var canvas = document.getElementById('c192');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#f00';
ctx.fillStyle = 'rgb(0,255,0)';
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.fillStyle.parse.rgb-percent.html ]]] -->
<p>Canvas test: 2d.fillStyle.parse.rgb-percent</p>
<canvas id="c193" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_parse_rgb_percent() {
var canvas = document.getElementById('c193');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#f00';
ctx.fillStyle = 'rgb(0% ,100% ,0%)';
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.fillStyle.parse.rgba-clamp-1.html ]]] -->
<p>Canvas test: 2d.fillStyle.parse.rgba-clamp-1</p>
<canvas id="c194" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_parse_rgba_clamp_1() {
var canvas = document.getElementById('c194');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#f00';
ctx.fillStyle = 'rgba(0, 255, 0, -2)';
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,0,0,0, 0);
}
</script>
<!-- [[[ test_2d.fillStyle.parse.rgba-clamp-2.html ]]] -->
<p>Canvas test: 2d.fillStyle.parse.rgba-clamp-2</p>
<canvas id="c195" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_parse_rgba_clamp_2() {
var canvas = document.getElementById('c195');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#f00';
ctx.fillStyle = 'rgba(0, 255, 0, 2)';
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.fillStyle.parse.rgba-num-1.html ]]] -->
<p>Canvas test: 2d.fillStyle.parse.rgba-num-1</p>
<canvas id="c196" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_parse_rgba_num_1() {
var canvas = document.getElementById('c196');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#f00';
ctx.fillStyle = 'rgba( 0 , 255 , 0 , .499 )';
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,255,0,127, 0);
}
</script>
<!-- [[[ test_2d.fillStyle.parse.rgba-num-2.html ]]] -->
<p>Canvas test: 2d.fillStyle.parse.rgba-num-2</p>
<canvas id="c197" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_parse_rgba_num_2() {
var canvas = document.getElementById('c197');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#f00';
ctx.fillStyle = 'rgba( 0 , 255 , 0 , 0.499 )';
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,255,0,127, 0);
}
</script>
<!-- [[[ test_2d.fillStyle.parse.rgba-percent.html ]]] -->
<p>Canvas test: 2d.fillStyle.parse.rgba-percent</p>
<canvas id="c198" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_parse_rgba_percent() {
var canvas = document.getElementById('c198');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#f00';
ctx.fillStyle = 'rgba(0%,100%,0%,0.499)';
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,255,0,127, 0);
}
</script>
<!-- [[[ test_2d.fillStyle.parse.rgba-solid-1.html ]]] -->
<p>Canvas test: 2d.fillStyle.parse.rgba-solid-1</p>
<canvas id="c199" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_parse_rgba_solid_1() {
var canvas = document.getElementById('c199');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#f00';
ctx.fillStyle = 'rgba( 0 , 255 , 0 , 1 )';
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.fillStyle.parse.rgba-solid-2.html ]]] -->
<p>Canvas test: 2d.fillStyle.parse.rgba-solid-2</p>
<canvas id="c200" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_parse_rgba_solid_2() {
var canvas = document.getElementById('c200');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#f00';
ctx.fillStyle = 'rgba( 0 , 255 , 0 , 1.0 )';
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.fillStyle.parse.svg-1.html ]]] -->
<p>Canvas test: 2d.fillStyle.parse.svg-1</p>
<canvas id="c201" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_parse_svg_1() {
var canvas = document.getElementById('c201');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#f00';
ctx.fillStyle = 'gray';
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 128,128,128,255, 0);
}
</script>
<!-- [[[ test_2d.fillStyle.parse.svg-2.html ]]] -->
<p>Canvas test: 2d.fillStyle.parse.svg-2</p>
<canvas id="c202" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_parse_svg_2() {
var canvas = document.getElementById('c202');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#f00';
ctx.fillStyle = 'grey';
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 128,128,128,255, 0);
}
</script>
<!-- [[[ test_2d.fillStyle.parse.system.html ]]] -->
<p>Canvas test: 2d.fillStyle.parse.system</p>
<canvas id="c203" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_parse_system() {
var canvas = document.getElementById('c203');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#f00';
ctx.fillStyle = 'ThreeDDarkShadow';
ok(/^#(?!(FF0000|ff0000|f00)$)/.test(ctx.fillStyle), "ctx.fillStyle =~ /^#(?!(FF0000|ff0000|f00)$)/"); // test that it's not red
}
</script>
<!-- [[[ test_2d.fillStyle.parse.transparent-1.html ]]] -->
<p>Canvas test: 2d.fillStyle.parse.transparent-1</p>
<canvas id="c204" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_parse_transparent_1() {
var canvas = document.getElementById('c204');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#f00';
ctx.fillStyle = 'transparent';
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,0,0,0, 0);
}
</script>
<!-- [[[ test_2d.fillStyle.parse.transparent-2.html ]]] -->
<p>Canvas test: 2d.fillStyle.parse.transparent-2</p>
<canvas id="c205" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_fillStyle_parse_transparent_2() {
var canvas = document.getElementById('c205');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#f00';
ctx.fillStyle = 'TrAnSpArEnT';
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,0,0,0, 0);
}
</script>
<!-- [[[ test_2d.getcontext.exists.html ]]] -->
<p>Canvas test: 2d.getcontext.exists</p>
<!-- Testing: The 2D context is implemented -->
<canvas id="c206" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_getcontext_exists() {
var canvas = document.getElementById('c206');
var ctx = canvas.getContext('2d');
ok(canvas.getContext('2d') !== null, "canvas.getContext('2d') !== null");
}
</script>
<!-- [[[ test_2d.getcontext.shared.html ]]] -->
<p>Canvas test: 2d.getcontext.shared</p>
<!-- Testing: getContext('2d') returns objects which share canvas state -->
<canvas id="c207" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_getcontext_shared() {
var canvas = document.getElementById('c207');
var ctx = canvas.getContext('2d');
var ctx2 = canvas.getContext('2d');
ctx.fillStyle = '#f00';
ctx2.fillStyle = '#0f0';
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.getcontext.unique.html ]]] -->
<p>Canvas test: 2d.getcontext.unique</p>
<!-- Testing: getContext('2d') returns the same object -->
<canvas id="c208" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_getcontext_unique() {
var canvas = document.getElementById('c208');
var ctx = canvas.getContext('2d');
// eslint-disable-next-line no-self-compare
ok(canvas.getContext('2d') === canvas.getContext('2d'), "canvas.getContext('2d') === canvas.getContext('2d')");
}
</script>
<!-- [[[ test_2d.gradient.empty.html ]]] -->
<p>Canvas test: 2d.gradient.empty</p>
<canvas id="c209" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_gradient_empty() {
var canvas = document.getElementById('c209');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#0f0';
ctx.fillRect(0, 0, 100, 50);
var g = ctx.createLinearGradient(0, 0, 0, 50);
ctx.fillStyle = g;
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,255,0,255, 2);
}
</script>
<!-- [[[ test_2d.gradient.interpolate.alpha.html ]]] -->
<p>Canvas test: 2d.gradient.interpolate.alpha</p>
<canvas id="c210" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_gradient_interpolate_alpha() {
var canvas = document.getElementById('c210');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#ff0';
ctx.fillRect(0, 0, 100, 50);
var g = ctx.createLinearGradient(0, 0, 100, 0);
g.addColorStop(0, 'rgba(0,0,255, 0)');
g.addColorStop(1, 'rgba(0,0,255, 1)');
ctx.fillStyle = g;
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 25,25, 191,191,63,255, 3);
isPixel(ctx, 50,25, 127,127,127,255, 3);
isPixel(ctx, 75,25, 63,63,191,255, 3);
}
</script>
<!-- [[[ test_2d.gradient.interpolate.colour.html ]]] -->
<p>Canvas test: 2d.gradient.interpolate.colour</p>
<canvas id="c211" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_gradient_interpolate_colour() {
var canvas = document.getElementById('c211');
var ctx = canvas.getContext('2d');
var g = ctx.createLinearGradient(0, 0, 100, 0);
g.addColorStop(0, '#ff0');
g.addColorStop(1, '#00f');
ctx.fillStyle = g;
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 25,25, 191,191,63,255, 3);
isPixel(ctx, 50,25, 127,127,127,255, 3);
isPixel(ctx, 75,25, 63,63,191,255, 3);
}
</script>
<!-- [[[ test_2d.gradient.interpolate.colouralpha.html ]]] -->
<p>Canvas test: 2d.gradient.interpolate.colouralpha</p>
<canvas id="c212" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_gradient_interpolate_colouralpha() {
var canvas = document.getElementById('c212');
var ctx = canvas.getContext('2d');
var g = ctx.createLinearGradient(0, 0, 100, 0);
g.addColorStop(0, 'rgba(255,255,0, 0)');
g.addColorStop(1, 'rgba(0,0,255, 1)');
ctx.fillStyle = g;
ctx.fillRect(0, 0, 100, 50);
// Following tests fail on Windows hardware (datacenter and local laptops), see bug 1657707
if (!IsWindows()) isPixel(ctx, 25,25, 191,191,63,63, 3);
if (!IsWindows()) isPixel(ctx, 50,25, 127,127,127,127, 3);
if (!IsWindows()) isPixel(ctx, 75,25, 63,63,191,191, 3);
}
</script>
<!-- [[[ test_2d.gradient.interpolate.multiple.html ]]] -->
<p>Canvas test: 2d.gradient.interpolate.multiple</p>
<canvas id="c213" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_gradient_interpolate_multiple() {
var canvas = document.getElementById('c213');
var ctx = canvas.getContext('2d');
canvas.width = 200;
var g = ctx.createLinearGradient(0, 0, 200, 0);
g.addColorStop(0, '#ff0');
g.addColorStop(0.5, '#0ff');
g.addColorStop(1, '#f0f');
ctx.fillStyle = g;
ctx.fillRect(0, 0, 200, 50);
isPixel(ctx, 50,25, 127,255,127,255, 3);
isPixel(ctx, 100,25, 0,255,255,255, 3);
isPixel(ctx, 150,25, 127,127,255,255, 3);
}
</script>
<!-- [[[ test_2d.gradient.interpolate.outside.html ]]] -->
<p>Canvas test: 2d.gradient.interpolate.outside</p>
<canvas id="c214" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_gradient_interpolate_outside() {
var canvas = document.getElementById('c214');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#f00';
ctx.fillRect(0, 0, 100, 50);
var g = ctx.createLinearGradient(25, 0, 75, 0);
g.addColorStop(0.4, '#0f0');
g.addColorStop(0.6, '#0f0');
ctx.fillStyle = g;
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 20,25, 0,255,0,255, 2);
isPixel(ctx, 50,25, 0,255,0,255, 2);
isPixel(ctx, 80,25, 0,255,0,255, 2);
}
</script>
<!-- [[[ test_2d.gradient.interpolate.overlap.html ]]] -->
<p>Canvas test: 2d.gradient.interpolate.overlap</p>
<canvas id="c215" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_gradient_interpolate_overlap() {
var canvas = document.getElementById('c215');
var ctx = canvas.getContext('2d');
if (!IsD2DEnabled()) {
// On D2D the different nature of how gradients
// are drawn makes it so we cannot guarantee these stops are completely
// hard.
// On OS X 10.5 quartz is confused by the overlapping stops: Bug #715235
canvas.width = 200;
var g = ctx.createLinearGradient(0, 0, 200, 0);
g.addColorStop(0, '#f00');
g.addColorStop(0, '#ff0');
g.addColorStop(0.25, '#00f');
g.addColorStop(0.25, '#0f0');
g.addColorStop(0.25, '#0f0');
g.addColorStop(0.25, '#0f0');
g.addColorStop(0.25, '#ff0');
g.addColorStop(0.5, '#00f');
g.addColorStop(0.5, '#0f0');
g.addColorStop(0.75, '#00f');
g.addColorStop(0.75, '#f00');
g.addColorStop(0.75, '#ff0');
g.addColorStop(0.5, '#0f0');
g.addColorStop(0.5, '#0f0');
g.addColorStop(0.5, '#ff0');
g.addColorStop(1, '#00f');
ctx.fillStyle = g;
ctx.fillRect(0, 0, 200, 50);
isPixel(ctx, 49,25, 0,0,255,255, 16);
isPixel(ctx, 51,25, 255,255,0,255, 16);
isPixel(ctx, 99,25, 0,0,255,255, 16);
isPixel(ctx, 101,25, 255,255,0,255, 16);
isPixel(ctx, 149,25, 0,0,255,255, 16);
isPixel(ctx, 151,25, 255,255,0,255, 16);
}
}
</script>
<!-- [[[ test_2d.gradient.interpolate.overlap2.html ]]] -->
<p>Canvas test: 2d.gradient.interpolate.overlap2</p>
<canvas id="c216" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_gradient_interpolate_overlap2() {
var canvas = document.getElementById('c216');
var ctx = canvas.getContext('2d');
var g = ctx.createLinearGradient(0, 0, 100, 0);
var ps = [ 0, 1/10, 1/4, 1/3, 1/2, 3/4, 1 ];
for (var p = 0; p < ps.length; ++p)
{
g.addColorStop(ps[p], '#0f0');
for (var i = 0; i < 15; ++i)
g.addColorStop(ps[p], '#f00');
g.addColorStop(ps[p], '#0f0');
}
ctx.fillStyle = g;
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 1,25, 0,255,0,255, 0);
isPixel(ctx, 30,25, 0,255,0,255, 0);
isPixel(ctx, 40,25, 0,255,0,255, 0);
isPixel(ctx, 60,25, 0,255,0,255, 0);
isPixel(ctx, 80,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.gradient.interpolate.solid.html ]]] -->
<p>Canvas test: 2d.gradient.interpolate.solid</p>
<canvas id="c217" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_gradient_interpolate_solid() {
var canvas = document.getElementById('c217');
var ctx = canvas.getContext('2d');
var g = ctx.createLinearGradient(0, 0, 100, 0);
g.addColorStop(0, '#0f0');
g.addColorStop(1, '#0f0');
ctx.fillStyle = g;
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.gradient.interpolate.vertical.html ]]] -->
<p>Canvas test: 2d.gradient.interpolate.vertical</p>
<canvas id="c218" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_gradient_interpolate_vertical() {
var canvas = document.getElementById('c218');
var ctx = canvas.getContext('2d');
var g = ctx.createLinearGradient(0, 0, 0, 50);
g.addColorStop(0, '#ff0');
g.addColorStop(1, '#00f');
ctx.fillStyle = g;
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,12, 191,191,63,255, 10);
isPixel(ctx, 50,25, 127,127,127,255, 5);
isPixel(ctx, 50,37, 63,63,191,255, 10);
}
</script>
<!-- [[[ test_2d.gradient.interpolate.zerosize.html ]]] -->
<p>Canvas test: 2d.gradient.interpolate.zerosize</p>
<canvas id="c219" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_gradient_interpolate_zerosize() {
var canvas = document.getElementById('c219');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#0f0';
ctx.fillRect(0, 0, 100, 50);
var g = ctx.createLinearGradient(50, 25, 50, 25); // zero-length line (undefined direction)
g.addColorStop(0, '#f00');
g.addColorStop(1, '#f00');
ctx.fillStyle = g;
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 40,20, 0,255,0,255, 2);
}
</script>
<!-- [[[ test_2d.gradient.linear.nonfinite.html ]]] -->
<p>Canvas test: 2d.gradient.linear.nonfinite</p>
<!-- Testing: createLinearGradient() throws NOT_SUPPORTED_ERR if arguments are not finite -->
<canvas id="c220" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
// eslint-disable-next-line complexity
function test_2d_gradient_linear_nonfinite() {
var canvas = document.getElementById('c220');
var ctx = canvas.getContext('2d');
var _thrown = undefined; try {
ctx.createLinearGradient(Infinity, 0, 1, 0);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createLinearGradient(-Infinity, 0, 1, 0);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createLinearGradient(NaN, 0, 1, 0);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createLinearGradient(0, Infinity, 1, 0);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createLinearGradient(0, -Infinity, 1, 0);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createLinearGradient(0, NaN, 1, 0);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createLinearGradient(0, 0, Infinity, 0);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createLinearGradient(0, 0, -Infinity, 0);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createLinearGradient(0, 0, NaN, 0);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createLinearGradient(0, 0, 1, Infinity);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createLinearGradient(0, 0, 1, -Infinity);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createLinearGradient(0, 0, 1, NaN);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createLinearGradient(Infinity, Infinity, 1, 0);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createLinearGradient(Infinity, Infinity, Infinity, 0);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createLinearGradient(Infinity, Infinity, Infinity, Infinity);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createLinearGradient(Infinity, Infinity, 1, Infinity);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createLinearGradient(Infinity, 0, Infinity, 0);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createLinearGradient(Infinity, 0, Infinity, Infinity);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createLinearGradient(Infinity, 0, 1, Infinity);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createLinearGradient(0, Infinity, Infinity, 0);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createLinearGradient(0, Infinity, Infinity, Infinity);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createLinearGradient(0, Infinity, 1, Infinity);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createLinearGradient(0, 0, Infinity, Infinity);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
}
</script>
<!-- [[[ test_2d.gradient.linear.transform.1.html ]]] -->
<p>Canvas test: 2d.gradient.linear.transform.1</p>
<!-- Testing: Linear gradient coordinates are relative to the coordinate space at the time of filling -->
<canvas id="c221" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_gradient_linear_transform_1() {
var canvas = document.getElementById('c221');
var ctx = canvas.getContext('2d');
var g = ctx.createLinearGradient(0, 0, 200, 0);
g.addColorStop(0, '#f00');
g.addColorStop(0.25, '#0f0');
g.addColorStop(0.75, '#0f0');
g.addColorStop(1, '#f00');
ctx.fillStyle = g;
ctx.translate(-50, 0);
ctx.fillRect(50, 0, 100, 50);
isPixel(ctx, 25,25, 0,255,0,255, 0);
isPixel(ctx, 50,25, 0,255,0,255, 0);
isPixel(ctx, 75,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.gradient.linear.transform.2.html ]]] -->
<p>Canvas test: 2d.gradient.linear.transform.2</p>
<!-- Testing: Linear gradient coordinates are relative to the coordinate space at the time of filling -->
<canvas id="c222" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_gradient_linear_transform_2() {
var canvas = document.getElementById('c222');
var ctx = canvas.getContext('2d');
ctx.translate(100, 0);
var g = ctx.createLinearGradient(0, 0, 200, 0);
g.addColorStop(0, '#f00');
g.addColorStop(0.25, '#0f0');
g.addColorStop(0.75, '#0f0');
g.addColorStop(1, '#f00');
ctx.fillStyle = g;
ctx.translate(-150, 0);
ctx.fillRect(50, 0, 100, 50);
isPixel(ctx, 25,25, 0,255,0,255, 0);
isPixel(ctx, 50,25, 0,255,0,255, 0);
isPixel(ctx, 75,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.gradient.linear.transform.3.html ]]] -->
<p>Canvas test: 2d.gradient.linear.transform.3</p>
<!-- Testing: Linear gradient transforms do not experience broken caching effects -->
<canvas id="c223" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_gradient_linear_transform_3() {
var canvas = document.getElementById('c223');
var ctx = canvas.getContext('2d');
var g = ctx.createLinearGradient(0, 0, 200, 0);
g.addColorStop(0, '#f00');
g.addColorStop(0.25, '#0f0');
g.addColorStop(0.75, '#0f0');
g.addColorStop(1, '#f00');
ctx.fillStyle = g;
ctx.fillRect(0, 0, 100, 50);
ctx.translate(-50, 0);
ctx.fillRect(50, 0, 100, 50);
isPixel(ctx, 25,25, 0,255,0,255, 0);
isPixel(ctx, 50,25, 0,255,0,255, 0);
isPixel(ctx, 75,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.gradient.object.compare.html ]]] -->
<p>Canvas test: 2d.gradient.object.compare</p>
<canvas id="c224" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_gradient_object_compare() {
var canvas = document.getElementById('c224');
var ctx = canvas.getContext('2d');
var g1 = ctx.createLinearGradient(0, 0, 100, 0);
var g2 = ctx.createLinearGradient(0, 0, 100, 0);
ok(g1 !== g2, "g1 !== g2");
ctx.fillStyle = g1;
ok(ctx.fillStyle === g1, "ctx.fillStyle === g1");
}
</script>
<!-- [[[ test_2d.gradient.object.crosscanvas.html ]]] -->
<p>Canvas test: 2d.gradient.object.crosscanvas</p>
<canvas id="c225" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_gradient_object_crosscanvas() {
var canvas = document.getElementById('c225');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#f00';
ctx.fillRect(0, 0, 100, 50);
var g = document.createElement('canvas').getContext('2d').createLinearGradient(0, 0, 100, 0);
g.addColorStop(0, '#0f0');
g.addColorStop(1, '#0f0');
ctx.fillStyle = g;
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,255,0,255, 2);
}
</script>
<!-- [[[ test_2d.gradient.object.invalidcolour.html ]]] -->
<p>Canvas test: 2d.gradient.object.invalidcolour</p>
<canvas id="c226" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_gradient_object_invalidcolour() {
var canvas = document.getElementById('c226');
var ctx = canvas.getContext('2d');
var g = ctx.createLinearGradient(0, 0, 100, 0);
var _thrown = undefined; try {
g.addColorStop(0, "");
} catch (e) { _thrown = e }; ok(_thrown && _thrown.name == "SyntaxError" && _thrown.code == DOMException.SYNTAX_ERR, "should throw SyntaxError");
var _thrown = undefined; try {
g.addColorStop(0, 'undefined');
} catch (e) { _thrown = e }; ok(_thrown && _thrown.name == "SyntaxError" && _thrown.code == DOMException.SYNTAX_ERR, "should throw SyntaxError");
}
</script>
<!-- [[[ test_2d.gradient.object.invalidoffset.html ]]] -->
<p>Canvas test: 2d.gradient.object.invalidoffset</p>
<canvas id="c227" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_gradient_object_invalidoffset() {
var canvas = document.getElementById('c227');
var ctx = canvas.getContext('2d');
var g = ctx.createLinearGradient(0, 0, 100, 0);
var _thrown = undefined; try {
g.addColorStop(-1, '#000');
} catch (e) { _thrown = e }; ok(_thrown && _thrown.name == "IndexSizeError" && _thrown.code == DOMException.INDEX_SIZE_ERR, "should throw IndexSizeError");
var _thrown = undefined; try {
g.addColorStop(2, '#000');
} catch (e) { _thrown = e }; ok(_thrown && _thrown.name == "IndexSizeError" && _thrown.code == DOMException.INDEX_SIZE_ERR, "should throw IndexSizeError");
var _thrown = undefined; try {
g.addColorStop(Infinity, '#000');
} catch (e) { _thrown = e }; ok(_thrown && _thrown.name == "TypeError", "should throw TypeError");
var _thrown = undefined; try {
g.addColorStop(-Infinity, '#000');
} catch (e) { _thrown = e }; ok(_thrown && _thrown.name == "TypeError", "should throw TypeError");
var _thrown = undefined; try {
g.addColorStop(NaN, '#000');
} catch (e) { _thrown = e }; ok(_thrown && _thrown.name == "TypeError", "should throw TypeError");
}
</script>
<!-- [[[ test_2d.gradient.object.return.html ]]] -->
<p>Canvas test: 2d.gradient.object.return</p>
<!-- Testing: createLinearGradient() and createRadialGradient() returns objects implementing CanvasGradient -->
<canvas id="c228" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_gradient_object_return() {
var canvas = document.getElementById('c228');
var ctx = canvas.getContext('2d');
window.CanvasGradient.prototype.thisImplementsCanvasGradient = true;
var g1 = ctx.createLinearGradient(0, 0, 100, 0);
ok(g1.addColorStop !== undefined, "g1.addColorStop !== undefined");
ok(g1.thisImplementsCanvasGradient === true, "g1.thisImplementsCanvasGradient === true");
var g2 = ctx.createRadialGradient(0, 0, 10, 0, 0, 20);
ok(g2.addColorStop !== undefined, "g2.addColorStop !== undefined");
ok(g2.thisImplementsCanvasGradient === true, "g2.thisImplementsCanvasGradient === true");
}
</script>
<!-- [[[ test_2d.gradient.object.type.html ]]] -->
<p>Canvas test: 2d.gradient.object.type</p>
<!-- Testing: window.CanvasGradient exists and has the right properties -->
<canvas id="c229" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_gradient_object_type() {
var canvas = document.getElementById('c229');
var ctx = canvas.getContext('2d');
ok(window.CanvasGradient !== undefined, "window.CanvasGradient !== undefined");
ok(window.CanvasGradient.prototype.addColorStop !== undefined, "window.CanvasGradient.prototype.addColorStop !== undefined");
}
</script>
<!-- [[[ test_2d.gradient.object.update.html ]]] -->
<p>Canvas test: 2d.gradient.object.update</p>
<canvas id="c230" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_gradient_object_update() {
var canvas = document.getElementById('c230');
var ctx = canvas.getContext('2d');
var g = ctx.createLinearGradient(-100, 0, 200, 0);
g.addColorStop(0, '#f00');
g.addColorStop(1, '#f00');
ctx.fillStyle = g;
g.addColorStop(0.1, '#0f0');
g.addColorStop(0.9, '#0f0');
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 50,25, 0,255,0,255, 2);
}
</script>
<!-- [[[ test_2d.gradient.radial.cone.behind.html ]]] -->
<p>Canvas test: 2d.gradient.radial.cone.behind</p>
<canvas id="c231" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_gradient_radial_cone_behind() {
var canvas = document.getElementById('c231');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#0f0';
ctx.fillRect(0, 0, 100, 50);
var g = ctx.createRadialGradient(120, 25, 10, 211, 25, 100);
g.addColorStop(0, '#f00');
g.addColorStop(1, '#f00');
ctx.fillStyle = g;
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 1,1, 0,255,0,255, 0);
isPixel(ctx, 50,1, 0,255,0,255, 0);
isPixel(ctx, 98,1, 0,255,0,255, 0);
isPixel(ctx, 1,25, 0,255,0,255, 0);
isPixel(ctx, 50,25, 0,255,0,255, 0);
isPixel(ctx, 98,25, 0,255,0,255, 0);
isPixel(ctx, 1,48, 0,255,0,255, 0);
isPixel(ctx, 50,48, 0,255,0,255, 0);
isPixel(ctx, 98,48, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.gradient.radial.cone.beside.html ]]] -->
<p>Canvas test: 2d.gradient.radial.cone.beside</p>
<canvas id="c232" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_gradient_radial_cone_beside() {
var canvas = document.getElementById('c232');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#0f0';
ctx.fillRect(0, 0, 100, 50);
var g = ctx.createRadialGradient(0, 100, 40, 100, 100, 50);
g.addColorStop(0, '#f00');
g.addColorStop(1, '#f00');
ctx.fillStyle = g;
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 1,1, 0,255,0,255, 0);
isPixel(ctx, 50,1, 0,255,0,255, 0);
isPixel(ctx, 98,1, 0,255,0,255, 0);
isPixel(ctx, 1,25, 0,255,0,255, 0);
isPixel(ctx, 50,25, 0,255,0,255, 0);
isPixel(ctx, 98,25, 0,255,0,255, 0);
isPixel(ctx, 1,48, 0,255,0,255, 0);
isPixel(ctx, 50,48, 0,255,0,255, 0);
isPixel(ctx, 98,48, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.gradient.radial.cone.bottom.html ]]] -->
<p>Canvas test: 2d.gradient.radial.cone.bottom</p>
<canvas id="c233" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_gradient_radial_cone_bottom() {
var canvas = document.getElementById('c233');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#f00';
ctx.fillRect(0, 0, 100, 50);
var g = ctx.createRadialGradient(210, 25, 100, 230, 25, 101);
g.addColorStop(0, '#0f0');
g.addColorStop(1, '#f00');
ctx.fillStyle = g;
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 1,1, 0,255,0,255, 0);
isPixel(ctx, 50,1, 0,255,0,255, 0);
isPixel(ctx, 98,1, 0,255,0,255, 0);
isPixel(ctx, 1,25, 0,255,0,255, 0);
isPixel(ctx, 50,25, 0,255,0,255, 0);
isPixel(ctx, 98,25, 0,255,0,255, 0);
isPixel(ctx, 1,48, 0,255,0,255, 0);
isPixel(ctx, 50,48, 0,255,0,255, 0);
isPixel(ctx, 98,48, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.gradient.radial.cone.cylinder.html ]]] -->
<p>Canvas test: 2d.gradient.radial.cone.cylinder</p>
<canvas id="c234" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_gradient_radial_cone_cylinder() {
var canvas = document.getElementById('c234');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#f00';
ctx.fillRect(0, 0, 100, 50);
var g = ctx.createRadialGradient(210, 25, 100, 230, 25, 100);
g.addColorStop(0, '#0f0');
g.addColorStop(1, '#f00');
ctx.fillStyle = g;
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 1, 1, 0, 255, 0, 255, 0);
isPixel(ctx, 50, 1, 0, 255, 0, 255, 0);
isPixel(ctx, 98, 1, 0, 255, 0, 255, 0);
isPixel(ctx, 1, 25, 0, 255, 0, 255, 0);
isPixel(ctx, 50, 25, 0, 255, 0, 255, 0);
isPixel(ctx, 98, 25, 0, 255, 0, 255, 0);
isPixel(ctx, 1, 48, 0, 255, 0, 255, 0);
isPixel(ctx, 50, 48, 0, 255, 0, 255, 0);
isPixel(ctx, 98, 48, 0, 255, 0, 255, 0);
}
</script>
<!-- [[[ test_2d.gradient.radial.cone.front.html ]]] -->
<p>Canvas test: 2d.gradient.radial.cone.front</p>
<canvas id="c235" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_gradient_radial_cone_front() {
var canvas = document.getElementById('c235');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#f00';
ctx.fillRect(0, 0, 100, 50);
var g = ctx.createRadialGradient(311, 25, 10, 210, 25, 100);
g.addColorStop(0, '#f00');
g.addColorStop(1, '#0f0');
ctx.fillStyle = g;
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 1,1, 0,255,0,255, 0);
isPixel(ctx, 50,1, 0,255,0,255, 0);
isPixel(ctx, 98,1, 0,255,0,255, 0);
isPixel(ctx, 1,25, 0,255,0,255, 0);
isPixel(ctx, 50,25, 0,255,0,255, 0);
isPixel(ctx, 98,25, 0,255,0,255, 0);
isPixel(ctx, 1,48, 0,255,0,255, 0);
isPixel(ctx, 50,48, 0,255,0,255, 0);
isPixel(ctx, 98,48, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.gradient.radial.cone.shape1.html ]]] -->
<p>Canvas test: 2d.gradient.radial.cone.shape1</p>
<canvas id="c236" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_gradient_radial_cone_shape1() {
var canvas = document.getElementById('c236');
var ctx = canvas.getContext('2d');
var tol = 1; // tolerance to avoid antialiasing artifacts
ctx.fillStyle = '#0f0';
ctx.fillRect(0, 0, 100, 50);
ctx.fillStyle = '#f00';
ctx.beginPath();
ctx.moveTo(30+tol, 40);
ctx.lineTo(110, -20+tol);
ctx.lineTo(110, 100-tol);
ctx.fill();
var g = ctx.createRadialGradient(30+10*5/2, 40, 10*3/2, 30+10*15/4, 40, 10*9/4);
g.addColorStop(0, '#0f0');
g.addColorStop(1, '#0f0');
ctx.fillStyle = g;
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 1,1, 0,255,0,255, 0);
isPixel(ctx, 50,1, 0,255,0,255, 0);
isPixel(ctx, 98,1, 0,255,0,255, 0);
isPixel(ctx, 1,25, 0,255,0,255, 0);
isPixel(ctx, 50,25, 0,255,0,255, 0);
isPixel(ctx, 98,25, 0,255,0,255, 0);
isPixel(ctx, 1,48, 0,255,0,255, 0);
isPixel(ctx, 50,48, 0,255,0,255, 0);
isPixel(ctx, 98,48, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.gradient.radial.cone.shape2.html ]]] -->
<p>Canvas test: 2d.gradient.radial.cone.shape2</p>
<canvas id="c237" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_gradient_radial_cone_shape2() {
var canvas = document.getElementById('c237');
var ctx = canvas.getContext('2d');
var tol = 1; // tolerance to avoid antialiasing artifacts
ctx.fillStyle = '#0f0';
ctx.fillRect(0, 0, 100, 50);
var g = ctx.createRadialGradient(30+10*5/2, 40, 10*3/2, 30+10*15/4, 40, 10*9/4);
g.addColorStop(0, '#f00');
g.addColorStop(1, '#f00');
ctx.fillStyle = g;
ctx.fillRect(0, 0, 100, 50);
ctx.fillStyle = '#0f0';
ctx.beginPath();
ctx.moveTo(30-tol, 40);
ctx.lineTo(110, -20-tol);
ctx.lineTo(110, 100+tol);
ctx.fill();
isPixel(ctx, 1,1, 0,255,0,255, 0);
isPixel(ctx, 50,1, 0,255,0,255, 0);
isPixel(ctx, 98,1, 0,255,0,255, 0);
isPixel(ctx, 1,25, 0,255,0,255, 0);
isPixel(ctx, 50,25, 0,255,0,255, 0);
isPixel(ctx, 98,25, 0,255,0,255, 0);
isPixel(ctx, 1,48, 0,255,0,255, 0);
isPixel(ctx, 50,48, 0,255,0,255, 0);
isPixel(ctx, 98,48, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.gradient.radial.cone.top.html ]]] -->
<p>Canvas test: 2d.gradient.radial.cone.top</p>
<canvas id="c238" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_gradient_radial_cone_top() {
var canvas = document.getElementById('c238');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#f00';
ctx.fillRect(0, 0, 100, 50);
var g = ctx.createRadialGradient(230, 25, 100, 100, 25, 101);
g.addColorStop(0, '#f00');
g.addColorStop(1, '#0f0');
ctx.fillStyle = g;
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 1, 1, 0, 255, 0, 255, 0);
isPixel(ctx, 50, 1, 0, 255, 0, 255, 0);
isPixel(ctx, 98, 1, 0, 255, 0, 255, 0);
isPixel(ctx, 1, 25, 0, 255, 0, 255, 0);
isPixel(ctx, 50, 25, 0, 255, 0, 255, 0);
isPixel(ctx, 98, 25, 0, 255, 0, 255, 0);
isPixel(ctx, 1, 48, 0, 255, 0, 255, 0);
isPixel(ctx, 50, 48, 0, 255, 0, 255, 0);
isPixel(ctx, 98, 48, 0, 255, 0, 255, 0);
}
</script>
<!-- [[[ test_2d.gradient.radial.equal.html ]]] -->
<p>Canvas test: 2d.gradient.radial.equal</p>
<canvas id="c239" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_gradient_radial_equal() {
var canvas = document.getElementById('c239');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#0f0';
ctx.fillRect(0, 0, 100, 50);
var g = ctx.createRadialGradient(50, 25, 20, 50, 25, 20);
g.addColorStop(0, '#f00');
g.addColorStop(1, '#f00');
ctx.fillStyle = g;
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 1,1, 0,255,0,255, 0);
isPixel(ctx, 50,1, 0,255,0,255, 0);
isPixel(ctx, 98,1, 0,255,0,255, 0);
isPixel(ctx, 1,25, 0,255,0,255, 0);
isPixel(ctx, 50,25, 0,255,0,255, 0);
isPixel(ctx, 98,25, 0,255,0,255, 0);
isPixel(ctx, 1,48, 0,255,0,255, 0);
isPixel(ctx, 50,48, 0,255,0,255, 0);
isPixel(ctx, 98,48, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.gradient.radial.inside1.html ]]] -->
<p>Canvas test: 2d.gradient.radial.inside1</p>
<canvas id="c240" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_gradient_radial_inside1() {
var canvas = document.getElementById('c240');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#f00';
ctx.fillRect(0, 0, 100, 50);
var g = ctx.createRadialGradient(50, 25, 100, 50, 25, 200);
g.addColorStop(0, '#0f0');
g.addColorStop(1, '#f00');
ctx.fillStyle = g;
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 1,1, 0,255,0,255, 0);
isPixel(ctx, 50,1, 0,255,0,255, 0);
isPixel(ctx, 98,1, 0,255,0,255, 0);
isPixel(ctx, 1,25, 0,255,0,255, 0);
isPixel(ctx, 50,25, 0,255,0,255, 0);
isPixel(ctx, 98,25, 0,255,0,255, 0);
isPixel(ctx, 1,48, 0,255,0,255, 0);
isPixel(ctx, 50,48, 0,255,0,255, 0);
isPixel(ctx, 98,48, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.gradient.radial.inside2.html ]]] -->
<p>Canvas test: 2d.gradient.radial.inside2</p>
<canvas id="c241" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_gradient_radial_inside2() {
var canvas = document.getElementById('c241');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#f00';
ctx.fillRect(0, 0, 100, 50);
var g = ctx.createRadialGradient(50, 25, 200, 50, 25, 100);
g.addColorStop(0, '#f00');
g.addColorStop(1, '#0f0');
ctx.fillStyle = g;
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 1,1, 0,255,0,255, 0);
isPixel(ctx, 50,1, 0,255,0,255, 0);
isPixel(ctx, 98,1, 0,255,0,255, 0);
isPixel(ctx, 1,25, 0,255,0,255, 0);
isPixel(ctx, 50,25, 0,255,0,255, 0);
isPixel(ctx, 98,25, 0,255,0,255, 0);
isPixel(ctx, 1,48, 0,255,0,255, 0);
isPixel(ctx, 50,48, 0,255,0,255, 0);
isPixel(ctx, 98,48, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.gradient.radial.inside3.html ]]] -->
<p>Canvas test: 2d.gradient.radial.inside3</p>
<canvas id="c242" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_gradient_radial_inside3() {
var canvas = document.getElementById('c242');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#f00';
ctx.fillRect(0, 0, 100, 50);
var g = ctx.createRadialGradient(50, 25, 200, 50, 25, 100);
g.addColorStop(0, '#f00');
g.addColorStop(0.993, '#f00');
g.addColorStop(1, '#0f0');
ctx.fillStyle = g;
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 1,1, 0,255,0,255, 0);
isPixel(ctx, 50,1, 0,255,0,255, 0);
isPixel(ctx, 98,1, 0,255,0,255, 0);
isPixel(ctx, 1,25, 0,255,0,255, 0);
isPixel(ctx, 50,25, 0,255,0,255, 0);
isPixel(ctx, 98,25, 0,255,0,255, 0);
isPixel(ctx, 1,48, 0,255,0,255, 0);
isPixel(ctx, 50,48, 0,255,0,255, 0);
isPixel(ctx, 98,48, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.gradient.radial.negative.html ]]] -->
<p>Canvas test: 2d.gradient.radial.negative</p>
<!-- Testing: createRadialGradient() throws INDEX_SIZE_ERR if either radius is negative -->
<canvas id="c243" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_gradient_radial_negative() {
var canvas = document.getElementById('c243');
var ctx = canvas.getContext('2d');
var _thrown = undefined; try {
ctx.createRadialGradient(0, 0, -0.1, 0, 0, 1);
} catch (e) { _thrown = e }; ok(_thrown && _thrown.name == "IndexSizeError" && _thrown.code == DOMException.INDEX_SIZE_ERR, "should throw IndexSizeError");
var _thrown = undefined; try {
ctx.createRadialGradient(0, 0, 1, 0, 0, -0.1);
} catch (e) { _thrown = e }; ok(_thrown && _thrown.name == "IndexSizeError" && _thrown.code == DOMException.INDEX_SIZE_ERR, "should throw IndexSizeError");
var _thrown = undefined; try {
ctx.createRadialGradient(0, 0, -0.1, 0, 0, -0.1);
} catch (e) { _thrown = e }; ok(_thrown && _thrown.name == "IndexSizeError" && _thrown.code == DOMException.INDEX_SIZE_ERR, "should throw IndexSizeError");
}
</script>
<!-- [[[ test_2d.gradient.radial.nonfinite.html ]]] -->
<p>Canvas test: 2d.gradient.radial.nonfinite</p>
<!-- Testing: createRadialGradient() throws NOT_SUPPORTED_ERR if arguments are not finite -->
<canvas id="c244" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
// eslint-disable-next-line complexity
function test_2d_gradient_radial_nonfinite() {
var canvas = document.getElementById('c244');
var ctx = canvas.getContext('2d');
var _thrown = undefined; try {
ctx.createRadialGradient(Infinity, 0, 1, 0, 0, 1);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(-Infinity, 0, 1, 0, 0, 1);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(NaN, 0, 1, 0, 0, 1);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(0, Infinity, 1, 0, 0, 1);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(0, -Infinity, 1, 0, 0, 1);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(0, NaN, 1, 0, 0, 1);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(0, 0, Infinity, 0, 0, 1);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(0, 0, -Infinity, 0, 0, 1);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(0, 0, NaN, 0, 0, 1);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(0, 0, 1, Infinity, 0, 1);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(0, 0, 1, -Infinity, 0, 1);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(0, 0, 1, NaN, 0, 1);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(0, 0, 1, 0, Infinity, 1);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(0, 0, 1, 0, -Infinity, 1);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(0, 0, 1, 0, NaN, 1);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(0, 0, 1, 0, 0, Infinity);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(0, 0, 1, 0, 0, -Infinity);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(0, 0, 1, 0, 0, NaN);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(Infinity, Infinity, 1, 0, 0, 1);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(Infinity, Infinity, Infinity, 0, 0, 1);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(Infinity, Infinity, Infinity, Infinity, 0, 1);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(Infinity, Infinity, Infinity, Infinity, Infinity, 1);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(Infinity, Infinity, Infinity, Infinity, Infinity, Infinity);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(Infinity, Infinity, Infinity, Infinity, 0, Infinity);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(Infinity, Infinity, Infinity, 0, Infinity, 1);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(Infinity, Infinity, Infinity, 0, Infinity, Infinity);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(Infinity, Infinity, Infinity, 0, 0, Infinity);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(Infinity, Infinity, 1, Infinity, 0, 1);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(Infinity, Infinity, 1, Infinity, Infinity, 1);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(Infinity, Infinity, 1, Infinity, Infinity, Infinity);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(Infinity, Infinity, 1, Infinity, 0, Infinity);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(Infinity, Infinity, 1, 0, Infinity, 1);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(Infinity, Infinity, 1, 0, Infinity, Infinity);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(Infinity, Infinity, 1, 0, 0, Infinity);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(Infinity, 0, Infinity, 0, 0, 1);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(Infinity, 0, Infinity, Infinity, 0, 1);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(Infinity, 0, Infinity, Infinity, Infinity, 1);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(Infinity, 0, Infinity, Infinity, Infinity, Infinity);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(Infinity, 0, Infinity, Infinity, 0, Infinity);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(Infinity, 0, Infinity, 0, Infinity, 1);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(Infinity, 0, Infinity, 0, Infinity, Infinity);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(Infinity, 0, Infinity, 0, 0, Infinity);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(Infinity, 0, 1, Infinity, 0, 1);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(Infinity, 0, 1, Infinity, Infinity, 1);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(Infinity, 0, 1, Infinity, Infinity, Infinity);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(Infinity, 0, 1, Infinity, 0, Infinity);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(Infinity, 0, 1, 0, Infinity, 1);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(Infinity, 0, 1, 0, Infinity, Infinity);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(Infinity, 0, 1, 0, 0, Infinity);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(0, Infinity, Infinity, 0, 0, 1);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(0, Infinity, Infinity, Infinity, 0, 1);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(0, Infinity, Infinity, Infinity, Infinity, 1);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(0, Infinity, Infinity, Infinity, Infinity, Infinity);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(0, Infinity, Infinity, Infinity, 0, Infinity);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(0, Infinity, Infinity, 0, Infinity, 1);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(0, Infinity, Infinity, 0, Infinity, Infinity);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(0, Infinity, Infinity, 0, 0, Infinity);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(0, Infinity, 1, Infinity, 0, 1);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(0, Infinity, 1, Infinity, Infinity, 1);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(0, Infinity, 1, Infinity, Infinity, Infinity);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(0, Infinity, 1, Infinity, 0, Infinity);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(0, Infinity, 1, 0, Infinity, 1);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(0, Infinity, 1, 0, Infinity, Infinity);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(0, Infinity, 1, 0, 0, Infinity);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(0, 0, Infinity, Infinity, 0, 1);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(0, 0, Infinity, Infinity, Infinity, 1);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(0, 0, Infinity, Infinity, Infinity, Infinity);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(0, 0, Infinity, Infinity, 0, Infinity);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(0, 0, Infinity, 0, Infinity, 1);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(0, 0, Infinity, 0, Infinity, Infinity);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(0, 0, Infinity, 0, 0, Infinity);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(0, 0, 1, Infinity, Infinity, 1);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(0, 0, 1, Infinity, Infinity, Infinity);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(0, 0, 1, Infinity, 0, Infinity);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createRadialGradient(0, 0, 1, 0, Infinity, Infinity);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
}
</script>
<!-- [[[ test_2d.gradient.radial.outside1.html ]]] -->
<p>Canvas test: 2d.gradient.radial.outside1</p>
<canvas id="c245" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_gradient_radial_outside1() {
var canvas = document.getElementById('c245');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#f00';
ctx.fillRect(0, 0, 100, 50);
var g = ctx.createRadialGradient(200, 25, 10, 200, 25, 20);
g.addColorStop(0, '#f00');
g.addColorStop(1, '#0f0');
ctx.fillStyle = g;
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 1,1, 0,255,0,255, 0);
isPixel(ctx, 50,1, 0,255,0,255, 0);
isPixel(ctx, 98,1, 0,255,0,255, 0);
isPixel(ctx, 1,25, 0,255,0,255, 0);
isPixel(ctx, 50,25, 0,255,0,255, 0);
isPixel(ctx, 98,25, 0,255,0,255, 0);
isPixel(ctx, 1,48, 0,255,0,255, 0);
isPixel(ctx, 50,48, 0,255,0,255, 0);
isPixel(ctx, 98,48, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.gradient.radial.outside2.html ]]] -->
<p>Canvas test: 2d.gradient.radial.outside2</p>
<canvas id="c246" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_gradient_radial_outside2() {
var canvas = document.getElementById('c246');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#f00';
ctx.fillRect(0, 0, 100, 50);
var g = ctx.createRadialGradient(200, 25, 20, 200, 25, 10);
g.addColorStop(0, '#0f0');
g.addColorStop(1, '#f00');
ctx.fillStyle = g;
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 1,1, 0,255,0,255, 0);
isPixel(ctx, 50,1, 0,255,0,255, 0);
isPixel(ctx, 98,1, 0,255,0,255, 0);
isPixel(ctx, 1,25, 0,255,0,255, 0);
isPixel(ctx, 50,25, 0,255,0,255, 0);
isPixel(ctx, 98,25, 0,255,0,255, 0);
isPixel(ctx, 1,48, 0,255,0,255, 0);
isPixel(ctx, 50,48, 0,255,0,255, 0);
isPixel(ctx, 98,48, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.gradient.radial.outside3.html ]]] -->
<p>Canvas test: 2d.gradient.radial.outside3</p>
<canvas id="c247" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_gradient_radial_outside3() {
var canvas = document.getElementById('c247');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#f00';
ctx.fillRect(0, 0, 100, 50);
var g = ctx.createRadialGradient(200, 25, 20, 200, 25, 10);
g.addColorStop(0, '#0f0');
g.addColorStop(0.001, '#f00');
g.addColorStop(1, '#f00');
ctx.fillStyle = g;
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 1,1, 0,255,0,255, 0);
isPixel(ctx, 50,1, 0,255,0,255, 0);
isPixel(ctx, 98,1, 0,255,0,255, 0);
isPixel(ctx, 1,25, 0,255,0,255, 0);
isPixel(ctx, 50,25, 0,255,0,255, 0);
isPixel(ctx, 98,25, 0,255,0,255, 0);
isPixel(ctx, 1,48, 0,255,0,255, 0);
isPixel(ctx, 50,48, 0,255,0,255, 0);
isPixel(ctx, 98,48, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.gradient.radial.touch1.html ]]] -->
<p>Canvas test: 2d.gradient.radial.touch1</p>
<canvas id="c248" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_gradient_radial_touch1() {
var canvas = document.getElementById('c248');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#0f0';
ctx.fillRect(0, 0, 100, 50);
var g = ctx.createRadialGradient(150, 25, 50, 200, 25, 100);
g.addColorStop(0, '#f00');
g.addColorStop(1, '#f00');
ctx.fillStyle = g;
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 1,1, 0,255,0,255, 0);
isPixel(ctx, 50,1, 0,255,0,255, 0);
isPixel(ctx, 98,1, 0,255,0,255, 0);
isPixel(ctx, 1,25, 0,255,0,255, 0);
isPixel(ctx, 50,25, 0,255,0,255, 0);
isPixel(ctx, 98,25, 0,255,0,255, 0);
isPixel(ctx, 1,48, 0,255,0,255, 0);
isPixel(ctx, 50,48, 0,255,0,255, 0);
isPixel(ctx, 98,48, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.gradient.radial.touch2.html ]]] -->
<p>Canvas test: 2d.gradient.radial.touch2</p>
<canvas id="c249" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_gradient_radial_touch2() {
var canvas = document.getElementById('c249');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#f00';
ctx.fillRect(0, 0, 100, 50);
var g = ctx.createRadialGradient(-80, 25, 70, 0, 25, 150);
g.addColorStop(0, '#f00');
g.addColorStop(0.01, '#0f0');
g.addColorStop(0.99, '#0f0');
g.addColorStop(1, '#f00');
ctx.fillStyle = g;
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 1,1, 0,255,0,255, 0);
isPixel(ctx, 50,1, 0,255,0,255, 0);
isPixel(ctx, 98,1, 0,255,0,255, 0);
isPixel(ctx, 1,25, 0,255,0,255, 0);
isPixel(ctx, 50,25, 0,255,0,255, 0);
isPixel(ctx, 98,25, 0,255,0,255, 0);
isPixel(ctx, 1,48, 0,255,0,255, 0);
isPixel(ctx, 50,48, 0,255,0,255, 0);
isPixel(ctx, 98,48, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.gradient.radial.touch3.html ]]] -->
<p>Canvas test: 2d.gradient.radial.touch3</p>
<canvas id="c250" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_gradient_radial_touch3() {
var canvas = document.getElementById('c250');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#0f0';
ctx.fillRect(0, 0, 100, 50);
var g = ctx.createRadialGradient(120, -15, 25, 140, -30, 50);
g.addColorStop(0, '#f00');
g.addColorStop(1, '#f00');
ctx.fillStyle = g;
ctx.fillRect(0, 0, 100, 50);
isPixel(ctx, 1,1, 0,255,0,255, 0);
isPixel(ctx, 50,1, 0,255,0,255, 0);
isPixel(ctx, 98,1, 0,255,0,255, 0);
isPixel(ctx, 1,25, 0,255,0,255, 0);
isPixel(ctx, 50,25, 0,255,0,255, 0);
isPixel(ctx, 98,25, 0,255,0,255, 0);
isPixel(ctx, 1,48, 0,255,0,255, 0);
isPixel(ctx, 50,48, 0,255,0,255, 0);
isPixel(ctx, 98,48, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.gradient.radial.transform.1.html ]]] -->
<p>Canvas test: 2d.gradient.radial.transform.1</p>
<!-- Testing: Radial gradient coordinates are relative to the coordinate space at the time of filling -->
<canvas id="c251" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_gradient_radial_transform_1() {
var canvas = document.getElementById('c251');
var ctx = canvas.getContext('2d');
var g = ctx.createRadialGradient(0, 0, 0, 0, 0, 11.2);
g.addColorStop(0, '#0f0');
g.addColorStop(0.5, '#0f0');
g.addColorStop(0.51, '#f00');
g.addColorStop(1, '#f00');
ctx.fillStyle = g;
ctx.translate(50, 25);
ctx.scale(10, 10);
ctx.fillRect(-5, -2.5, 10, 5);
isPixel(ctx, 25,25, 0,255,0,255, 0);
isPixel(ctx, 50,25, 0,255,0,255, 0);
isPixel(ctx, 75,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.gradient.radial.transform.2.html ]]] -->
<p>Canvas test: 2d.gradient.radial.transform.2</p>
<!-- Testing: Radial gradient coordinates are relative to the coordinate space at the time of filling -->
<canvas id="c252" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_gradient_radial_transform_2() {
var canvas = document.getElementById('c252');
var ctx = canvas.getContext('2d');
ctx.translate(100, 0);
var g = ctx.createRadialGradient(0, 0, 0, 0, 0, 11.2);
g.addColorStop(0, '#0f0');
g.addColorStop(0.5, '#0f0');
g.addColorStop(0.51, '#f00');
g.addColorStop(1, '#f00');
ctx.fillStyle = g;
ctx.translate(-50, 25);
ctx.scale(10, 10);
ctx.fillRect(-5, -2.5, 10, 5);
isPixel(ctx, 25,25, 0,255,0,255, 0);
isPixel(ctx, 50,25, 0,255,0,255, 0);
isPixel(ctx, 75,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.gradient.radial.transform.3.html ]]] -->
<p>Canvas test: 2d.gradient.radial.transform.3</p>
<!-- Testing: Radial gradient transforms do not experience broken caching effects -->
<canvas id="c253" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_gradient_radial_transform_3() {
var canvas = document.getElementById('c253');
var ctx = canvas.getContext('2d');
var g = ctx.createRadialGradient(0, 0, 0, 0, 0, 11.2);
g.addColorStop(0, '#0f0');
g.addColorStop(0.5, '#0f0');
g.addColorStop(0.51, '#f00');
g.addColorStop(1, '#f00');
ctx.fillStyle = g;
ctx.fillRect(0, 0, 100, 50);
ctx.translate(50, 25);
ctx.scale(10, 10);
ctx.fillRect(-5, -2.5, 10, 5);
isPixel(ctx, 25,25, 0,255,0,255, 0);
isPixel(ctx, 50,25, 0,255,0,255, 0);
isPixel(ctx, 75,25, 0,255,0,255, 0);
}
</script>
<!-- [[[ test_2d.imageData.create.basic.html ]]] -->
<p>Canvas test: 2d.imageData.create.basic - bug 433004</p>
<!-- Testing: createImageData() exists and returns something -->
<canvas id="c254" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_imageData_create_basic() {
var canvas = document.getElementById('c254');
var ctx = canvas.getContext('2d');
ok(ctx.createImageData(1, 1) !== null, "ctx.createImageData(1, 1) !== null");
}
</script>
<!-- [[[ test_2d.imageData.create1.basic.html ]]] -->
<p>Canvas test: 2d.imageData.create1.basic - bug 630040</p>
<!-- Testing: createImageData(imgdata) exists and returns something -->
<canvas id="c254a" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_imageData_create1_basic() {
var canvas = document.getElementById('c254a');
var ctx = canvas.getContext('2d');
ok(ctx.createImageData(ctx.createImageData(1, 1)) != null, "ctx.createImageData(ctx.createImageData(1, 1)) != null");
}
</script>
<!-- [[[ test_2d.imageData.create.initial.html ]]] -->
<p>Canvas test: 2d.imageData.create.initial - bug 433004</p>
<!-- Testing: createImageData() returns transparent black data of the right size -->
<canvas id="c255" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_imageData_create_initial() {
var canvas = document.getElementById('c255');
var ctx = canvas.getContext('2d');
var imgdata = ctx.createImageData(10, 20);
ok(imgdata.data.length == imgdata.width*imgdata.height*4, "imgdata.data.length == imgdata.width*imgdata.height*4");
ok(imgdata.width < imgdata.height, "imgdata.width < imgdata.height");
ok(imgdata.width > 0, "imgdata.width > 0");
var isTransparentBlack = true;
for (var i = 0; i < imgdata.data.length; ++i)
if (imgdata.data[i] !== 0)
isTransparentBlack = false;
ok(isTransparentBlack, "isTransparentBlack");
}
</script>
<!-- [[[ test_2d.imageData.create1.initial.html ]]] -->
<p>Canvas test: 2d.imageData.create1.initial - bug 630040</p>
<!-- Testing: createImageData(imgdata) returns transparent black data of the right size -->
<canvas id="c255a" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_imageData_create1_initial() {
var canvas = document.getElementById('c255a');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#0f0';
ctx.fillRect(0, 0, 100, 50);
var imgdata1 = ctx.getImageData(0, 0, 10, 20);
var imgdata2 = ctx.createImageData(imgdata1);
ok(imgdata2.data.length == imgdata1.data.length, "imgdata2.data.length == imgdata1.data.length");
ok(imgdata2.width == imgdata1.width, "imgdata2.width == imgdata1.width");
ok(imgdata2.height == imgdata1.height, "imgdata2.height == imgdata1.height");
var isTransparentBlack = true;
for (var i = 0; i < imgdata2.data.length; ++i)
if (imgdata2.data[i] !== 0)
isTransparentBlack = false;
ok(isTransparentBlack, "isTransparentBlack");
}
</script>
<!-- [[[ test_2d.imageData.create.large.html ]]] -->
<p>Canvas test: 2d.imageData.create.large - bug 433004</p>
<!-- Testing: createImageData() works for sizes much larger than the canvas -->
<canvas id="c256" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_imageData_create_large() {
var canvas = document.getElementById('c256');
var ctx = canvas.getContext('2d');
var _thrown_outer = false;
var imgdata = ctx.createImageData(1000, 2000);
ok(imgdata.data.length == imgdata.width*imgdata.height*4, "imgdata.data.length == imgdata.width*imgdata.height*4");
ok(imgdata.width < imgdata.height, "imgdata.width < imgdata.height");
ok(imgdata.width > 0, "imgdata.width > 0");
var isTransparentBlack = true;
for (var i = 0; i < imgdata.data.length; i += 7813) // check ~1024 points (assuming normal scaling)
if (imgdata.data[i] !== 0)
isTransparentBlack = false;
ok(isTransparentBlack, "isTransparentBlack");
}
</script>
<!-- [[[ test_2d.imageData.create.negative.html ]]] -->
<p>Canvas test: 2d.imageData.create.negative - bug 433004</p>
<!-- Testing: createImageData() takes the absolute magnitude of the size arguments -->
<canvas id="c257" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_imageData_create_negative() {
var canvas = document.getElementById('c257');
var ctx = canvas.getContext('2d');
var _thrown_outer = false;
try {
var imgdata1 = ctx.createImageData(10, 20);
var imgdata2 = ctx.createImageData(-10, 20);
var imgdata3 = ctx.createImageData(10, -20);
var imgdata4 = ctx.createImageData(-10, -20);
ok(imgdata1.data.length == imgdata2.data.length, "imgdata1.data.length == imgdata2.data.length");
ok(imgdata2.data.length == imgdata3.data.length, "imgdata2.data.length == imgdata3.data.length");
ok(imgdata3.data.length == imgdata4.data.length, "imgdata3.data.length == imgdata4.data.length");
} catch (e) {
_thrown_outer = true;
}
ok(!_thrown_outer, ctx.canvas.id + ' should not throw exception');
}
</script>
<!-- [[[ test_2d.imageData.create.nonfinite.html ]]] -->
<p>Canvas test: 2d.imageData.create.nonfinite - bug 433004</p>
<!-- Testing: createImageData() throws NOT_SUPPORTED_ERR if arguments are not finite -->
<canvas id="c258" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_imageData_create_nonfinite() {
var canvas = document.getElementById('c258');
var ctx = canvas.getContext('2d');
var _thrown = undefined; try {
ctx.createImageData(Infinity, 10);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createImageData(-Infinity, 10);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createImageData(NaN, 10);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createImageData(10, Infinity);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createImageData(10, -Infinity);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createImageData(10, NaN);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createImageData(Infinity, Infinity);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createImageData({valueOf:() => Infinity}, 10);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createImageData({valueOf:() => -Infinity}, 10);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createImageData({valueOf:() => NaN}, 10);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createImageData(10, {valueOf:() => Infinity});
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createImageData(10, {valueOf:() => -Infinity});
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createImageData(10, {valueOf:() => NaN});
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.createImageData({valueOf:() => Infinity}, {valueOf:() => Infinity});
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
}
</script>
<!-- [[[ test_2d.imageData.create.round.html ]]] -->
<p>Canvas test: 2d.imageData.create.round - bug 433004</p>
<!-- Testing: createImageData(w, h) is rounded the same as getImageData(0, 0, w, h) -->
<canvas id="c259" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_imageData_create_round() {
var canvas = document.getElementById('c259');
var ctx = canvas.getContext('2d');
var _thrown_outer = false;
var imgdata1 = ctx.createImageData(10.01, 10.99);
var imgdata2 = ctx.getImageData(0, 0, 10.01, 10.99);
is(imgdata1.width, imgdata2.width, "imgdata1.width == imgdata2.width");
is(imgdata1.height, imgdata2.height, "imgdata1.height == imgdata2.height");
}
</script>
<!-- [[[ test_2d.imageData.create.tiny.html ]]] -->
<p>Canvas test: 2d.imageData.create.tiny - bug 433004</p>
<!-- Testing: createImageData() works for sizes smaller than one pixel -->
<canvas id="c260" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_imageData_create_tiny() {
var canvas = document.getElementById('c260');
var ctx = canvas.getContext('2d');
var _thrown_outer = false;
try {
var imgdata = ctx.createImageData(0.0001, 0.0001);
} catch (e) {
_thrown_outer = true;
}
ok(_thrown_outer, ctx.canvas.id + ' should throw exception');
}
</script>
<!-- [[[ test_2d.imageData.create.type.html ]]] -->
<p>Canvas test: 2d.imageData.create.type - bug 433004</p>
<!-- Testing: createImageData() returns an ImageData object containing a Uint8ClampedArray object -->
<canvas id="c261" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_imageData_create_type() {
var canvas = document.getElementById('c261');
var ctx = canvas.getContext('2d');
ok(window.ImageData !== undefined, "window.ImageData !== undefined");
ok(window.Uint8ClampedArray !== undefined, "window.Uint8ClampedArray !== undefined");
window.ImageData.prototype.thisImplementsImageData = true;
window.Uint8ClampedArray.prototype.thisImplementsUint8ClampedArray = true;
var imgdata = ctx.createImageData(1, 1);
ok(imgdata.thisImplementsImageData, "imgdata.thisImplementsImageData");
ok(imgdata.data.thisImplementsUint8ClampedArray, "imgdata.data.thisImplementsUint8ClampedArray");
}
</script>
<!-- [[[ test_2d.imageData.create1.type.html ]]] -->
<p>Canvas test: 2d.imageData.create1.type - bug 630040</p>
<!-- Testing: createImageData(imgdata) returns an ImageData object containing a Uint8ClampedArray object -->
<canvas id="c261a" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_imageData_create1_type() {
var canvas = document.getElementById('c261a');
var ctx = canvas.getContext('2d');
ok(window.ImageData !== undefined, "window.ImageData !== undefined");
ok(window.Uint8ClampedArray !== undefined, "window.Uint8ClampedArray !== undefined");
window.ImageData.prototype.thisImplementsImageData = true;
window.Uint8ClampedArray.prototype.thisImplementsUint8ClampedArray = true;
var imgdata = ctx.createImageData(ctx.createImageData(1, 1));
ok(imgdata.thisImplementsImageData, "imgdata.thisImplementsImageData");
ok(imgdata.data.thisImplementsUint8ClampedArray, "imgdata.data.thisImplementsUint8ClampedArray");
}
</script>
<!-- [[[ test_2d.imageData.create.zero.html ]]] -->
<p>Canvas test: 2d.imageData.create.zero - bug 433004</p>
<!-- Testing: createImageData() throws INDEX_SIZE_ERR if size is zero -->
<canvas id="c262" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_imageData_create_zero() {
var canvas = document.getElementById('c262');
var ctx = canvas.getContext('2d');
var _thrown = undefined; try {
ctx.createImageData(10, 0);
} catch (e) { _thrown = e }; ok(_thrown && _thrown.name == "IndexSizeError" && _thrown.code == DOMException.INDEX_SIZE_ERR, "should throw IndexSizeError");
var _thrown = undefined; try {
ctx.createImageData(0, 10);
} catch (e) { _thrown = e }; ok(_thrown && _thrown.name == "IndexSizeError" && _thrown.code == DOMException.INDEX_SIZE_ERR, "should throw IndexSizeError");
var _thrown = undefined; try {
ctx.createImageData(0, 0);
} catch (e) { _thrown = e }; ok(_thrown && _thrown.name == "IndexSizeError" && _thrown.code == DOMException.INDEX_SIZE_ERR, "should throw IndexSizeError");
}
</script>
<!-- [[[ test_2d.imageData.create1.zero.html ]]] -->
<p>Canvas test: 2d.imageData.create1.zero - bug 630040</p>
<!-- Testing: createImageData(null) throws TypeError -->
<canvas id="c262a" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_imageData_create1_zero() {
var canvas = document.getElementById('c262a');
var ctx = canvas.getContext('2d');
var _thrown = undefined; try {
ctx.createImageData(null);
} catch (e) { _thrown = e };
ok(_thrown && _thrown.name == "TypeError", "should throw TypeError");
}
</script>
<!-- [[[ test_2d.imageData.get.basic.html ]]] -->
<p>Canvas test: 2d.imageData.get.basic</p>
<!-- Testing: getImageData() exists and returns something -->
<canvas id="c263" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_imageData_get_basic() {
var canvas = document.getElementById('c263');
var ctx = canvas.getContext('2d');
ok(ctx.getImageData(0, 0, 100, 50) !== null, "ctx.getImageData(0, 0, 100, 50) !== null");
}
</script>
<!-- [[[ test_2d.imageData.get.clamp.html ]]] -->
<p>Canvas test: 2d.imageData.get.clamp</p>
<!-- Testing: getImageData() clamps colours to the range [0, 255] -->
<canvas id="c264" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_imageData_get_clamp() {
var canvas = document.getElementById('c264');
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'rgb(-100, -200, -300)';
ctx.fillRect(0, 0, 100, 50);
ctx.fillStyle = 'rgb(256, 300, 400)';
ctx.fillRect(20, 10, 60, 10);
var imgdata1 = ctx.getImageData(10, 5, 1, 1);
ok(imgdata1.data[0] === 0, "imgdata1.data[\""+(0)+"\"] === 0");
ok(imgdata1.data[1] === 0, "imgdata1.data[\""+(1)+"\"] === 0");
ok(imgdata1.data[2] === 0, "imgdata1.data[\""+(2)+"\"] === 0");
var imgdata2 = ctx.getImageData(30, 15, 1, 1);
ok(imgdata2.data[0] === 255, "imgdata2.data[\""+(0)+"\"] === 255");
ok(imgdata2.data[1] === 255, "imgdata2.data[\""+(1)+"\"] === 255");
ok(imgdata2.data[2] === 255, "imgdata2.data[\""+(2)+"\"] === 255");
}
</script>
<!-- [[[ test_2d.imageData.get.nonfinite.html ]]] -->
<p>Canvas test: 2d.imageData.get.nonfinite</p>
<!-- Testing: getImageData() throws NOT_SUPPORTED_ERR if arguments are not finite -->
<canvas id="c265" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
// eslint-disable-next-line complexity
function test_2d_imageData_get_nonfinite() {
var canvas = document.getElementById('c265');
var ctx = canvas.getContext('2d');
var _thrown = undefined; try {
ctx.getImageData(Infinity, 10, 10, 10);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.getImageData(-Infinity, 10, 10, 10);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.getImageData(NaN, 10, 10, 10);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.getImageData(10, Infinity, 10, 10);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.getImageData(10, -Infinity, 10, 10);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.getImageData(10, NaN, 10, 10);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.getImageData(10, 10, Infinity, 10);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.getImageData(10, 10, -Infinity, 10);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.getImageData(10, 10, NaN, 10);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.getImageData(10, 10, 10, Infinity);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.getImageData(10, 10, 10, -Infinity);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.getImageData(10, 10, 10, NaN);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.getImageData(Infinity, Infinity, 10, 10);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.getImageData(Infinity, Infinity, Infinity, 10);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.getImageData(Infinity, Infinity, Infinity, Infinity);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.getImageData(Infinity, Infinity, 10, Infinity);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.getImageData(Infinity, 10, Infinity, 10);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.getImageData(Infinity, 10, Infinity, Infinity);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.getImageData(Infinity, 10, 10, Infinity);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.getImageData(10, Infinity, Infinity, 10);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.getImageData(10, Infinity, Infinity, Infinity);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.getImageData(10, Infinity, 10, Infinity);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.getImageData(10, 10, Infinity, Infinity);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.getImageData({valueOf:() => Infinity}, 10, 10, 10);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.getImageData({valueOf:() => -Infinity}, 10, 10, 10);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.getImageData({valueOf:() => NaN}, 10, 10, 10);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.getImageData(10, {valueOf:() => Infinity}, 10, 10);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.getImageData(10, {valueOf:() => -Infinity}, 10, 10);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.getImageData(10, {valueOf:() => NaN}, 10, 10);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.getImageData(10, 10, {valueOf:() => Infinity}, 10);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.getImageData(10, 10, {valueOf:() => -Infinity}, 10);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.getImageData(10, 10, {valueOf:() => NaN}, 10);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.getImageData(10, 10, 10, {valueOf:() => Infinity});
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.getImageData(10, 10, 10, {valueOf:() => -Infinity});
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.getImageData(10, 10, 10, {valueOf:() => NaN});
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.getImageData({valueOf:() => Infinity}, {valueOf:() => Infinity}, 10, 10);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.getImageData({valueOf:() => Infinity}, {valueOf:() => Infinity}, {valueOf:() => Infinity}, 10);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.getImageData({valueOf:() => Infinity}, {valueOf:() => Infinity}, {valueOf:() => Infinity}, {valueOf:() => Infinity});
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.getImageData({valueOf:() => Infinity}, {valueOf:() => Infinity}, 10, {valueOf:() => Infinity});
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.getImageData({valueOf:() => Infinity}, 10, {valueOf:() => Infinity}, 10);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.getImageData({valueOf:() => Infinity}, 10, {valueOf:() => Infinity}, {valueOf:() => Infinity});
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.getImageData({valueOf:() => Infinity}, 10, 10, {valueOf:() => Infinity});
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.getImageData(10, {valueOf:() => Infinity}, {valueOf:() => Infinity}, 10);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.getImageData(10, {valueOf:() => Infinity}, {valueOf:() => Infinity}, {valueOf:() => Infinity});
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.getImageData(10, {valueOf:() => Infinity}, 10, {valueOf:() => Infinity});
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.getImageData(10, 10, {valueOf:() => Infinity}, {valueOf:() => Infinity});
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
}
</script>
<!-- [[[ test_2d.imageData.get.nonpremul.html ]]] -->
<p>Canvas test: 2d.imageData.get.nonpremul</p>
<!-- Testing: getImageData() returns non-premultiplied colours -->
<canvas id="c266" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_imageData_get_nonpremul() {
var canvas = document.getElementById('c266');
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'rgba(255, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
var imgdata = ctx.getImageData(10, 10, 10, 10);
ok(imgdata.data[0] > 200, "imgdata.data[\""+(0)+"\"] > 200");
ok(imgdata.data[1] > 200, "imgdata.data[\""+(1)+"\"] > 200");
ok(imgdata.data[2] > 200, "imgdata.data[\""+(2)+"\"] > 200");
ok(imgdata.data[3] > 100, "imgdata.data[\""+(3)+"\"] > 100");
ok(imgdata.data[3] < 200, "imgdata.data[\""+(3)+"\"] < 200");
}
</script>
<!-- [[[ test_2d.imageData.get.order.alpha.html ]]] -->
<p>Canvas test: 2d.imageData.get.order.alpha</p>
<!-- Testing: getImageData() returns A in the fourth component -->
<canvas id="c267" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_imageData_get_order_alpha() {
var canvas = document.getElementById('c267');
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'rgba(0, 0, 0, 0.5)';
ctx.fillRect(0, 0, 100, 50);
var imgdata = ctx.getImageData(0, 0, 10, 10);
ok(imgdata.data[3] < 200, "imgdata.data[\""+(3)+"\"] < 200");
ok(imgdata.data[3] > 100, "imgdata.data[\""+(3)+"\"] > 100");
}
</script>
<!-- [[[ test_2d.imageData.get.order.cols.html ]]] -->
<p>Canvas test: 2d.imageData.get.order.cols</p>
<!-- Testing: getImageData() returns leftmost columns first -->
<canvas id="c268" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_imageData_get_order_cols() {
var canvas = document.getElementById('c268');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#fff';
ctx.fillRect(0, 0, 100, 50);
ctx.fillStyle = '#000';
ctx.fillRect(0, 0, 2, 50);
var imgdata = ctx.getImageData(0, 0, 10, 10);
ok(imgdata.data[0] === 0, "imgdata.data[\""+(0)+"\"] === 0");
ok(imgdata.data[Math.round(imgdata.width/2*4)] === 255, "imgdata.data[Math.round(imgdata.width/2*4)] === 255");
ok(imgdata.data[Math.round((imgdata.height/2)*imgdata.width*4)] === 0, "imgdata.data[Math.round((imgdata.height/2)*imgdata.width*4)] === 0");
}
</script>
<!-- [[[ test_2d.imageData.get.order.rgb.html ]]] -->
<p>Canvas test: 2d.imageData.get.order.rgb</p>
<!-- Testing: getImageData() returns R then G then B -->
<canvas id="c269" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_imageData_get_order_rgb() {
var canvas = document.getElementById('c269');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#48c';
ctx.fillRect(0, 0, 100, 50);
var imgdata = ctx.getImageData(0, 0, 10, 10);
ok(imgdata.data[0] === 0x44, "imgdata.data[\""+(0)+"\"] === 0x44");
ok(imgdata.data[1] === 0x88, "imgdata.data[\""+(1)+"\"] === 0x88");
ok(imgdata.data[2] === 0xCC, "imgdata.data[\""+(2)+"\"] === 0xCC");
ok(imgdata.data[3] === 255, "imgdata.data[\""+(3)+"\"] === 255");
}
</script>
<!-- [[[ test_2d.imageData.get.order.rows.html ]]] -->
<p>Canvas test: 2d.imageData.get.order.rows</p>
<!-- Testing: getImageData() returns topmost rows first -->
<canvas id="c270" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_imageData_get_order_rows() {
var canvas = document.getElementById('c270');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#fff';
ctx.fillRect(0, 0, 100, 50);
ctx.fillStyle = '#000';
ctx.fillRect(0, 0, 100, 2);
var imgdata = ctx.getImageData(0, 0, 10, 10);
ok(imgdata.data[0] === 0, "imgdata.data[\""+(0)+"\"] === 0");
ok(imgdata.data[Math.floor(imgdata.width/2*4)] === 0, "imgdata.data[Math.floor(imgdata.width/2*4)] === 0");
ok(imgdata.data[(imgdata.height/2)*imgdata.width*4] === 255, "imgdata.data[(imgdata.height/2)*imgdata.width*4] === 255");
}
</script>
<!-- [[[ test_2d.imageData.get.range.html ]]] -->
<p>Canvas test: 2d.imageData.get.range</p>
<!-- Testing: getImageData() returns values in the range [0, 255] -->
<canvas id="c271" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_imageData_get_range() {
var canvas = document.getElementById('c271');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#000';
ctx.fillRect(0, 0, 100, 50);
ctx.fillStyle = '#fff';
ctx.fillRect(20, 10, 60, 10);
var imgdata1 = ctx.getImageData(10, 5, 1, 1);
ok(imgdata1.data[0] === 0, "imgdata1.data[\""+(0)+"\"] === 0");
var imgdata2 = ctx.getImageData(30, 15, 1, 1);
ok(imgdata2.data[0] === 255, "imgdata2.data[\""+(0)+"\"] === 255");
}
</script>
<!-- [[[ test_2d.imageData.get.source.negative.html ]]] -->
<p>Canvas test: 2d.imageData.get.source.negative</p>
<!-- Testing: getImageData() works with negative width and height -->
<canvas id="c272" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_imageData_get_source_negative() {
var canvas = document.getElementById('c272');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#000';
ctx.fillRect(0, 0, 100, 50);
ctx.fillStyle = '#fff';
ctx.fillRect(20, 10, 60, 10);
var imgdata1 = ctx.getImageData(85, 25, -10, -10);
ok(imgdata1.data[0] === 255, "imgdata1.data[\""+(0)+"\"] === 255");
ok(imgdata1.data[1] === 255, "imgdata1.data[\""+(1)+"\"] === 255");
ok(imgdata1.data[2] === 255, "imgdata1.data[\""+(2)+"\"] === 255");
ok(imgdata1.data[3] === 255, "imgdata1.data[\""+(3)+"\"] === 255");
ok(imgdata1.data[imgdata1.data.length-4+0] === 0, "imgdata1.data[imgdata1.data.length-4+0] === 0");
ok(imgdata1.data[imgdata1.data.length-4+1] === 0, "imgdata1.data[imgdata1.data.length-4+1] === 0");
ok(imgdata1.data[imgdata1.data.length-4+2] === 0, "imgdata1.data[imgdata1.data.length-4+2] === 0");
ok(imgdata1.data[imgdata1.data.length-4+3] === 255, "imgdata1.data[imgdata1.data.length-4+3] === 255");
var imgdata2 = ctx.getImageData(0, 0, -1, -1);
ok(imgdata2.data[0] === 0, "imgdata2.data[\""+(0)+"\"] === 0");
ok(imgdata2.data[1] === 0, "imgdata2.data[\""+(1)+"\"] === 0");
ok(imgdata2.data[2] === 0, "imgdata2.data[\""+(2)+"\"] === 0");
ok(imgdata2.data[3] === 0, "imgdata2.data[\""+(3)+"\"] === 0");
}
</script>
<!-- [[[ test_2d.imageData.get.source.outside.html ]]] -->
<p>Canvas test: 2d.imageData.get.source.outside</p>
<!-- Testing: getImageData() returns transparent black outside the canvas -->
<canvas id="c273" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_imageData_get_source_outside() {
var canvas = document.getElementById('c273');
var ctx = canvas.getContext('2d');
var _thrown_outer = false;
try {
ctx.fillStyle = '#08f';
ctx.fillRect(0, 0, 100, 50);
var imgdata1 = ctx.getImageData(-10, 5, 1, 1);
ok(imgdata1.data[0] === 0, "imgdata1.data[\""+(0)+"\"] === 0");
ok(imgdata1.data[1] === 0, "imgdata1.data[\""+(1)+"\"] === 0");
ok(imgdata1.data[2] === 0, "imgdata1.data[\""+(2)+"\"] === 0");
ok(imgdata1.data[3] === 0, "imgdata1.data[\""+(3)+"\"] === 0");
var imgdata2 = ctx.getImageData(10, -5, 1, 1);
ok(imgdata2.data[0] === 0, "imgdata2.data[\""+(0)+"\"] === 0");
ok(imgdata2.data[1] === 0, "imgdata2.data[\""+(1)+"\"] === 0");
ok(imgdata2.data[2] === 0, "imgdata2.data[\""+(2)+"\"] === 0");
ok(imgdata2.data[3] === 0, "imgdata2.data[\""+(3)+"\"] === 0");
var imgdata3 = ctx.getImageData(200, 5, 1, 1);
ok(imgdata3.data[0] === 0, "imgdata3.data[\""+(0)+"\"] === 0");
ok(imgdata3.data[1] === 0, "imgdata3.data[\""+(1)+"\"] === 0");
ok(imgdata3.data[2] === 0, "imgdata3.data[\""+(2)+"\"] === 0");
ok(imgdata3.data[3] === 0, "imgdata3.data[\""+(3)+"\"] === 0");
var imgdata4 = ctx.getImageData(10, 60, 1, 1);
ok(imgdata4.data[0] === 0, "imgdata4.data[\""+(0)+"\"] === 0");
ok(imgdata4.data[1] === 0, "imgdata4.data[\""+(1)+"\"] === 0");
ok(imgdata4.data[2] === 0, "imgdata4.data[\""+(2)+"\"] === 0");
ok(imgdata4.data[3] === 0, "imgdata4.data[\""+(3)+"\"] === 0");
var imgdata5 = ctx.getImageData(100, 10, 1, 1);
ok(imgdata5.data[0] === 0, "imgdata5.data[\""+(0)+"\"] === 0");
ok(imgdata5.data[1] === 0, "imgdata5.data[\""+(1)+"\"] === 0");
ok(imgdata5.data[2] === 0, "imgdata5.data[\""+(2)+"\"] === 0");
ok(imgdata5.data[3] === 0, "imgdata5.data[\""+(3)+"\"] === 0");
var imgdata6 = ctx.getImageData(0, 10, 1, 1);
ok(imgdata6.data[0] === 0, "imgdata6.data[\""+(0)+"\"] === 0");
ok(imgdata6.data[1] === 136, "imgdata6.data[\""+(1)+"\"] === 136");
ok(imgdata6.data[2] === 255, "imgdata6.data[\""+(2)+"\"] === 255");
ok(imgdata6.data[3] === 255, "imgdata6.data[\""+(3)+"\"] === 255");
var imgdata7 = ctx.getImageData(-10, 10, 20, 20);
ok(imgdata7.data[ 0*4+0] === 0, "imgdata7.data[ 0*4+0] === 0");
ok(imgdata7.data[ 0*4+1] === 0, "imgdata7.data[ 0*4+1] === 0");
ok(imgdata7.data[ 0*4+2] === 0, "imgdata7.data[ 0*4+2] === 0");
ok(imgdata7.data[ 0*4+3] === 0, "imgdata7.data[ 0*4+3] === 0");
ok(imgdata7.data[ 9*4+0] === 0, "imgdata7.data[ 9*4+0] === 0");
ok(imgdata7.data[ 9*4+1] === 0, "imgdata7.data[ 9*4+1] === 0");
ok(imgdata7.data[ 9*4+2] === 0, "imgdata7.data[ 9*4+2] === 0");
ok(imgdata7.data[ 9*4+3] === 0, "imgdata7.data[ 9*4+3] === 0");
ok(imgdata7.data[10*4+0] === 0, "imgdata7.data[10*4+0] === 0");
ok(imgdata7.data[10*4+1] === 136, "imgdata7.data[10*4+1] === 136");
ok(imgdata7.data[10*4+2] === 255, "imgdata7.data[10*4+2] === 255");
ok(imgdata7.data[10*4+3] === 255, "imgdata7.data[10*4+3] === 255");
ok(imgdata7.data[19*4+0] === 0, "imgdata7.data[19*4+0] === 0");
ok(imgdata7.data[19*4+1] === 136, "imgdata7.data[19*4+1] === 136");
ok(imgdata7.data[19*4+2] === 255, "imgdata7.data[19*4+2] === 255");
ok(imgdata7.data[19*4+3] === 255, "imgdata7.data[19*4+3] === 255");
ok(imgdata7.data[20*4+0] === 0, "imgdata7.data[20*4+0] === 0");
ok(imgdata7.data[20*4+1] === 0, "imgdata7.data[20*4+1] === 0");
ok(imgdata7.data[20*4+2] === 0, "imgdata7.data[20*4+2] === 0");
ok(imgdata7.data[20*4+3] === 0, "imgdata7.data[20*4+3] === 0");
} catch (e) {
_thrown_outer = true;
}
ok(!_thrown_outer, ctx.canvas.id + ' should not throw exception');
}
</script>
<!-- [[[ test_2d.imageData.get.source.size.html ]]] -->
<p>Canvas test: 2d.imageData.get.source.size</p>
<!-- Testing: getImageData() returns bigger ImageData for bigger source rectangle -->
<canvas id="c274" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_imageData_get_source_size() {
var canvas = document.getElementById('c274');
var ctx = canvas.getContext('2d');
var imgdata1 = ctx.getImageData(0, 0, 10, 10);
var imgdata2 = ctx.getImageData(0, 0, 20, 20);
ok(imgdata2.width > imgdata1.width, "imgdata2.width > imgdata1.width");
ok(imgdata2.height > imgdata1.height, "imgdata2.height > imgdata1.height");
}
</script>
<!-- [[[ test_2d.imageData.get.tiny.html ]]] -->
<p>Canvas test: 2d.imageData.get.tiny</p>
<canvas id="c275" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_imageData_get_tiny() {
var canvas = document.getElementById('c275');
var ctx = canvas.getContext('2d');
var _thrown_outer = false;
try {
var imgdata = ctx.getImageData(0, 0, 0.0001, 0.0001);
} catch (e) {
_thrown_outer = true;
}
ok(_thrown_outer, ctx.canvas.id + ' should throw');
}
</script>
<!-- [[[ test_2d.imageData.get.type.html ]]] -->
<p>Canvas test: 2d.imageData.get.type</p>
<!-- Testing: getImageData() returns an ImageData object containing a Uint8ClampedArray object -->
<canvas id="c276" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_imageData_get_type() {
var canvas = document.getElementById('c276');
var ctx = canvas.getContext('2d');
ok(window.ImageData !== undefined, "window.ImageData !== undefined");
ok(window.Uint8ClampedArray !== undefined, "window.Uint8ClampedArray !== undefined");
window.ImageData.prototype.thisImplementsImageData = true;
window.Uint8ClampedArray.prototype.thisImplementsUint8ClampedArray = true;
var imgdata = ctx.getImageData(0, 0, 1, 1);
ok(imgdata.thisImplementsImageData, "imgdata.thisImplementsImageData");
ok(imgdata.data.thisImplementsUint8ClampedArray, "imgdata.data.thisImplementsUint8ClampedArray");
}
</script>
<!-- [[[ test_2d.imageData.get.unaffected.html ]]] -->
<p>Canvas test: 2d.imageData.get.unaffected</p>
<!-- Testing: getImageData() is not affected by context state -->
<canvas id="c277" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_imageData_get_unaffected() {
var canvas = document.getElementById('c277');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#0f0';
ctx.fillRect(0, 0, 50, 50)
ctx.fillStyle = '#f00';
ctx.fillRect(50, 0, 50, 50)
ctx.save();
ctx.translate(50, 0);
ctx.globalAlpha = 0.1;
ctx.globalCompositeOperation = 'destination-atop';
ctx.shadowColor = '#f00';
ctx.rect(0, 0, 5, 5);
ctx.clip();
var imgdata = ctx.getImageData(0, 0, 50, 50);
ctx.restore();
ctx.putImageData(imgdata, 50, 0);
isPixel(ctx, 25,25, 0,255,0,255, 2);
isPixel(ctx, 75,25, 0,255,0,255, 2);
}
</script>
<!-- [[[ test_2d.imageData.get.zero.html ]]] -->
<p>Canvas test: 2d.imageData.get.zero</p>
<!-- Testing: getImageData() throws INDEX_SIZE_ERR if size is zero -->
<canvas id="c278" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_imageData_get_zero() {
var canvas = document.getElementById('c278');
var ctx = canvas.getContext('2d');
var _thrown = undefined; try {
ctx.getImageData(1, 1, 10, 0);
} catch (e) { _thrown = e }; ok(_thrown && _thrown.name == "IndexSizeError" && _thrown.code == DOMException.INDEX_SIZE_ERR, "should throw IndexSizeError");
var _thrown = undefined; try {
ctx.getImageData(1, 1, 0, 10);
} catch (e) { _thrown = e }; ok(_thrown && _thrown.name == "IndexSizeError" && _thrown.code == DOMException.INDEX_SIZE_ERR, "should throw IndexSizeError");
var _thrown = undefined; try {
ctx.getImageData(1, 1, 0, 0);
} catch (e) { _thrown = e }; ok(_thrown && _thrown.name == "IndexSizeError" && _thrown.code == DOMException.INDEX_SIZE_ERR, "should throw IndexSizeError");
}
</script>
<!-- [[[ test_2d.imageData.object.clamp.html ]]] -->
<p>Canvas test: 2d.imageData.object.clamp</p>
<!-- Testing: ImageData.data clamps numbers to [0, 255] -->
<canvas id="c279" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_imageData_object_clamp() {
var canvas = document.getElementById('c279');
var ctx = canvas.getContext('2d');
var imgdata = ctx.getImageData(0, 0, 10, 10);
imgdata.data[0] = 100;
imgdata.data[0] = 300;
ok(imgdata.data[0] === 255, "imgdata.data[\""+(0)+"\"] === 255");
imgdata.data[0] = 100;
imgdata.data[0] = -100;
ok(imgdata.data[0] === 0, "imgdata.data[\""+(0)+"\"] === 0");
imgdata.data[0] = 100;
imgdata.data[0] = 200+Math.pow(2, 32);
ok(imgdata.data[0] === 255, "imgdata.data[\""+(0)+"\"] === 255");
imgdata.data[0] = 100;
imgdata.data[0] = -200-Math.pow(2, 32);
ok(imgdata.data[0] === 0, "imgdata.data[\""+(0)+"\"] === 0");
imgdata.data[0] = 100;
imgdata.data[0] = Math.pow(10, 39);
ok(imgdata.data[0] === 255, "imgdata.data[\""+(0)+"\"] === 255");
imgdata.data[0] = 100;
imgdata.data[0] = -Math.pow(10, 39);
ok(imgdata.data[0] === 0, "imgdata.data[\""+(0)+"\"] === 0");
imgdata.data[0] = 100;
imgdata.data[0] = -Infinity;
ok(imgdata.data[0] === 0, "imgdata.data[\""+(0)+"\"] === 0");
imgdata.data[0] = 100;
imgdata.data[0] = Infinity;
ok(imgdata.data[0] === 255, "imgdata.data[\""+(0)+"\"] === 255");
}
</script>
<!-- [[[ test_2d.imageData.object.ctor.html ]]] -->
<p>Canvas test: 2d.imageData.object.ctor</p>
<!-- Testing: ImageData does not have a usable constructor -->
<canvas id="c280" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_imageData_object_ctor() {
var canvas = document.getElementById('c280');
var ctx = canvas.getContext('2d');
ok(window.ImageData !== undefined, "window.ImageData !== undefined");
var _thrown_outer = false;
try {
new window.ImageData(1,1);
} catch (e) {
_thrown_outer = true;
}
ok(!_thrown_outer, ctx.canvas.id + ' should not throw exception');
}
</script>
<!-- [[[ test_2d.imageData.object.nan.html ]]] -->
<p>Canvas test: 2d.imageData.object.nan</p>
<!-- Testing: ImageData.data converts NaN to 0 -->
<canvas id="c281" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_imageData_object_nan() {
var canvas = document.getElementById('c281');
var ctx = canvas.getContext('2d');
var imgdata = ctx.getImageData(0, 0, 10, 10);
imgdata.data[0] = 100;
imgdata.data[0] = NaN;
ok(imgdata.data[0] === 0, "imgdata.data[\""+(0)+"\"] === 0");
imgdata.data[0] = 100;
imgdata.data[0] = "cheese";
ok(imgdata.data[0] === 0, "imgdata.data[\""+(0)+"\"] === 0");
}
</script>
<!-- [[[ test_2d.imageData.object.properties.html ]]] -->
<p>Canvas test: 2d.imageData.object.properties</p>
<!-- Testing: ImageData objects have the right properties -->
<canvas id="c282" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_imageData_object_properties() {
var canvas = document.getElementById('c282');
var ctx = canvas.getContext('2d');
var imgdata = ctx.getImageData(0, 0, 10, 10);
ok(typeof(imgdata.width) == 'number', "typeof(imgdata.width) == 'number'");
ok(typeof(imgdata.height) == 'number', "typeof(imgdata.height) == 'number'");
ok(typeof(imgdata.data) == 'object', "typeof(imgdata.data) == 'object'");
}
</script>
<!-- [[[ test_2d.imageData.object.readonly.html ]]] -->
<p>Canvas test: 2d.imageData.object.readonly</p>
<!-- Testing: ImageData objects properties are read-only -->
<canvas id="c283" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_imageData_object_readonly() {
var canvas = document.getElementById('c283');
var ctx = canvas.getContext('2d');
var imgdata = ctx.getImageData(0, 0, 10, 10);
var w = imgdata.width;
var h = imgdata.height;
var d = imgdata.data;
imgdata.width = 123;
imgdata.height = 123;
imgdata.data = [100,100,100,100];
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");
}
</script>
<!-- [[[ test_2d.imageData.object.round.html ]]] -->
<p>Canvas test: 2d.imageData.object.round</p>
<!-- Testing: ImageData.data rounds numbers with convertToIntegerTiesToEven -->
<canvas id="c284" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_imageData_object_round() {
var canvas = document.getElementById('c284');
var ctx = canvas.getContext('2d');
var imgdata = ctx.getImageData(0, 0, 10, 10);
imgdata.data[0] = 0.499;
ok(imgdata.data[0] === 0, "imgdata.data[\""+(0)+"\"] === 0");
imgdata.data[0] = 0.5;
ok(imgdata.data[0] === 0, "imgdata.data[\""+(0)+"\"] === 0");
imgdata.data[0] = 0.501;
ok(imgdata.data[0] === 1, "imgdata.data[\""+(0)+"\"] === 1");
imgdata.data[0] = 1.499;
ok(imgdata.data[0] === 1, "imgdata.data[\""+(0)+"\"] === 1");
imgdata.data[0] = 1.5;
ok(imgdata.data[0] === 2, "imgdata.data[\""+(0)+"\"] === 2");
imgdata.data[0] = 1.501;
ok(imgdata.data[0] === 2, "imgdata.data[\""+(0)+"\"] === 2");
imgdata.data[0] = 2.5;
ok(imgdata.data[0] === 2, "imgdata.data[\""+(0)+"\"] === 2");
imgdata.data[0] = 3.5;
ok(imgdata.data[0] === 4, "imgdata.data[\""+(0)+"\"] === 4");
imgdata.data[0] = 252.5;
ok(imgdata.data[0] === 252, "imgdata.data[\""+(0)+"\"] === 252");
imgdata.data[0] = 253.5;
ok(imgdata.data[0] === 254, "imgdata.data[\""+(0)+"\"] === 254");
imgdata.data[0] = 254.5;
ok(imgdata.data[0] === 254, "imgdata.data[\""+(0)+"\"] === 254");
}
</script>
<!-- [[[ test_2d.imageData.object.set.html ]]] -->
<p>Canvas test: 2d.imageData.object.set</p>
<!-- Testing: ImageData.data can be modified -->
<canvas id="c285" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_imageData_object_set() {
var canvas = document.getElementById('c285');
var ctx = canvas.getContext('2d');
var imgdata = ctx.getImageData(0, 0, 10, 10);
imgdata.data[0] = 100;
ok(imgdata.data[0] === 100, "imgdata.data[\""+(0)+"\"] === 100");
imgdata.data[0] = 200;
ok(imgdata.data[0] === 200, "imgdata.data[\""+(0)+"\"] === 200");
}
</script>
<!-- [[[ test_2d.imageData.object.string.html ]]] -->
<p>Canvas test: 2d.imageData.object.string</p>
<!-- Testing: ImageData.data converts strings to numbers with ToNumber -->
<canvas id="c286" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_imageData_object_string() {
var canvas = document.getElementById('c286');
var ctx = canvas.getContext('2d');
var imgdata = ctx.getImageData(0, 0, 10, 10);
imgdata.data[0] = 100;
imgdata.data[0] = "110";
ok(imgdata.data[0] === 110, "imgdata.data[\""+(0)+"\"] === 110");
imgdata.data[0] = 100;
imgdata.data[0] = "0x78";
ok(imgdata.data[0] === 120, "imgdata.data[\""+(0)+"\"] === 120");
imgdata.data[0] = 100;
imgdata.data[0] = " +130e0 ";
ok(imgdata.data[0] === 130, "imgdata.data[\""+(0)+"\"] === 130");
}
</script>
<!-- [[[ test_2d.imageData.object.undefined.html ]]] -->
<p>Canvas test: 2d.imageData.object.undefined</p>
<!-- Testing: ImageData.data converts undefined to 0 -->
<canvas id="c287" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_imageData_object_undefined() {
var canvas = document.getElementById('c287');
var ctx = canvas.getContext('2d');
var imgdata = ctx.getImageData(0, 0, 10, 10);
imgdata.data[0] = 100;
imgdata.data[0] = undefined;
ok(imgdata.data[0] === 0, "imgdata.data[\""+(0)+"\"] === 0");
}
</script>
<!-- [[[ test_2d.imageData.put.alpha.html ]]] -->
<p>Canvas test: 2d.imageData.put.alpha</p>
<!-- Testing: putImageData() puts non-solid image data correctly -->
<canvas id="c288" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_imageData_put_alpha() {
var canvas = document.getElementById('c288');
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'rgba(0, 255, 0, 0.25)';
ctx.fillRect(0, 0, 100, 50)
var imgdata = ctx.getImageData(0, 0, 100, 50);
ctx.fillStyle = '#f00';
ctx.fillRect(0, 0, 100, 50)
ctx.putImageData(imgdata, 0, 0);
isPixel(ctx, 50,25, 0,255,0,64, 2);
}
</script>
<!-- [[[ test_2d.imageData.put.basic.html ]]] -->
<p>Canvas test: 2d.imageData.put.basic</p>
<!-- Testing: putImageData() puts image data from getImageData() onto the canvas -->
<canvas id="c289" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_imageData_put_basic() {
var canvas = document.getElementById('c289');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#0f0';
ctx.fillRect(0, 0, 100, 50)
var imgdata = ctx.getImageData(0, 0, 100, 50);
ctx.fillStyle = '#f00';
ctx.fillRect(0, 0, 100, 50)
ctx.putImageData(imgdata, 0, 0);
isPixel(ctx, 50,25, 0,255,0,255, 2);
}
</script>
<!-- [[[ test_2d.imageData.put.clip.html ]]] -->
<p>Canvas test: 2d.imageData.put.clip - bug 433397</p>
<!-- Testing: putImageData() is not affected by clipping regions -->
<canvas id="c290" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_imageData_put_clip() {
var canvas = document.getElementById('c290');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#0f0';
ctx.fillRect(0, 0, 100, 50)
var imgdata = ctx.getImageData(0, 0, 100, 50);
ctx.fillStyle = '#f00';
ctx.fillRect(0, 0, 100, 50)
ctx.beginPath();
ctx.rect(0, 0, 50, 50);
ctx.clip();
ctx.putImageData(imgdata, 0, 0);
isPixel(ctx, 25,25, 0,255,0,255, 2);
isPixel(ctx, 75,25, 0,255,0,255, 2);
}
</script>
<!-- [[[ test_2d.imageData.put.created.html ]]] -->
<p>Canvas test: 2d.imageData.put.created - bug 433004</p>
<!-- Testing: putImageData() puts image data from createImageData() onto the canvas -->
<canvas id="c291" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
// eslint-disable-next-line complexity
function test_2d_imageData_put_created() {
var canvas = document.getElementById('c291');
var ctx = canvas.getContext('2d');
var imgdata = ctx.createImageData(100, 50);
for (var i = 0; i < imgdata.data.length; i += 4) {
imgdata.data[i] = 0;
imgdata.data[i+1] = 255;
imgdata.data[i+2] = 0;
imgdata.data[i+3] = 255;
}
ctx.fillStyle = '#f00';
ctx.fillRect(0, 0, 100, 50)
ctx.putImageData(imgdata, 0, 0);
isPixel(ctx, 50,25, 0,255,0,255, 2);
}
</script>
<!-- [[[ test_2d.imageData.put.cross.html ]]] -->
<p>Canvas test: 2d.imageData.put.cross</p>
<!-- Testing: putImageData() accepts image data got from a different canvas -->
<canvas id="c292" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_imageData_put_cross() {
var canvas = document.getElementById('c292');
var ctx = canvas.getContext('2d');
var canvas2 = document.createElement('canvas');
var ctx2 = canvas2.getContext('2d');
ctx2.fillStyle = '#0f0';
ctx2.fillRect(0, 0, 100, 50)
var imgdata = ctx2.getImageData(0, 0, 100, 50);
ctx.fillStyle = '#f00';
ctx.fillRect(0, 0, 100, 50)
ctx.putImageData(imgdata, 0, 0);
isPixel(ctx, 50,25, 0,255,0,255, 2);
}
</script>
<!-- [[[ test_2d.imageData.put.dirty.negative.html ]]] -->
<p>Canvas test: 2d.imageData.put.dirty.negative</p>
<!-- Testing: putImageData() handles negative-sized dirty rectangles correctly -->
<canvas id="c293" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_imageData_put_dirty_negative() {
var canvas = document.getElementById('c293');
var ctx = canvas.getContext('2d');
var _thrown_outer = false;
try {
ctx.fillStyle = '#f00';
ctx.fillRect(0, 0, 100, 50)
ctx.fillStyle = '#0f0';
ctx.fillRect(0, 0, 20, 20)
var imgdata = ctx.getImageData(0, 0, 100, 50);
ctx.fillStyle = '#0f0';
ctx.fillRect(0, 0, 100, 50)
ctx.fillStyle = '#f00';
ctx.fillRect(40, 20, 20, 20)
ctx.putImageData(imgdata, 40, 20, 20, 20, -20, -20);
isPixel(ctx, 50,25, 0,255,0,255, 2);
isPixel(ctx, 35,25, 0,255,0,255, 2);
isPixel(ctx, 65,25, 0,255,0,255, 2);
isPixel(ctx, 50,15, 0,255,0,255, 2);
isPixel(ctx, 50,45, 0,255,0,255, 2);
} catch (e) {
_thrown_outer = true;
}
ok(!_thrown_outer, ctx.canvas.id + ' should not throw exception');
}
</script>
<!-- [[[ test_2d.imageData.put.dirty.outside.html ]]] -->
<p>Canvas test: 2d.imageData.put.dirty.outside</p>
<!-- Testing: putImageData() handles dirty rectangles outside the canvas correctly -->
<canvas id="c294" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_imageData_put_dirty_outside() {
var canvas = document.getElementById('c294');
var ctx = canvas.getContext('2d');
var _thrown_outer = false;
try {
ctx.fillStyle = '#f00';
ctx.fillRect(0, 0, 100, 50)
var imgdata = ctx.getImageData(0, 0, 100, 50);
ctx.fillStyle = '#0f0';
ctx.fillRect(0, 0, 100, 50)
ctx.putImageData(imgdata, 100, 20, 20, 20, -20, -20);
ctx.putImageData(imgdata, 200, 200, 0, 0, 100, 50);
ctx.putImageData(imgdata, 40, 20, -30, -20, 30, 20);
ctx.putImageData(imgdata, -30, 20, 0, 0, 30, 20);
isPixel(ctx, 50,25, 0,255,0,255, 2);
isPixel(ctx, 98,15, 0,255,0,255, 2);
isPixel(ctx, 98,25, 0,255,0,255, 2);
isPixel(ctx, 98,45, 0,255,0,255, 2);
isPixel(ctx, 1,5, 0,255,0,255, 2);
isPixel(ctx, 1,25, 0,255,0,255, 2);
isPixel(ctx, 1,45, 0,255,0,255, 2);
} catch (e) {
_thrown_outer = true;
}
ok(!_thrown_outer, ctx.canvas.id + ' should not throw exception');
}
</script>
<!-- [[[ test_2d.imageData.put.dirty.rect1.html ]]] -->
<p>Canvas test: 2d.imageData.put.dirty.rect1</p>
<!-- Testing: putImageData() only modifies areas inside the dirty rectangle, using width and height -->
<canvas id="c295" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_imageData_put_dirty_rect1() {
var canvas = document.getElementById('c295');
var ctx = canvas.getContext('2d');
var _thrown_outer = false;
try {
ctx.fillStyle = '#f00';
ctx.fillRect(0, 0, 100, 50)
ctx.fillStyle = '#0f0';
ctx.fillRect(0, 0, 20, 20)
var imgdata = ctx.getImageData(0, 0, 100, 50);
ctx.fillStyle = '#0f0';
ctx.fillRect(0, 0, 100, 50)
ctx.fillStyle = '#f00';
ctx.fillRect(40, 20, 20, 20)
ctx.putImageData(imgdata, 40, 20, 0, 0, 20, 20);
isPixel(ctx, 50,25, 0,255,0,255, 2);
isPixel(ctx, 35,25, 0,255,0,255, 2);
isPixel(ctx, 65,25, 0,255,0,255, 2);
isPixel(ctx, 50,15, 0,255,0,255, 2);
isPixel(ctx, 50,45, 0,255,0,255, 2);
} catch (e) {
_thrown_outer = true;
}
ok(!_thrown_outer, ctx.canvas.id + ' should not throw exception');
}
</script>
<!-- [[[ test_2d.imageData.put.dirty.rect2.html ]]] -->
<p>Canvas test: 2d.imageData.put.dirty.rect2</p>
<!-- Testing: putImageData() only modifies areas inside the dirty rectangle, using x and y -->
<canvas id="c296" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_imageData_put_dirty_rect2() {
var canvas = document.getElementById('c296');
var ctx = canvas.getContext('2d');
var _thrown_outer = false;
try {
ctx.fillStyle = '#f00';
ctx.fillRect(0, 0, 100, 50)
ctx.fillStyle = '#0f0';
ctx.fillRect(60, 30, 20, 20)
var imgdata = ctx.getImageData(0, 0, 100, 50);
ctx.fillStyle = '#0f0';
ctx.fillRect(0, 0, 100, 50)
ctx.fillStyle = '#f00';
ctx.fillRect(40, 20, 20, 20)
ctx.putImageData(imgdata, -20, -10, 60, 30, 20, 20);
isPixel(ctx, 50,25, 0,255,0,255, 2);
isPixel(ctx, 35,25, 0,255,0,255, 2);
isPixel(ctx, 65,25, 0,255,0,255, 2);
isPixel(ctx, 50,15, 0,255,0,255, 2);
isPixel(ctx, 50,45, 0,255,0,255, 2);
} catch (e) {
_thrown_outer = true;
}
ok(!_thrown_outer, ctx.canvas.id + ' should not throw exception');
}
</script>
<!-- [[[ test_2d.imageData.put.dirty.zero.html ]]] -->
<p>Canvas test: 2d.imageData.put.dirty.zero</p>
<!-- Testing: putImageData() with zero-sized dirty rectangle puts nothing -->
<canvas id="c297" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_imageData_put_dirty_zero() {
var canvas = document.getElementById('c297');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#f00';
ctx.fillRect(0, 0, 100, 50)
var imgdata = ctx.getImageData(0, 0, 100, 50);
ctx.fillStyle = '#0f0';
ctx.fillRect(0, 0, 100, 50)
ctx.putImageData(imgdata, 0, 0, 0, 0, 0, 0);
isPixel(ctx, 50,25, 0,255,0,255, 2);
}
</script>
<!-- [[[ test_2d.imageData.put.modified.html ]]] -->
<p>Canvas test: 2d.imageData.put.modified</p>
<!-- Testing: putImageData() puts modified image data correctly -->
<canvas id="c298" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function test_2d_imageData_put_modified() {
var canvas = document.getElementById('c298');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#0f0';
ctx.fillRect(0, 0, 100, 50)
ctx.fillStyle = '#f00';
ctx.fillRect(45, 20, 10, 10)
var imgdata = ctx.getImageData(45, 20, 10, 10);
for (var i = 0, len = imgdata.width*imgdata.height*4; i < len; i += 4)
{
imgdata.data[i] = 0;
imgdata.data[i+1] = 255;
}
ctx.putImageData(imgdata, 45, 20);
isPixel(ctx, 50,25, 0,255,0,255, 2);
}
</script>
<!-- [[[ test_2d.imageData.put.nonfinite.html ]]] -->
<p>Canvas test: 2d.imageData.put.nonfinite</p>
<!-- Testing: putImageData() throws NOT_SUPPORTED_ERR if arguments are not finite -->
<canvas id="c299" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
// eslint-disable-next-line complexity
function test_2d_imageData_put_nonfinite() {
var canvas = document.getElementById('c299');
var ctx = canvas.getContext('2d');
var imgdata = ctx.getImageData(0, 0, 10, 10);
var _thrown = undefined; try {
ctx.putImageData(imgdata, Infinity, 10);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.putImageData(imgdata, -Infinity, 10);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.putImageData(imgdata, NaN, 10);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.putImageData(imgdata, 10, Infinity);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.putImageData(imgdata, 10, -Infinity);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.putImageData(imgdata, 10, NaN);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.putImageData(imgdata, Infinity, Infinity);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.putImageData(imgdata, Infinity, 10, 10, 10, 10, 10);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.putImageData(imgdata, -Infinity, 10, 10, 10, 10, 10);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.putImageData(imgdata, NaN, 10, 10, 10, 10, 10);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.putImageData(imgdata, 10, Infinity, 10, 10, 10, 10);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.putImageData(imgdata, 10, -Infinity, 10, 10, 10, 10);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.putImageData(imgdata, 10, NaN, 10, 10, 10, 10);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.putImageData(imgdata, 10, 10, Infinity, 10, 10, 10);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError");
var _thrown = undefined; try {
ctx.putImageData(imgdata, 10, 10, -Infinity, 10, 10, 10);
} catch (e) { _thrown = e }; ok(_thrown && _thrown instanceof TypeError, "should throw TypeError"); | |