Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(476)

Side by Side Diff: third_party/WebKit/LayoutTests/fast/canvas/canvas-pattern-modify.html

Issue 2689243002: Use testharness.js instead of js-test.js in LayoutTests/fast/canvas tests. (Closed)
Patch Set: Addressing comments Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <script src="../../resources/js-test.js"></script> 1 <script src="../../resources/testharness.js"></script>
2 <script src="canvas-pattern-modify.js"></script> 2 <script src="../../resources/testharnessreport.js"></script>
3 <script>
4 // Based on http://philip.html5.org/tests/canvas/suite/tests/2d.pattern.modify.c anvas1.html
5
6 function pixelShouldBe(ctx, x, y, color) {
7 assert_array_equals(ctx.getImageData(x, y, 1, 1).data, color);
8 }
9
10 function createCanvasImage(width, height, color) {
11 var c = document.createElement("canvas");
12 c.width = width;
13 c.height = height;
14 var context = c.getContext("2d");
15 context.fillStyle = color;
16 context.fillRect(0, 0, width, height);
17 return c;
18 }
19
20 test(function(t) {
21 var canvas = createCanvasImage(100, 50, '#fff');
22 var ctx = canvas.getContext('2d');
23
24 var patternCanvas = createCanvasImage(100, 50, '#0f0');
25 var pattern = ctx.createPattern(patternCanvas, 'no-repeat');
26
27 // Modify the original canvas after we create a pattern.
28 var patternCtx = patternCanvas.getContext('2d');
29 patternCtx.fillStyle = '#f00';
30 patternCtx.fillRect(0, 0, 100, 50);
31
32 ctx.fillStyle = pattern;
33 ctx.fillRect(0, 0, 100, 50);
34
35 pixelShouldBe(ctx, 1, 1, [0, 255, 0, 255]);
36 pixelShouldBe(ctx, 98, 1, [0, 255, 0, 255]);
37 pixelShouldBe(ctx, 1, 48, [0, 255, 0, 255]);
38 pixelShouldBe(ctx, 98, 48, [0, 255, 0, 255]);
39 }, "This test checks if pattern changes after the source canvas is modified. See https://bugs.webkit.org/show_bug.cgi?id=20578 .");
40 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698