summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/canvas/element/manual/fill-and-stroke-styles
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/html/canvas/element/manual/fill-and-stroke-styles')
-rw-r--r--testing/web-platform/tests/html/canvas/element/manual/fill-and-stroke-styles/2d.fillStyle.parse.current.notrendered.html31
-rw-r--r--testing/web-platform/tests/html/canvas/element/manual/fill-and-stroke-styles/canvas_colorsandstyles_createlineargradient_001.htm59
-rw-r--r--testing/web-platform/tests/html/canvas/element/manual/fill-and-stroke-styles/conic-gradient-expected.html22
-rw-r--r--testing/web-platform/tests/html/canvas/element/manual/fill-and-stroke-styles/conic-gradient-rotation-expected.html22
-rw-r--r--testing/web-platform/tests/html/canvas/element/manual/fill-and-stroke-styles/conic-gradient-rotation.html30
-rw-r--r--testing/web-platform/tests/html/canvas/element/manual/fill-and-stroke-styles/conic-gradient.html30
6 files changed, 194 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/canvas/element/manual/fill-and-stroke-styles/2d.fillStyle.parse.current.notrendered.html b/testing/web-platform/tests/html/canvas/element/manual/fill-and-stroke-styles/2d.fillStyle.parse.current.notrendered.html
new file mode 100644
index 0000000000..37701bacee
--- /dev/null
+++ b/testing/web-platform/tests/html/canvas/element/manual/fill-and-stroke-styles/2d.fillStyle.parse.current.notrendered.html
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<title>Canvas test: 2d.fillStyle.parse.current.notrendered</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/html/canvas/resources/canvas-tests.js"></script>
+<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css">
+<body class="show_output">
+
+<h1>2d.fillStyle.parse.current.basic</h1>
+<p class="desc">currentColor is computed from the canvas element</p>
+
+
+<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("currentColor is computed from the canvas element even when element is not rendered");
+_addTest(function(canvas, ctx) {
+
+canvas.setAttribute('style', 'color: #0f0;');
+canvas.style.display = 'none';
+canvas.offsetTop;
+ctx.fillStyle = 'currentColor';
+canvas.style.display = 'inline';
+ctx.fillRect(0, 0, 100, 50);
+_assertPixel(canvas, 50,25, 0,255,0,255);
+
+
+});
+</script>
diff --git a/testing/web-platform/tests/html/canvas/element/manual/fill-and-stroke-styles/canvas_colorsandstyles_createlineargradient_001.htm b/testing/web-platform/tests/html/canvas/element/manual/fill-and-stroke-styles/canvas_colorsandstyles_createlineargradient_001.htm
new file mode 100644
index 0000000000..5b77c98de7
--- /dev/null
+++ b/testing/web-platform/tests/html/canvas/element/manual/fill-and-stroke-styles/canvas_colorsandstyles_createlineargradient_001.htm
@@ -0,0 +1,59 @@
+<!doctype HTML>
+<html>
+ <head>
+ <title>HTML5 Canvas Test: createlinearGradient() with two points same</title>
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ <link rel="author" title="Microsoft" href="http://www.microsoft.com" />
+ <link rel="help" href="http://www.w3.org/TR/2dcontext/#dom-context-2d-createlineargradient" />
+ <meta name="assert" content="If the two points in a linear gradient have identical x,y coordinates, the canvas must paint nothing." />
+ <script type="text/javascript">
+ async_test(function(t) {
+ window.addEventListener("load", t.step_func_done(function runTest() {
+ var canvas = document.getElementById("canvas1");
+ var ctx = canvas.getContext("2d");
+ var width = canvas.width;
+ var height = canvas.height;
+
+ // Start by drawing a left to right, green-to-blue linear gradient.
+ var lingrad = ctx.createLinearGradient(0, 50, 100, 50);
+ lingrad.addColorStop(0, "rgba(0, 255, 0, 1.0)");
+ lingrad.addColorStop(1, "rgba(0, 0, 255, 1.0)");
+ ctx.fillStyle = lingrad;
+ ctx.fillRect(0, 0, 100, 50);
+
+ // Get the current state of the canvas
+ var initial = ctx.getImageData(0, 0, width, height);
+
+ // Nothing must be drawn if the two points in the linear gradient are the same.
+ lingrad = ctx.createLinearGradient(100, 100, 100, 100);
+ lingrad.addColorStop(0, "rgba(255, 0, 0, 1.0)");
+ lingrad.addColorStop(1, "rgba(255, 0, 0, 1.0)");
+ ctx.fillStyle = lingrad;
+ ctx.fillRect(0, 0, 300, 150);
+
+ // Check that nothing is drawn.
+ var after = ctx.getImageData(0, 0, width, height);
+
+ // Asserts
+ assert_equals(initial.width, after.width, "widths are equal");
+ assert_equals(initial.height, after.height, "heights are equal");
+ assert_array_equals(initial.data, after.data, "data are equal");
+
+ for (var i = 0; i < after.data.length; i += 4) {
+ var r = after.data[i];
+ var g = after.data[i+1];
+ var b = after.data[i+2];
+ var a = after.data[i+3];
+ assert_false(r == 0xFF && g == 0 && b == 0 && a == 0xFF, "no red");
+ }
+ }));
+ }, "linear gradient from point to self draws nothing");
+ </script>
+ </head>
+ <body>
+ <p>Description: If the two points in a linear gradient have identical x,y coordinates, the canvas must paint nothing.</p>
+ <p>Test passes if there is one left-to-right, green-to-blue linear gradient seen on the page and no red is seen on the page.</p>
+ <canvas id="canvas1" width="300" height="150">Browser does not support HTML5 Canvas.</canvas>
+ </body>
+</html>
diff --git a/testing/web-platform/tests/html/canvas/element/manual/fill-and-stroke-styles/conic-gradient-expected.html b/testing/web-platform/tests/html/canvas/element/manual/fill-and-stroke-styles/conic-gradient-expected.html
new file mode 100644
index 0000000000..f347abc9d3
--- /dev/null
+++ b/testing/web-platform/tests/html/canvas/element/manual/fill-and-stroke-styles/conic-gradient-expected.html
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title></title>
+ <style type="text/css">
+ div {
+ width: 300px;
+ height: 150px;
+ background: conic-gradient(
+ from 90deg at 100px 50px,
+ red 0.2turn,
+ orange 0.2turn 0.4turn,
+ yellow 0.4turn 0.6turn,
+ green 0.6turn 0.8turn,
+ blue 0.8turn 1.0turn
+ );
+ </style>
+</head>
+<body>
+ <div id="output"></div>
+</body>
+</html> \ No newline at end of file
diff --git a/testing/web-platform/tests/html/canvas/element/manual/fill-and-stroke-styles/conic-gradient-rotation-expected.html b/testing/web-platform/tests/html/canvas/element/manual/fill-and-stroke-styles/conic-gradient-rotation-expected.html
new file mode 100644
index 0000000000..68d750f462
--- /dev/null
+++ b/testing/web-platform/tests/html/canvas/element/manual/fill-and-stroke-styles/conic-gradient-rotation-expected.html
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title></title>
+ <style type="text/css">
+ div {
+ width: 300px;
+ height: 150px;
+ background: conic-gradient(
+ from 180deg at 100px 50px,
+ red 0.2turn,
+ orange 0.2turn 0.4turn,
+ yellow 0.4turn 0.6turn,
+ green 0.6turn 0.8turn,
+ blue 0.8turn 1.0turn
+ );
+ </style>
+</head>
+<body>
+ <div id="output"></div>
+</body>
+</html>
diff --git a/testing/web-platform/tests/html/canvas/element/manual/fill-and-stroke-styles/conic-gradient-rotation.html b/testing/web-platform/tests/html/canvas/element/manual/fill-and-stroke-styles/conic-gradient-rotation.html
new file mode 100644
index 0000000000..e8b213b3d8
--- /dev/null
+++ b/testing/web-platform/tests/html/canvas/element/manual/fill-and-stroke-styles/conic-gradient-rotation.html
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Conic gradient</title>
+ <link rel="match" href="conic-gradient-rotation-expected.html"/>
+</head>
+<body>
+ <canvas id="c"></canvas>
+ <script type="text/javascript">
+ const canvas = document.getElementById('c');
+ const ctx = canvas.getContext('2d');
+
+ const grad = ctx.createConicGradient(2.5*Math.PI, 100, 50);
+
+ grad.addColorStop(0, "red");
+ grad.addColorStop(0.2, "red");
+ grad.addColorStop(0.2, "orange");
+ grad.addColorStop(0.4, "orange");
+ grad.addColorStop(0.4, "yellow");
+ grad.addColorStop(0.6, "yellow");
+ grad.addColorStop(0.6, "green");
+ grad.addColorStop(0.8, "green");
+ grad.addColorStop(0.8, "blue");
+
+ ctx.fillStyle = grad;
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
+ </script>
+
+</body>
+</html> \ No newline at end of file
diff --git a/testing/web-platform/tests/html/canvas/element/manual/fill-and-stroke-styles/conic-gradient.html b/testing/web-platform/tests/html/canvas/element/manual/fill-and-stroke-styles/conic-gradient.html
new file mode 100644
index 0000000000..73fcf6c23e
--- /dev/null
+++ b/testing/web-platform/tests/html/canvas/element/manual/fill-and-stroke-styles/conic-gradient.html
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Conic gradient</title>
+ <link rel="match" href="conic-gradient-expected.html"/>
+</head>
+<body>
+ <canvas id="c"></canvas>
+ <script type="text/javascript">
+ const canvas = document.getElementById('c');
+ const ctx = canvas.getContext('2d');
+
+ const grad = ctx.createConicGradient(0, 100, 50);
+
+ grad.addColorStop(0, "red");
+ grad.addColorStop(0.2, "red");
+ grad.addColorStop(0.2, "orange");
+ grad.addColorStop(0.4, "orange");
+ grad.addColorStop(0.4, "yellow");
+ grad.addColorStop(0.6, "yellow");
+ grad.addColorStop(0.6, "green");
+ grad.addColorStop(0.8, "green");
+ grad.addColorStop(0.8, "blue");
+
+ ctx.fillStyle = grad;
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
+ </script>
+
+</body>
+</html> \ No newline at end of file