Skip to content

Commit

Permalink
Updated a canvas test to match current spec.
Browse files Browse the repository at this point in the history
  • Loading branch information
sideshowbarker committed Apr 30, 2014
1 parent 7b53231 commit 7ed0592
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
15 changes: 13 additions & 2 deletions 2dcontext/fill-and-stroke-styles/2d.pattern.repeat.null.html
Expand Up @@ -14,15 +14,26 @@ <h1>2d.pattern.repeat.null</h1>

<p class="output">Actual output:</p>
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>

<p class="output expectedtext">Expected output:<p><img src="/images/green-100x50.png" class="output expected" id="expected" alt="">
<ul id="d"></ul>
<script>
var t = async_test("");
_addTest(function(canvas, ctx) {

_assert_throws("SYNTAX_ERR", function() { ctx.createPattern(canvas, null); });
ctx.fillStyle = '#f00';
ctx.fillRect(0, 0, 100, 50);
var img = document.getElementById('green-1x1.png');
var pattern = ctx.createPattern(img, null);
ctx.fillStyle = pattern;
ctx.fillRect(0, 0, 200, 50);

_assertPixel(canvas, 1,1, 0,255,0,255, "1,1", "0,255,0,255");
_assertPixel(canvas, 98,1, 0,255,0,255, "98,1", "0,255,0,255");
_assertPixel(canvas, 1,48, 0,255,0,255, "1,48", "0,255,0,255");
_assertPixel(canvas, 98,48, 0,255,0,255, "98,48", "0,255,0,255");


});
</script>
<img src="/images/green-1x1.png" id="green-1x1.png" class="resource">

17 changes: 15 additions & 2 deletions 2dcontext/tools/tests2d.yaml
Expand Up @@ -2842,9 +2842,22 @@

- name: 2d.pattern.repeat.null
testing:
- 2d.pattern.unrecognised
- 2d.pattern.missing
images:
- green-1x1.png
code: |
@assert throws SYNTAX_ERR ctx.createPattern(canvas, null); @moz-todo
ctx.fillStyle = '#f00';
ctx.fillRect(0, 0, 100, 50);
var img = document.getElementById('green-1x1.png');
var pattern = ctx.createPattern(img, null);
ctx.fillStyle = pattern;
ctx.fillRect(0, 0, 200, 50);
@assert pixel 1,1 == 0,255,0,255;
@assert pixel 98,1 == 0,255,0,255;
@assert pixel 1,48 == 0,255,0,255;
@assert pixel 98,48 == 0,255,0,255;
expected: green

- name: 2d.pattern.repeat.undefined
testing:
Expand Down

0 comments on commit 7ed0592

Please sign in to comment.