зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1835700
[wpt PR 40292] - Raise DOM exceptions if layer API is incorrectly used., a=testonly
Automatic update from web-platform-tests Raise DOM exceptions if layer API is incorrectly used. It's invalid to call `endLayer()` without a matching `beginLayer()`. Likewise, calling `restore()` after `beginLayer()` isn't allowed. Calling `save()` without a matching `restore()` outside of layers however is allows to preserve existing functionality. We want to be stricter with usage of the new layer API, at least at first, because as soon as we start allowing degenerate API uses, Hyrum's law will make sure we'll have to support these forever. Bug: 1396372 Fixed: 1237275, 1403977 Change-Id: I76e83217fafe60248f8e4ae81ceafb1215dda9bc Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4572867 Commit-Queue: Jean-Philippe Gravel <jpgravel@chromium.org> Reviewed-by: Justin Novosad <junov@chromium.org> Cr-Commit-Position: refs/heads/main@{#1158153} -- wpt-commits: a44ca1286f13670ca201d5a10588848e6fcb6a61 wpt-pr: 40292
This commit is contained in:
Родитель
aab137b1e6
Коммит
e466f3f0f4
|
@ -0,0 +1,14 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
|
||||
<title>Canvas test: 2d.layer.cross-layer-paths</title>
|
||||
<h1>2d.layer.cross-layer-paths</h1>
|
||||
<p class="desc">Checks that path defined in a layer is usable outside.</p>
|
||||
<canvas id="canvas" width="100" height="50">
|
||||
<p class="fallback">FAIL (fallback content)</p>
|
||||
</canvas>
|
||||
<script>
|
||||
const canvas = document.getElementById("canvas");
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
ctx.moveTo(50, 0); ctx.lineTo(50, 100); ctx.stroke();
|
||||
</script>
|
|
@ -0,0 +1,20 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
|
||||
<link rel="match" href="2d.layer.cross-layer-paths-expected.html">
|
||||
<title>Canvas test: 2d.layer.cross-layer-paths</title>
|
||||
<h1>2d.layer.cross-layer-paths</h1>
|
||||
<p class="desc">Checks that path defined in a layer is usable outside.</p>
|
||||
<canvas id="canvas" width="100" height="50">
|
||||
<p class="fallback">FAIL (fallback content)</p>
|
||||
</canvas>
|
||||
<script>
|
||||
const canvas = document.getElementById("canvas");
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
ctx.beginLayer();
|
||||
ctx.translate(50, 0);
|
||||
ctx.moveTo(0, 0);
|
||||
ctx.endLayer();
|
||||
ctx.lineTo(50, 100);
|
||||
ctx.stroke();
|
||||
</script>
|
|
@ -1,21 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
|
||||
<title>Canvas test: 2d.layer.endlayer.alone</title>
|
||||
<h1>2d.layer.endlayer.alone</h1>
|
||||
<p class="desc">A test to make sure a single endLayer with no beginLayer is a no-op.</p>
|
||||
<canvas id="canvas" width="200" height="200">
|
||||
<p class="fallback">FAIL (fallback content)</p>
|
||||
</canvas>
|
||||
<script>
|
||||
const canvas = document.getElementById("canvas");
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
ctx.fillStyle = 'rgba(0, 0, 255, 1)';
|
||||
ctx.fillRect(60, 60, 75, 50);
|
||||
ctx.globalAlpha = 0.5;
|
||||
|
||||
ctx.fillStyle = 'rgba(225, 0, 0, 1)';
|
||||
ctx.fillRect(50, 50, 75, 50);
|
||||
ctx.fillStyle = 'rgba(0, 255, 0, 1)';
|
||||
ctx.fillRect(70, 70, 75, 50);
|
||||
</script>
|
|
@ -1,24 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
|
||||
<link rel="match" href="2d.layer.endlayer.alone-expected.html">
|
||||
<title>Canvas test: 2d.layer.endlayer.alone</title>
|
||||
<h1>2d.layer.endlayer.alone</h1>
|
||||
<p class="desc">A test to make sure a single endLayer with no beginLayer is a no-op.</p>
|
||||
<canvas id="canvas" width="200" height="200">
|
||||
<p class="fallback">FAIL (fallback content)</p>
|
||||
</canvas>
|
||||
<script>
|
||||
const canvas = document.getElementById("canvas");
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
ctx.fillStyle = 'rgba(0, 0, 255, 1)';
|
||||
ctx.fillRect(60, 60, 75, 50);
|
||||
ctx.globalAlpha = 0.5;
|
||||
|
||||
ctx.fillStyle = 'rgba(225, 0, 0, 1)';
|
||||
ctx.fillRect(50, 50, 75, 50);
|
||||
ctx.fillStyle = 'rgba(0, 255, 0, 1)';
|
||||
ctx.fillRect(70, 70, 75, 50);
|
||||
|
||||
ctx.endLayer();
|
||||
</script>
|
|
@ -1,24 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
|
||||
<title>Canvas test: 2d.layer.endlayer.unmatched</title>
|
||||
<h1>2d.layer.endlayer.unmatched</h1>
|
||||
<p class="desc">A test to make sure an unmatched endLayer is a no-op and has no effect on the code following it.</p>
|
||||
<canvas id="canvas" width="200" height="200">
|
||||
<p class="fallback">FAIL (fallback content)</p>
|
||||
</canvas>
|
||||
<script>
|
||||
const canvas = document.getElementById("canvas");
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
ctx.fillStyle = 'rgba(0, 0, 255, 1)';
|
||||
ctx.fillRect(60, 60, 75, 50);
|
||||
|
||||
ctx.globalAlpha = 0.5;
|
||||
|
||||
ctx.beginLayer();
|
||||
ctx.fillStyle = 'rgba(225, 0, 0, 1)';
|
||||
ctx.fillRect(50, 50, 75, 50);
|
||||
ctx.fillStyle = 'rgba(0, 255, 0, 1)';
|
||||
ctx.fillRect(70, 70, 75, 50);
|
||||
ctx.endLayer();
|
||||
</script>
|
|
@ -1,28 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
|
||||
<link rel="match" href="2d.layer.endlayer.unmatched-expected.html">
|
||||
<title>Canvas test: 2d.layer.endlayer.unmatched</title>
|
||||
<h1>2d.layer.endlayer.unmatched</h1>
|
||||
<p class="desc">A test to make sure an unmatched endLayer is a no-op and has no effect on the code following it.</p>
|
||||
<canvas id="canvas" width="200" height="200">
|
||||
<p class="fallback">FAIL (fallback content)</p>
|
||||
</canvas>
|
||||
<script>
|
||||
const canvas = document.getElementById("canvas");
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
ctx.fillStyle = 'rgba(0, 0, 255, 1)';
|
||||
ctx.fillRect(60, 60, 75, 50);
|
||||
|
||||
ctx.globalAlpha = 0.5;
|
||||
|
||||
// This endlayer call should no-op.
|
||||
ctx.endLayer();
|
||||
|
||||
ctx.beginLayer();
|
||||
ctx.fillStyle = 'rgba(225, 0, 0, 1)';
|
||||
ctx.fillRect(50, 50, 75, 50);
|
||||
ctx.fillStyle = 'rgba(0, 255, 0, 1)';
|
||||
ctx.fillRect(70, 70, 75, 50);
|
||||
ctx.endLayer();
|
||||
</script>
|
|
@ -0,0 +1,30 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
|
||||
<title>Canvas test: 2d.layer.invalid-calls.beginLayer-reset-endLayer</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.layer.invalid-calls.beginLayer-reset-endLayer</h1>
|
||||
<p class="desc">Raises exception on beginLayer() + reset() + endLayer().</p>
|
||||
|
||||
|
||||
<p class="output">Actual output:</p>
|
||||
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
|
||||
|
||||
<ul id="d"></ul>
|
||||
<script>
|
||||
var t = async_test("Raises exception on beginLayer() + reset() + endLayer().");
|
||||
_addTest(function(canvas, ctx) {
|
||||
|
||||
assert_throws_dom("INVALID_STATE_ERR", function() {
|
||||
ctx.beginLayer();
|
||||
ctx.reset();
|
||||
ctx.endLayer();
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
|
||||
<title>Canvas test: 2d.layer.invalid-calls.beginLayer-restore</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.layer.invalid-calls.beginLayer-restore</h1>
|
||||
<p class="desc">Raises exception on beginLayer() + restore().</p>
|
||||
|
||||
|
||||
<p class="output">Actual output:</p>
|
||||
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
|
||||
|
||||
<ul id="d"></ul>
|
||||
<script>
|
||||
var t = async_test("Raises exception on beginLayer() + restore().");
|
||||
_addTest(function(canvas, ctx) {
|
||||
|
||||
assert_throws_dom("INVALID_STATE_ERR", function() {
|
||||
ctx.beginLayer();
|
||||
ctx.restore();
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
|
||||
<title>Canvas test: 2d.layer.invalid-calls.beginLayer-save-endLayer</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.layer.invalid-calls.beginLayer-save-endLayer</h1>
|
||||
<p class="desc">Raises exception on beginLayer() + save() + endLayer().</p>
|
||||
|
||||
|
||||
<p class="output">Actual output:</p>
|
||||
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
|
||||
|
||||
<ul id="d"></ul>
|
||||
<script>
|
||||
var t = async_test("Raises exception on beginLayer() + save() + endLayer().");
|
||||
_addTest(function(canvas, ctx) {
|
||||
|
||||
assert_throws_dom("INVALID_STATE_ERR", function() {
|
||||
ctx.beginLayer();
|
||||
ctx.save();
|
||||
ctx.endLayer();
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
|
||||
<title>Canvas test: 2d.layer.invalid-calls.endLayer</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.layer.invalid-calls.endLayer</h1>
|
||||
<p class="desc">Raises exception on lone endLayer calls.</p>
|
||||
|
||||
|
||||
<p class="output">Actual output:</p>
|
||||
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
|
||||
|
||||
<ul id="d"></ul>
|
||||
<script>
|
||||
var t = async_test("Raises exception on lone endLayer calls.");
|
||||
_addTest(function(canvas, ctx) {
|
||||
|
||||
assert_throws_dom("INVALID_STATE_ERR", function() {
|
||||
ctx.endLayer();
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
|
||||
<title>Canvas test: 2d.layer.invalid-calls.save-beginLayer-restore</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.layer.invalid-calls.save-beginLayer-restore</h1>
|
||||
<p class="desc">Raises exception on save() + beginLayer() + restore().</p>
|
||||
|
||||
|
||||
<p class="output">Actual output:</p>
|
||||
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
|
||||
|
||||
<ul id="d"></ul>
|
||||
<script>
|
||||
var t = async_test("Raises exception on save() + beginLayer() + restore().");
|
||||
_addTest(function(canvas, ctx) {
|
||||
|
||||
assert_throws_dom("INVALID_STATE_ERR", function() {
|
||||
ctx.save();
|
||||
ctx.beginLayer();
|
||||
ctx.restore();
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
|
||||
<title>Canvas test: 2d.layer.invalid-calls.save-endLayer</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.layer.invalid-calls.save-endLayer</h1>
|
||||
<p class="desc">Raises exception on save() + endLayer().</p>
|
||||
|
||||
|
||||
<p class="output">Actual output:</p>
|
||||
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
|
||||
|
||||
<ul id="d"></ul>
|
||||
<script>
|
||||
var t = async_test("Raises exception on save() + endLayer().");
|
||||
_addTest(function(canvas, ctx) {
|
||||
|
||||
assert_throws_dom("INVALID_STATE_ERR", function() {
|
||||
ctx.save();
|
||||
ctx.endLayer();
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
|
||||
<title>Canvas test: 2d.layer.reset</title>
|
||||
<h1>2d.layer.reset</h1>
|
||||
<p class="desc">Checks that reset discards any pending layers.</p>
|
||||
<canvas id="canvas" width="100" height="50">
|
||||
<p class="fallback">FAIL (fallback content)</p>
|
||||
</canvas>
|
||||
<script>
|
||||
const canvas = document.getElementById("canvas");
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
ctx.fillRect(10, 10, 75, 50);
|
||||
</script>
|
|
@ -0,0 +1,33 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
|
||||
<link rel="match" href="2d.layer.reset-expected.html">
|
||||
<title>Canvas test: 2d.layer.reset</title>
|
||||
<h1>2d.layer.reset</h1>
|
||||
<p class="desc">Checks that reset discards any pending layers.</p>
|
||||
<canvas id="canvas" width="100" height="50">
|
||||
<p class="fallback">FAIL (fallback content)</p>
|
||||
</canvas>
|
||||
<script>
|
||||
const canvas = document.getElementById("canvas");
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
// Global states:
|
||||
ctx.globalAlpha = 0.3;
|
||||
ctx.globalCompositeOperation = 'source-in';
|
||||
ctx.shadowOffsetX = -3;
|
||||
ctx.shadowOffsetY = 3;
|
||||
ctx.shadowColor = 'rgba(0, 30, 0, 0.3)';
|
||||
|
||||
ctx.beginLayer({filter: 'dropShadow', dx: -3, dy: 3});
|
||||
|
||||
// Layer states:
|
||||
ctx.globalAlpha = 0.6;
|
||||
ctx.globalCompositeOperation = 'source-in';
|
||||
ctx.shadowOffsetX = -6;
|
||||
ctx.shadowOffsetY = 6;
|
||||
ctx.shadowColor = 'rgba(0, 60, 0, 0.6)';
|
||||
|
||||
ctx.reset();
|
||||
|
||||
ctx.fillRect(10, 10, 75, 50);
|
||||
</script>
|
|
@ -0,0 +1,28 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
|
||||
<title>Canvas test: 2d.layer.unclosed-nested</title>
|
||||
<h1>2d.layer.unclosed-nested</h1>
|
||||
<p class="desc">Check that layers are rendered even if not closed.</p>
|
||||
<canvas id="canvas" width="200" height="200">
|
||||
<p class="fallback">FAIL (fallback content)</p>
|
||||
</canvas>
|
||||
<script>
|
||||
const canvas = document.getElementById("canvas");
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
const canvas1 = document.createElement('canvas');
|
||||
const ctx1 = canvas1.getContext('2d');
|
||||
ctx1.fillStyle = 'rgba(0,255,0,1)';
|
||||
ctx1.fillRect(70,70,75,50);
|
||||
|
||||
const canvas2 = document.createElement('canvas');
|
||||
const ctx2 = canvas2.getContext('2d');
|
||||
ctx2.fillStyle = 'rgba(225,0,0,1)';
|
||||
ctx2.fillRect(50,50,75,50);
|
||||
ctx2.drawImage(canvas1, 0, 0);
|
||||
|
||||
ctx.fillStyle = 'rgba(0,0,255,1)';
|
||||
ctx.fillRect(60,60,75,50);
|
||||
ctx.globalAlpha = 0.5;
|
||||
ctx.drawImage(canvas2, 0, 0);
|
||||
</script>
|
|
@ -1,8 +1,9 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
|
||||
<title>Canvas test: 2d.layer.endlayer.unmatched</title>
|
||||
<h1>2d.layer.endlayer.unmatched</h1>
|
||||
<p class="desc">A test to make sure an unmatched endLayer is a no-op and has no effect on the code following it.</p>
|
||||
<link rel="match" href="2d.layer.unclosed-nested-expected.html">
|
||||
<title>Canvas test: 2d.layer.unclosed-nested</title>
|
||||
<h1>2d.layer.unclosed-nested</h1>
|
||||
<p class="desc">Check that layers are rendered even if not closed.</p>
|
||||
<canvas id="canvas" width="200" height="200">
|
||||
<p class="fallback">FAIL (fallback content)</p>
|
||||
</canvas>
|
||||
|
@ -12,13 +13,16 @@
|
|||
|
||||
ctx.fillStyle = 'rgba(0, 0, 255, 1)';
|
||||
ctx.fillRect(60, 60, 75, 50);
|
||||
|
||||
ctx.globalAlpha = 0.5;
|
||||
|
||||
ctx.beginLayer();
|
||||
ctx.fillStyle = 'rgba(225, 0, 0, 1)';
|
||||
ctx.fillRect(50, 50, 75, 50);
|
||||
|
||||
ctx.beginLayer();
|
||||
ctx.fillStyle = 'rgba(0, 255, 0, 1)';
|
||||
ctx.fillRect(70, 70, 75, 50);
|
||||
|
||||
ctx.endLayer();
|
||||
// Missing ctx.endLayer() here.
|
||||
</script>
|
|
@ -0,0 +1,27 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
|
||||
<title>Canvas test: 2d.layer.valid-calls.beginLayer-endLayer</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.layer.valid-calls.beginLayer-endLayer</h1>
|
||||
<p class="desc">No exception raised on beginLayer() + endLayer().</p>
|
||||
|
||||
|
||||
<p class="output">Actual output:</p>
|
||||
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
|
||||
|
||||
<ul id="d"></ul>
|
||||
<script>
|
||||
var t = async_test("No exception raised on beginLayer() + endLayer().");
|
||||
_addTest(function(canvas, ctx) {
|
||||
|
||||
ctx.beginLayer();
|
||||
ctx.save();
|
||||
|
||||
});
|
||||
</script>
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
|
||||
<title>Canvas test: 2d.layer.valid-calls.beginLayer-save</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.layer.valid-calls.beginLayer-save</h1>
|
||||
<p class="desc">No exception raised on beginLayer() + save().</p>
|
||||
|
||||
|
||||
<p class="output">Actual output:</p>
|
||||
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
|
||||
|
||||
<ul id="d"></ul>
|
||||
<script>
|
||||
var t = async_test("No exception raised on beginLayer() + save().");
|
||||
_addTest(function(canvas, ctx) {
|
||||
|
||||
ctx.beginLayer();
|
||||
ctx.save();
|
||||
|
||||
});
|
||||
</script>
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
|
||||
<title>Canvas test: 2d.layer.valid-calls.beginLayer</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.layer.valid-calls.beginLayer</h1>
|
||||
<p class="desc">No exception raised on lone beginLayer() calls.</p>
|
||||
|
||||
|
||||
<p class="output">Actual output:</p>
|
||||
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
|
||||
|
||||
<ul id="d"></ul>
|
||||
<script>
|
||||
var t = async_test("No exception raised on lone beginLayer() calls.");
|
||||
_addTest(function(canvas, ctx) {
|
||||
|
||||
ctx.beginLayer();
|
||||
|
||||
});
|
||||
</script>
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
|
||||
<title>Canvas test: 2d.layer.valid-calls.restore</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.layer.valid-calls.restore</h1>
|
||||
<p class="desc">No exception raised on lone restore() calls.</p>
|
||||
|
||||
|
||||
<p class="output">Actual output:</p>
|
||||
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
|
||||
|
||||
<ul id="d"></ul>
|
||||
<script>
|
||||
var t = async_test("No exception raised on lone restore() calls.");
|
||||
_addTest(function(canvas, ctx) {
|
||||
|
||||
ctx.restore();
|
||||
|
||||
});
|
||||
</script>
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
|
||||
<title>Canvas test: 2d.layer.valid-calls.save-beginLayer</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.layer.valid-calls.save-beginLayer</h1>
|
||||
<p class="desc">No exception raised on save() + beginLayer().</p>
|
||||
|
||||
|
||||
<p class="output">Actual output:</p>
|
||||
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
|
||||
|
||||
<ul id="d"></ul>
|
||||
<script>
|
||||
var t = async_test("No exception raised on save() + beginLayer().");
|
||||
_addTest(function(canvas, ctx) {
|
||||
|
||||
ctx.save();
|
||||
ctx.beginLayer();
|
||||
|
||||
});
|
||||
</script>
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
|
||||
<title>Canvas test: 2d.layer.valid-calls.save</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.layer.valid-calls.save</h1>
|
||||
<p class="desc">No exception raised on lone save() calls.</p>
|
||||
|
||||
|
||||
<p class="output">Actual output:</p>
|
||||
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
|
||||
|
||||
<ul id="d"></ul>
|
||||
<script>
|
||||
var t = async_test("No exception raised on lone save() calls.");
|
||||
_addTest(function(canvas, ctx) {
|
||||
|
||||
ctx.save();
|
||||
|
||||
});
|
||||
</script>
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
|
||||
<title>Canvas test: 2d.layer.valid-calls.save_reset_restore</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.layer.valid-calls.save_reset_restore</h1>
|
||||
<p class="desc">No exception raised on save() + reset() + restore().</p>
|
||||
|
||||
|
||||
<p class="output">Actual output:</p>
|
||||
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
|
||||
|
||||
<ul id="d"></ul>
|
||||
<script>
|
||||
var t = async_test("No exception raised on save() + reset() + restore().");
|
||||
_addTest(function(canvas, ctx) {
|
||||
|
||||
ctx.save();
|
||||
ctx.reset();
|
||||
ctx.restore();
|
||||
|
||||
});
|
||||
</script>
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
|
||||
<title>Canvas test: 2d.layer.valid-calls.save_restore</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.layer.valid-calls.save_restore</h1>
|
||||
<p class="desc">No exception raised on save() + restore().</p>
|
||||
|
||||
|
||||
<p class="output">Actual output:</p>
|
||||
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
|
||||
|
||||
<ul id="d"></ul>
|
||||
<script>
|
||||
var t = async_test("No exception raised on save() + restore().");
|
||||
_addTest(function(canvas, ctx) {
|
||||
|
||||
ctx.save();
|
||||
ctx.restore();
|
||||
|
||||
});
|
||||
</script>
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
|
||||
<title>Canvas test: 2d.layer.cross-layer-paths</title>
|
||||
<h1>2d.layer.cross-layer-paths</h1>
|
||||
<p class="desc">Checks that path defined in a layer is usable outside.</p>
|
||||
<canvas id="canvas" width="100" height="50">
|
||||
<p class="fallback">FAIL (fallback content)</p>
|
||||
</canvas>
|
||||
<script>
|
||||
const canvas = document.getElementById("canvas");
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
ctx.moveTo(50, 0); ctx.lineTo(50, 100); ctx.stroke();
|
||||
</script>
|
|
@ -0,0 +1,23 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
|
||||
<link rel="match" href="2d.layer.cross-layer-paths-expected.html">
|
||||
<title>Canvas test: 2d.layer.cross-layer-paths</title>
|
||||
<h1>2d.layer.cross-layer-paths</h1>
|
||||
<p class="desc">Checks that path defined in a layer is usable outside.</p>
|
||||
<canvas id="canvas" width="100" height="50">
|
||||
<p class="fallback">FAIL (fallback content)</p>
|
||||
</canvas>
|
||||
<script>
|
||||
const canvas = new OffscreenCanvas(100, 50);
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
ctx.beginLayer();
|
||||
ctx.translate(50, 0);
|
||||
ctx.moveTo(0, 0);
|
||||
ctx.endLayer();
|
||||
ctx.lineTo(50, 100);
|
||||
ctx.stroke();
|
||||
|
||||
const outputCanvas = document.getElementById("canvas");
|
||||
outputCanvas.getContext('2d').drawImage(canvas, 0, 0);
|
||||
</script>
|
|
@ -1,32 +1,24 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
|
||||
<html class="reftest-wait">
|
||||
<link rel="match" href="2d.layer.endlayer.unmatched-expected.html">
|
||||
<title>Canvas test: 2d.layer.endlayer.unmatched</title>
|
||||
<h1>2d.layer.endlayer.unmatched</h1>
|
||||
<p class="desc">A test to make sure an unmatched endLayer is a no-op and has no effect on the code following it.</p>
|
||||
<canvas id="canvas" width="200" height="200">
|
||||
<link rel="match" href="2d.layer.cross-layer-paths-expected.html">
|
||||
<title>Canvas test: 2d.layer.cross-layer-paths</title>
|
||||
<h1>2d.layer.cross-layer-paths</h1>
|
||||
<p class="desc">Checks that path defined in a layer is usable outside.</p>
|
||||
<canvas id="canvas" width="100" height="50">
|
||||
<p class="fallback">FAIL (fallback content)</p>
|
||||
</canvas>
|
||||
<script id='myWorker' type='text/worker'>
|
||||
self.onmessage = function(e) {
|
||||
const canvas = new OffscreenCanvas(200, 200);
|
||||
const canvas = new OffscreenCanvas(100, 50);
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
ctx.fillStyle = 'rgba(0, 0, 255, 1)';
|
||||
ctx.fillRect(60, 60, 75, 50);
|
||||
|
||||
ctx.globalAlpha = 0.5;
|
||||
|
||||
// This endlayer call should no-op.
|
||||
ctx.endLayer();
|
||||
|
||||
ctx.beginLayer();
|
||||
ctx.fillStyle = 'rgba(225, 0, 0, 1)';
|
||||
ctx.fillRect(50, 50, 75, 50);
|
||||
ctx.fillStyle = 'rgba(0, 255, 0, 1)';
|
||||
ctx.fillRect(70, 70, 75, 50);
|
||||
ctx.translate(50, 0);
|
||||
ctx.moveTo(0, 0);
|
||||
ctx.endLayer();
|
||||
ctx.lineTo(50, 100);
|
||||
ctx.stroke();
|
||||
|
||||
const bitmap = canvas.transferToImageBitmap();
|
||||
self.postMessage(bitmap, bitmap);
|
|
@ -1,21 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
|
||||
<title>Canvas test: 2d.layer.endlayer.alone</title>
|
||||
<h1>2d.layer.endlayer.alone</h1>
|
||||
<p class="desc">A test to make sure a single endLayer with no beginLayer is a no-op.</p>
|
||||
<canvas id="canvas" width="200" height="200">
|
||||
<p class="fallback">FAIL (fallback content)</p>
|
||||
</canvas>
|
||||
<script>
|
||||
const canvas = document.getElementById("canvas");
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
ctx.fillStyle = 'rgba(0, 0, 255, 1)';
|
||||
ctx.fillRect(60, 60, 75, 50);
|
||||
ctx.globalAlpha = 0.5;
|
||||
|
||||
ctx.fillStyle = 'rgba(225, 0, 0, 1)';
|
||||
ctx.fillRect(50, 50, 75, 50);
|
||||
ctx.fillStyle = 'rgba(0, 255, 0, 1)';
|
||||
ctx.fillRect(70, 70, 75, 50);
|
||||
</script>
|
|
@ -1,31 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
|
||||
<link rel="match" href="2d.layer.endlayer.unmatched-expected.html">
|
||||
<title>Canvas test: 2d.layer.endlayer.unmatched</title>
|
||||
<h1>2d.layer.endlayer.unmatched</h1>
|
||||
<p class="desc">A test to make sure an unmatched endLayer is a no-op and has no effect on the code following it.</p>
|
||||
<canvas id="canvas" width="200" height="200">
|
||||
<p class="fallback">FAIL (fallback content)</p>
|
||||
</canvas>
|
||||
<script>
|
||||
const canvas = new OffscreenCanvas(200, 200);
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
ctx.fillStyle = 'rgba(0, 0, 255, 1)';
|
||||
ctx.fillRect(60, 60, 75, 50);
|
||||
|
||||
ctx.globalAlpha = 0.5;
|
||||
|
||||
// This endlayer call should no-op.
|
||||
ctx.endLayer();
|
||||
|
||||
ctx.beginLayer();
|
||||
ctx.fillStyle = 'rgba(225, 0, 0, 1)';
|
||||
ctx.fillRect(50, 50, 75, 50);
|
||||
ctx.fillStyle = 'rgba(0, 255, 0, 1)';
|
||||
ctx.fillRect(70, 70, 75, 50);
|
||||
ctx.endLayer();
|
||||
|
||||
const outputCanvas = document.getElementById("canvas");
|
||||
outputCanvas.getContext('2d').drawImage(canvas, 0, 0);
|
||||
</script>
|
|
@ -0,0 +1,31 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
|
||||
<title>OffscreenCanvas test: 2d.layer.invalid-calls.beginLayer-reset-endLayer</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/html/canvas/resources/canvas-tests.js"></script>
|
||||
|
||||
<h1>2d.layer.invalid-calls.beginLayer-reset-endLayer</h1>
|
||||
<p class="desc">Raises exception on beginLayer() + reset() + endLayer().</p>
|
||||
|
||||
|
||||
<script>
|
||||
var t = async_test("Raises exception on beginLayer() + reset() + endLayer().");
|
||||
var t_pass = t.done.bind(t);
|
||||
var t_fail = t.step_func(function(reason) {
|
||||
throw reason;
|
||||
});
|
||||
t.step(function() {
|
||||
|
||||
var canvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = canvas.getContext('2d');
|
||||
|
||||
assert_throws_dom("INVALID_STATE_ERR", function() {
|
||||
ctx.beginLayer();
|
||||
ctx.reset();
|
||||
ctx.endLayer();
|
||||
});
|
||||
t.done();
|
||||
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,26 @@
|
|||
// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py.
|
||||
// OffscreenCanvas test in a worker:2d.layer.invalid-calls.beginLayer-reset-endLayer
|
||||
// Description:Raises exception on beginLayer() + reset() + endLayer().
|
||||
// Note:
|
||||
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("/html/canvas/resources/canvas-tests.js");
|
||||
|
||||
var t = async_test("Raises exception on beginLayer() + reset() + endLayer().");
|
||||
var t_pass = t.done.bind(t);
|
||||
var t_fail = t.step_func(function(reason) {
|
||||
throw reason;
|
||||
});
|
||||
t.step(function() {
|
||||
|
||||
var canvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = canvas.getContext('2d');
|
||||
|
||||
assert_throws_dom("INVALID_STATE_ERR", function() {
|
||||
ctx.beginLayer();
|
||||
ctx.reset();
|
||||
ctx.endLayer();
|
||||
});
|
||||
t.done();
|
||||
});
|
||||
done();
|
|
@ -0,0 +1,30 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
|
||||
<title>OffscreenCanvas test: 2d.layer.invalid-calls.beginLayer-restore</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/html/canvas/resources/canvas-tests.js"></script>
|
||||
|
||||
<h1>2d.layer.invalid-calls.beginLayer-restore</h1>
|
||||
<p class="desc">Raises exception on beginLayer() + restore().</p>
|
||||
|
||||
|
||||
<script>
|
||||
var t = async_test("Raises exception on beginLayer() + restore().");
|
||||
var t_pass = t.done.bind(t);
|
||||
var t_fail = t.step_func(function(reason) {
|
||||
throw reason;
|
||||
});
|
||||
t.step(function() {
|
||||
|
||||
var canvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = canvas.getContext('2d');
|
||||
|
||||
assert_throws_dom("INVALID_STATE_ERR", function() {
|
||||
ctx.beginLayer();
|
||||
ctx.restore();
|
||||
});
|
||||
t.done();
|
||||
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,25 @@
|
|||
// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py.
|
||||
// OffscreenCanvas test in a worker:2d.layer.invalid-calls.beginLayer-restore
|
||||
// Description:Raises exception on beginLayer() + restore().
|
||||
// Note:
|
||||
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("/html/canvas/resources/canvas-tests.js");
|
||||
|
||||
var t = async_test("Raises exception on beginLayer() + restore().");
|
||||
var t_pass = t.done.bind(t);
|
||||
var t_fail = t.step_func(function(reason) {
|
||||
throw reason;
|
||||
});
|
||||
t.step(function() {
|
||||
|
||||
var canvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = canvas.getContext('2d');
|
||||
|
||||
assert_throws_dom("INVALID_STATE_ERR", function() {
|
||||
ctx.beginLayer();
|
||||
ctx.restore();
|
||||
});
|
||||
t.done();
|
||||
});
|
||||
done();
|
|
@ -0,0 +1,31 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
|
||||
<title>OffscreenCanvas test: 2d.layer.invalid-calls.beginLayer-save-endLayer</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/html/canvas/resources/canvas-tests.js"></script>
|
||||
|
||||
<h1>2d.layer.invalid-calls.beginLayer-save-endLayer</h1>
|
||||
<p class="desc">Raises exception on beginLayer() + save() + endLayer().</p>
|
||||
|
||||
|
||||
<script>
|
||||
var t = async_test("Raises exception on beginLayer() + save() + endLayer().");
|
||||
var t_pass = t.done.bind(t);
|
||||
var t_fail = t.step_func(function(reason) {
|
||||
throw reason;
|
||||
});
|
||||
t.step(function() {
|
||||
|
||||
var canvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = canvas.getContext('2d');
|
||||
|
||||
assert_throws_dom("INVALID_STATE_ERR", function() {
|
||||
ctx.beginLayer();
|
||||
ctx.save();
|
||||
ctx.endLayer();
|
||||
});
|
||||
t.done();
|
||||
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,26 @@
|
|||
// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py.
|
||||
// OffscreenCanvas test in a worker:2d.layer.invalid-calls.beginLayer-save-endLayer
|
||||
// Description:Raises exception on beginLayer() + save() + endLayer().
|
||||
// Note:
|
||||
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("/html/canvas/resources/canvas-tests.js");
|
||||
|
||||
var t = async_test("Raises exception on beginLayer() + save() + endLayer().");
|
||||
var t_pass = t.done.bind(t);
|
||||
var t_fail = t.step_func(function(reason) {
|
||||
throw reason;
|
||||
});
|
||||
t.step(function() {
|
||||
|
||||
var canvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = canvas.getContext('2d');
|
||||
|
||||
assert_throws_dom("INVALID_STATE_ERR", function() {
|
||||
ctx.beginLayer();
|
||||
ctx.save();
|
||||
ctx.endLayer();
|
||||
});
|
||||
t.done();
|
||||
});
|
||||
done();
|
|
@ -0,0 +1,29 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
|
||||
<title>OffscreenCanvas test: 2d.layer.invalid-calls.endLayer</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/html/canvas/resources/canvas-tests.js"></script>
|
||||
|
||||
<h1>2d.layer.invalid-calls.endLayer</h1>
|
||||
<p class="desc">Raises exception on lone endLayer calls.</p>
|
||||
|
||||
|
||||
<script>
|
||||
var t = async_test("Raises exception on lone endLayer calls.");
|
||||
var t_pass = t.done.bind(t);
|
||||
var t_fail = t.step_func(function(reason) {
|
||||
throw reason;
|
||||
});
|
||||
t.step(function() {
|
||||
|
||||
var canvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = canvas.getContext('2d');
|
||||
|
||||
assert_throws_dom("INVALID_STATE_ERR", function() {
|
||||
ctx.endLayer();
|
||||
});
|
||||
t.done();
|
||||
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,24 @@
|
|||
// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py.
|
||||
// OffscreenCanvas test in a worker:2d.layer.invalid-calls.endLayer
|
||||
// Description:Raises exception on lone endLayer calls.
|
||||
// Note:
|
||||
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("/html/canvas/resources/canvas-tests.js");
|
||||
|
||||
var t = async_test("Raises exception on lone endLayer calls.");
|
||||
var t_pass = t.done.bind(t);
|
||||
var t_fail = t.step_func(function(reason) {
|
||||
throw reason;
|
||||
});
|
||||
t.step(function() {
|
||||
|
||||
var canvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = canvas.getContext('2d');
|
||||
|
||||
assert_throws_dom("INVALID_STATE_ERR", function() {
|
||||
ctx.endLayer();
|
||||
});
|
||||
t.done();
|
||||
});
|
||||
done();
|
|
@ -0,0 +1,31 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
|
||||
<title>OffscreenCanvas test: 2d.layer.invalid-calls.save-beginLayer-restore</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/html/canvas/resources/canvas-tests.js"></script>
|
||||
|
||||
<h1>2d.layer.invalid-calls.save-beginLayer-restore</h1>
|
||||
<p class="desc">Raises exception on save() + beginLayer() + restore().</p>
|
||||
|
||||
|
||||
<script>
|
||||
var t = async_test("Raises exception on save() + beginLayer() + restore().");
|
||||
var t_pass = t.done.bind(t);
|
||||
var t_fail = t.step_func(function(reason) {
|
||||
throw reason;
|
||||
});
|
||||
t.step(function() {
|
||||
|
||||
var canvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = canvas.getContext('2d');
|
||||
|
||||
assert_throws_dom("INVALID_STATE_ERR", function() {
|
||||
ctx.save();
|
||||
ctx.beginLayer();
|
||||
ctx.restore();
|
||||
});
|
||||
t.done();
|
||||
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,26 @@
|
|||
// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py.
|
||||
// OffscreenCanvas test in a worker:2d.layer.invalid-calls.save-beginLayer-restore
|
||||
// Description:Raises exception on save() + beginLayer() + restore().
|
||||
// Note:
|
||||
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("/html/canvas/resources/canvas-tests.js");
|
||||
|
||||
var t = async_test("Raises exception on save() + beginLayer() + restore().");
|
||||
var t_pass = t.done.bind(t);
|
||||
var t_fail = t.step_func(function(reason) {
|
||||
throw reason;
|
||||
});
|
||||
t.step(function() {
|
||||
|
||||
var canvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = canvas.getContext('2d');
|
||||
|
||||
assert_throws_dom("INVALID_STATE_ERR", function() {
|
||||
ctx.save();
|
||||
ctx.beginLayer();
|
||||
ctx.restore();
|
||||
});
|
||||
t.done();
|
||||
});
|
||||
done();
|
|
@ -0,0 +1,30 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
|
||||
<title>OffscreenCanvas test: 2d.layer.invalid-calls.save-endLayer</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/html/canvas/resources/canvas-tests.js"></script>
|
||||
|
||||
<h1>2d.layer.invalid-calls.save-endLayer</h1>
|
||||
<p class="desc">Raises exception on save() + endLayer().</p>
|
||||
|
||||
|
||||
<script>
|
||||
var t = async_test("Raises exception on save() + endLayer().");
|
||||
var t_pass = t.done.bind(t);
|
||||
var t_fail = t.step_func(function(reason) {
|
||||
throw reason;
|
||||
});
|
||||
t.step(function() {
|
||||
|
||||
var canvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = canvas.getContext('2d');
|
||||
|
||||
assert_throws_dom("INVALID_STATE_ERR", function() {
|
||||
ctx.save();
|
||||
ctx.endLayer();
|
||||
});
|
||||
t.done();
|
||||
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,25 @@
|
|||
// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py.
|
||||
// OffscreenCanvas test in a worker:2d.layer.invalid-calls.save-endLayer
|
||||
// Description:Raises exception on save() + endLayer().
|
||||
// Note:
|
||||
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("/html/canvas/resources/canvas-tests.js");
|
||||
|
||||
var t = async_test("Raises exception on save() + endLayer().");
|
||||
var t_pass = t.done.bind(t);
|
||||
var t_fail = t.step_func(function(reason) {
|
||||
throw reason;
|
||||
});
|
||||
t.step(function() {
|
||||
|
||||
var canvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = canvas.getContext('2d');
|
||||
|
||||
assert_throws_dom("INVALID_STATE_ERR", function() {
|
||||
ctx.save();
|
||||
ctx.endLayer();
|
||||
});
|
||||
t.done();
|
||||
});
|
||||
done();
|
|
@ -0,0 +1,14 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
|
||||
<title>Canvas test: 2d.layer.reset</title>
|
||||
<h1>2d.layer.reset</h1>
|
||||
<p class="desc">Checks that reset discards any pending layers.</p>
|
||||
<canvas id="canvas" width="100" height="50">
|
||||
<p class="fallback">FAIL (fallback content)</p>
|
||||
</canvas>
|
||||
<script>
|
||||
const canvas = document.getElementById("canvas");
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
ctx.fillRect(10, 10, 75, 50);
|
||||
</script>
|
|
@ -0,0 +1,36 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
|
||||
<link rel="match" href="2d.layer.reset-expected.html">
|
||||
<title>Canvas test: 2d.layer.reset</title>
|
||||
<h1>2d.layer.reset</h1>
|
||||
<p class="desc">Checks that reset discards any pending layers.</p>
|
||||
<canvas id="canvas" width="100" height="50">
|
||||
<p class="fallback">FAIL (fallback content)</p>
|
||||
</canvas>
|
||||
<script>
|
||||
const canvas = new OffscreenCanvas(100, 50);
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
// Global states:
|
||||
ctx.globalAlpha = 0.3;
|
||||
ctx.globalCompositeOperation = 'source-in';
|
||||
ctx.shadowOffsetX = -3;
|
||||
ctx.shadowOffsetY = 3;
|
||||
ctx.shadowColor = 'rgba(0, 30, 0, 0.3)';
|
||||
|
||||
ctx.beginLayer({filter: 'dropShadow', dx: -3, dy: 3});
|
||||
|
||||
// Layer states:
|
||||
ctx.globalAlpha = 0.6;
|
||||
ctx.globalCompositeOperation = 'source-in';
|
||||
ctx.shadowOffsetX = -6;
|
||||
ctx.shadowOffsetY = 6;
|
||||
ctx.shadowColor = 'rgba(0, 60, 0, 0.6)';
|
||||
|
||||
ctx.reset();
|
||||
|
||||
ctx.fillRect(10, 10, 75, 50);
|
||||
|
||||
const outputCanvas = document.getElementById("canvas");
|
||||
outputCanvas.getContext('2d').drawImage(canvas, 0, 0);
|
||||
</script>
|
|
@ -0,0 +1,50 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
|
||||
<html class="reftest-wait">
|
||||
<link rel="match" href="2d.layer.reset-expected.html">
|
||||
<title>Canvas test: 2d.layer.reset</title>
|
||||
<h1>2d.layer.reset</h1>
|
||||
<p class="desc">Checks that reset discards any pending layers.</p>
|
||||
<canvas id="canvas" width="100" height="50">
|
||||
<p class="fallback">FAIL (fallback content)</p>
|
||||
</canvas>
|
||||
<script id='myWorker' type='text/worker'>
|
||||
self.onmessage = function(e) {
|
||||
const canvas = new OffscreenCanvas(100, 50);
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
// Global states:
|
||||
ctx.globalAlpha = 0.3;
|
||||
ctx.globalCompositeOperation = 'source-in';
|
||||
ctx.shadowOffsetX = -3;
|
||||
ctx.shadowOffsetY = 3;
|
||||
ctx.shadowColor = 'rgba(0, 30, 0, 0.3)';
|
||||
|
||||
ctx.beginLayer({filter: 'dropShadow', dx: -3, dy: 3});
|
||||
|
||||
// Layer states:
|
||||
ctx.globalAlpha = 0.6;
|
||||
ctx.globalCompositeOperation = 'source-in';
|
||||
ctx.shadowOffsetX = -6;
|
||||
ctx.shadowOffsetY = 6;
|
||||
ctx.shadowColor = 'rgba(0, 60, 0, 0.6)';
|
||||
|
||||
ctx.reset();
|
||||
|
||||
ctx.fillRect(10, 10, 75, 50);
|
||||
|
||||
const bitmap = canvas.transferToImageBitmap();
|
||||
self.postMessage(bitmap, bitmap);
|
||||
};
|
||||
</script>
|
||||
<script>
|
||||
const blob = new Blob([document.getElementById('myWorker').textContent]);
|
||||
const worker = new Worker(URL.createObjectURL(blob));
|
||||
worker.addEventListener('message', msg => {
|
||||
const outputCtx = document.getElementById("canvas").getContext('2d');
|
||||
outputCtx.drawImage(msg.data, 0, 0);
|
||||
document.documentElement.classList.remove("reftest-wait");
|
||||
});
|
||||
worker.postMessage(null);
|
||||
</script>
|
||||
</html>
|
|
@ -0,0 +1,28 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
|
||||
<title>Canvas test: 2d.layer.unclosed-nested</title>
|
||||
<h1>2d.layer.unclosed-nested</h1>
|
||||
<p class="desc">Check that layers are rendered even if not closed.</p>
|
||||
<canvas id="canvas" width="200" height="200">
|
||||
<p class="fallback">FAIL (fallback content)</p>
|
||||
</canvas>
|
||||
<script>
|
||||
const canvas = document.getElementById("canvas");
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
const canvas1 = document.createElement('canvas');
|
||||
const ctx1 = canvas1.getContext('2d');
|
||||
ctx1.fillStyle = 'rgba(0,255,0,1)';
|
||||
ctx1.fillRect(70,70,75,50);
|
||||
|
||||
const canvas2 = document.createElement('canvas');
|
||||
const ctx2 = canvas2.getContext('2d');
|
||||
ctx2.fillStyle = 'rgba(225,0,0,1)';
|
||||
ctx2.fillRect(50,50,75,50);
|
||||
ctx2.drawImage(canvas1, 0, 0);
|
||||
|
||||
ctx.fillStyle = 'rgba(0,0,255,1)';
|
||||
ctx.fillRect(60,60,75,50);
|
||||
ctx.globalAlpha = 0.5;
|
||||
ctx.drawImage(canvas2, 0, 0);
|
||||
</script>
|
|
@ -1,9 +1,9 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
|
||||
<link rel="match" href="2d.layer.endlayer.alone-expected.html">
|
||||
<title>Canvas test: 2d.layer.endlayer.alone</title>
|
||||
<h1>2d.layer.endlayer.alone</h1>
|
||||
<p class="desc">A test to make sure a single endLayer with no beginLayer is a no-op.</p>
|
||||
<link rel="match" href="2d.layer.unclosed-nested-expected.html">
|
||||
<title>Canvas test: 2d.layer.unclosed-nested</title>
|
||||
<h1>2d.layer.unclosed-nested</h1>
|
||||
<p class="desc">Check that layers are rendered even if not closed.</p>
|
||||
<canvas id="canvas" width="200" height="200">
|
||||
<p class="fallback">FAIL (fallback content)</p>
|
||||
</canvas>
|
||||
|
@ -15,12 +15,16 @@
|
|||
ctx.fillRect(60, 60, 75, 50);
|
||||
ctx.globalAlpha = 0.5;
|
||||
|
||||
ctx.beginLayer();
|
||||
ctx.fillStyle = 'rgba(225, 0, 0, 1)';
|
||||
ctx.fillRect(50, 50, 75, 50);
|
||||
|
||||
ctx.beginLayer();
|
||||
ctx.fillStyle = 'rgba(0, 255, 0, 1)';
|
||||
ctx.fillRect(70, 70, 75, 50);
|
||||
|
||||
ctx.endLayer();
|
||||
// Missing ctx.endLayer() here.
|
||||
|
||||
const outputCanvas = document.getElementById("canvas");
|
||||
outputCanvas.getContext('2d').drawImage(canvas, 0, 0);
|
|
@ -1,10 +1,10 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
|
||||
<html class="reftest-wait">
|
||||
<link rel="match" href="2d.layer.endlayer.alone-expected.html">
|
||||
<title>Canvas test: 2d.layer.endlayer.alone</title>
|
||||
<h1>2d.layer.endlayer.alone</h1>
|
||||
<p class="desc">A test to make sure a single endLayer with no beginLayer is a no-op.</p>
|
||||
<link rel="match" href="2d.layer.unclosed-nested-expected.html">
|
||||
<title>Canvas test: 2d.layer.unclosed-nested</title>
|
||||
<h1>2d.layer.unclosed-nested</h1>
|
||||
<p class="desc">Check that layers are rendered even if not closed.</p>
|
||||
<canvas id="canvas" width="200" height="200">
|
||||
<p class="fallback">FAIL (fallback content)</p>
|
||||
</canvas>
|
||||
|
@ -17,12 +17,16 @@
|
|||
ctx.fillRect(60, 60, 75, 50);
|
||||
ctx.globalAlpha = 0.5;
|
||||
|
||||
ctx.beginLayer();
|
||||
ctx.fillStyle = 'rgba(225, 0, 0, 1)';
|
||||
ctx.fillRect(50, 50, 75, 50);
|
||||
|
||||
ctx.beginLayer();
|
||||
ctx.fillStyle = 'rgba(0, 255, 0, 1)';
|
||||
ctx.fillRect(70, 70, 75, 50);
|
||||
|
||||
ctx.endLayer();
|
||||
// Missing ctx.endLayer() here.
|
||||
|
||||
const bitmap = canvas.transferToImageBitmap();
|
||||
self.postMessage(bitmap, bitmap);
|
|
@ -0,0 +1,28 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
|
||||
<title>OffscreenCanvas test: 2d.layer.valid-calls.beginLayer-endLayer</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/html/canvas/resources/canvas-tests.js"></script>
|
||||
|
||||
<h1>2d.layer.valid-calls.beginLayer-endLayer</h1>
|
||||
<p class="desc">No exception raised on beginLayer() + endLayer().</p>
|
||||
|
||||
|
||||
<script>
|
||||
var t = async_test("No exception raised on beginLayer() + endLayer().");
|
||||
var t_pass = t.done.bind(t);
|
||||
var t_fail = t.step_func(function(reason) {
|
||||
throw reason;
|
||||
});
|
||||
t.step(function() {
|
||||
|
||||
var canvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = canvas.getContext('2d');
|
||||
|
||||
ctx.beginLayer();
|
||||
ctx.save();
|
||||
t.done();
|
||||
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,23 @@
|
|||
// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py.
|
||||
// OffscreenCanvas test in a worker:2d.layer.valid-calls.beginLayer-endLayer
|
||||
// Description:No exception raised on beginLayer() + endLayer().
|
||||
// Note:
|
||||
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("/html/canvas/resources/canvas-tests.js");
|
||||
|
||||
var t = async_test("No exception raised on beginLayer() + endLayer().");
|
||||
var t_pass = t.done.bind(t);
|
||||
var t_fail = t.step_func(function(reason) {
|
||||
throw reason;
|
||||
});
|
||||
t.step(function() {
|
||||
|
||||
var canvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = canvas.getContext('2d');
|
||||
|
||||
ctx.beginLayer();
|
||||
ctx.save();
|
||||
t.done();
|
||||
});
|
||||
done();
|
|
@ -0,0 +1,28 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
|
||||
<title>OffscreenCanvas test: 2d.layer.valid-calls.beginLayer-save</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/html/canvas/resources/canvas-tests.js"></script>
|
||||
|
||||
<h1>2d.layer.valid-calls.beginLayer-save</h1>
|
||||
<p class="desc">No exception raised on beginLayer() + save().</p>
|
||||
|
||||
|
||||
<script>
|
||||
var t = async_test("No exception raised on beginLayer() + save().");
|
||||
var t_pass = t.done.bind(t);
|
||||
var t_fail = t.step_func(function(reason) {
|
||||
throw reason;
|
||||
});
|
||||
t.step(function() {
|
||||
|
||||
var canvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = canvas.getContext('2d');
|
||||
|
||||
ctx.beginLayer();
|
||||
ctx.save();
|
||||
t.done();
|
||||
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,23 @@
|
|||
// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py.
|
||||
// OffscreenCanvas test in a worker:2d.layer.valid-calls.beginLayer-save
|
||||
// Description:No exception raised on beginLayer() + save().
|
||||
// Note:
|
||||
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("/html/canvas/resources/canvas-tests.js");
|
||||
|
||||
var t = async_test("No exception raised on beginLayer() + save().");
|
||||
var t_pass = t.done.bind(t);
|
||||
var t_fail = t.step_func(function(reason) {
|
||||
throw reason;
|
||||
});
|
||||
t.step(function() {
|
||||
|
||||
var canvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = canvas.getContext('2d');
|
||||
|
||||
ctx.beginLayer();
|
||||
ctx.save();
|
||||
t.done();
|
||||
});
|
||||
done();
|
|
@ -0,0 +1,27 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
|
||||
<title>OffscreenCanvas test: 2d.layer.valid-calls.beginLayer</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/html/canvas/resources/canvas-tests.js"></script>
|
||||
|
||||
<h1>2d.layer.valid-calls.beginLayer</h1>
|
||||
<p class="desc">No exception raised on lone beginLayer() calls.</p>
|
||||
|
||||
|
||||
<script>
|
||||
var t = async_test("No exception raised on lone beginLayer() calls.");
|
||||
var t_pass = t.done.bind(t);
|
||||
var t_fail = t.step_func(function(reason) {
|
||||
throw reason;
|
||||
});
|
||||
t.step(function() {
|
||||
|
||||
var canvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = canvas.getContext('2d');
|
||||
|
||||
ctx.beginLayer();
|
||||
t.done();
|
||||
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,22 @@
|
|||
// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py.
|
||||
// OffscreenCanvas test in a worker:2d.layer.valid-calls.beginLayer
|
||||
// Description:No exception raised on lone beginLayer() calls.
|
||||
// Note:
|
||||
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("/html/canvas/resources/canvas-tests.js");
|
||||
|
||||
var t = async_test("No exception raised on lone beginLayer() calls.");
|
||||
var t_pass = t.done.bind(t);
|
||||
var t_fail = t.step_func(function(reason) {
|
||||
throw reason;
|
||||
});
|
||||
t.step(function() {
|
||||
|
||||
var canvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = canvas.getContext('2d');
|
||||
|
||||
ctx.beginLayer();
|
||||
t.done();
|
||||
});
|
||||
done();
|
|
@ -0,0 +1,27 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
|
||||
<title>OffscreenCanvas test: 2d.layer.valid-calls.restore</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/html/canvas/resources/canvas-tests.js"></script>
|
||||
|
||||
<h1>2d.layer.valid-calls.restore</h1>
|
||||
<p class="desc">No exception raised on lone restore() calls.</p>
|
||||
|
||||
|
||||
<script>
|
||||
var t = async_test("No exception raised on lone restore() calls.");
|
||||
var t_pass = t.done.bind(t);
|
||||
var t_fail = t.step_func(function(reason) {
|
||||
throw reason;
|
||||
});
|
||||
t.step(function() {
|
||||
|
||||
var canvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = canvas.getContext('2d');
|
||||
|
||||
ctx.restore();
|
||||
t.done();
|
||||
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,22 @@
|
|||
// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py.
|
||||
// OffscreenCanvas test in a worker:2d.layer.valid-calls.restore
|
||||
// Description:No exception raised on lone restore() calls.
|
||||
// Note:
|
||||
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("/html/canvas/resources/canvas-tests.js");
|
||||
|
||||
var t = async_test("No exception raised on lone restore() calls.");
|
||||
var t_pass = t.done.bind(t);
|
||||
var t_fail = t.step_func(function(reason) {
|
||||
throw reason;
|
||||
});
|
||||
t.step(function() {
|
||||
|
||||
var canvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = canvas.getContext('2d');
|
||||
|
||||
ctx.restore();
|
||||
t.done();
|
||||
});
|
||||
done();
|
|
@ -0,0 +1,28 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
|
||||
<title>OffscreenCanvas test: 2d.layer.valid-calls.save-beginLayer</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/html/canvas/resources/canvas-tests.js"></script>
|
||||
|
||||
<h1>2d.layer.valid-calls.save-beginLayer</h1>
|
||||
<p class="desc">No exception raised on save() + beginLayer().</p>
|
||||
|
||||
|
||||
<script>
|
||||
var t = async_test("No exception raised on save() + beginLayer().");
|
||||
var t_pass = t.done.bind(t);
|
||||
var t_fail = t.step_func(function(reason) {
|
||||
throw reason;
|
||||
});
|
||||
t.step(function() {
|
||||
|
||||
var canvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = canvas.getContext('2d');
|
||||
|
||||
ctx.save();
|
||||
ctx.beginLayer();
|
||||
t.done();
|
||||
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,23 @@
|
|||
// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py.
|
||||
// OffscreenCanvas test in a worker:2d.layer.valid-calls.save-beginLayer
|
||||
// Description:No exception raised on save() + beginLayer().
|
||||
// Note:
|
||||
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("/html/canvas/resources/canvas-tests.js");
|
||||
|
||||
var t = async_test("No exception raised on save() + beginLayer().");
|
||||
var t_pass = t.done.bind(t);
|
||||
var t_fail = t.step_func(function(reason) {
|
||||
throw reason;
|
||||
});
|
||||
t.step(function() {
|
||||
|
||||
var canvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = canvas.getContext('2d');
|
||||
|
||||
ctx.save();
|
||||
ctx.beginLayer();
|
||||
t.done();
|
||||
});
|
||||
done();
|
|
@ -0,0 +1,27 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
|
||||
<title>OffscreenCanvas test: 2d.layer.valid-calls.save</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/html/canvas/resources/canvas-tests.js"></script>
|
||||
|
||||
<h1>2d.layer.valid-calls.save</h1>
|
||||
<p class="desc">No exception raised on lone save() calls.</p>
|
||||
|
||||
|
||||
<script>
|
||||
var t = async_test("No exception raised on lone save() calls.");
|
||||
var t_pass = t.done.bind(t);
|
||||
var t_fail = t.step_func(function(reason) {
|
||||
throw reason;
|
||||
});
|
||||
t.step(function() {
|
||||
|
||||
var canvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = canvas.getContext('2d');
|
||||
|
||||
ctx.save();
|
||||
t.done();
|
||||
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,22 @@
|
|||
// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py.
|
||||
// OffscreenCanvas test in a worker:2d.layer.valid-calls.save
|
||||
// Description:No exception raised on lone save() calls.
|
||||
// Note:
|
||||
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("/html/canvas/resources/canvas-tests.js");
|
||||
|
||||
var t = async_test("No exception raised on lone save() calls.");
|
||||
var t_pass = t.done.bind(t);
|
||||
var t_fail = t.step_func(function(reason) {
|
||||
throw reason;
|
||||
});
|
||||
t.step(function() {
|
||||
|
||||
var canvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = canvas.getContext('2d');
|
||||
|
||||
ctx.save();
|
||||
t.done();
|
||||
});
|
||||
done();
|
|
@ -0,0 +1,29 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
|
||||
<title>OffscreenCanvas test: 2d.layer.valid-calls.save_reset_restore</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/html/canvas/resources/canvas-tests.js"></script>
|
||||
|
||||
<h1>2d.layer.valid-calls.save_reset_restore</h1>
|
||||
<p class="desc">No exception raised on save() + reset() + restore().</p>
|
||||
|
||||
|
||||
<script>
|
||||
var t = async_test("No exception raised on save() + reset() + restore().");
|
||||
var t_pass = t.done.bind(t);
|
||||
var t_fail = t.step_func(function(reason) {
|
||||
throw reason;
|
||||
});
|
||||
t.step(function() {
|
||||
|
||||
var canvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = canvas.getContext('2d');
|
||||
|
||||
ctx.save();
|
||||
ctx.reset();
|
||||
ctx.restore();
|
||||
t.done();
|
||||
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,24 @@
|
|||
// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py.
|
||||
// OffscreenCanvas test in a worker:2d.layer.valid-calls.save_reset_restore
|
||||
// Description:No exception raised on save() + reset() + restore().
|
||||
// Note:
|
||||
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("/html/canvas/resources/canvas-tests.js");
|
||||
|
||||
var t = async_test("No exception raised on save() + reset() + restore().");
|
||||
var t_pass = t.done.bind(t);
|
||||
var t_fail = t.step_func(function(reason) {
|
||||
throw reason;
|
||||
});
|
||||
t.step(function() {
|
||||
|
||||
var canvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = canvas.getContext('2d');
|
||||
|
||||
ctx.save();
|
||||
ctx.reset();
|
||||
ctx.restore();
|
||||
t.done();
|
||||
});
|
||||
done();
|
|
@ -0,0 +1,28 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
|
||||
<title>OffscreenCanvas test: 2d.layer.valid-calls.save_restore</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/html/canvas/resources/canvas-tests.js"></script>
|
||||
|
||||
<h1>2d.layer.valid-calls.save_restore</h1>
|
||||
<p class="desc">No exception raised on save() + restore().</p>
|
||||
|
||||
|
||||
<script>
|
||||
var t = async_test("No exception raised on save() + restore().");
|
||||
var t_pass = t.done.bind(t);
|
||||
var t_fail = t.step_func(function(reason) {
|
||||
throw reason;
|
||||
});
|
||||
t.step(function() {
|
||||
|
||||
var canvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = canvas.getContext('2d');
|
||||
|
||||
ctx.save();
|
||||
ctx.restore();
|
||||
t.done();
|
||||
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,23 @@
|
|||
// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py.
|
||||
// OffscreenCanvas test in a worker:2d.layer.valid-calls.save_restore
|
||||
// Description:No exception raised on save() + restore().
|
||||
// Note:
|
||||
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("/html/canvas/resources/canvas-tests.js");
|
||||
|
||||
var t = async_test("No exception raised on save() + restore().");
|
||||
var t_pass = t.done.bind(t);
|
||||
var t_fail = t.step_func(function(reason) {
|
||||
throw reason;
|
||||
});
|
||||
t.step(function() {
|
||||
|
||||
var canvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = canvas.getContext('2d');
|
||||
|
||||
ctx.save();
|
||||
ctx.restore();
|
||||
t.done();
|
||||
});
|
||||
done();
|
|
@ -271,6 +271,40 @@
|
|||
ctx.fillRect(50, 50, 75, 50);
|
||||
ctx.endLayer();
|
||||
|
||||
- name: 2d.layer.unclosed-nested
|
||||
desc: Check that layers are rendered even if not closed.
|
||||
size: [200, 200]
|
||||
code: |
|
||||
ctx.fillStyle = 'rgba(0, 0, 255, 1)';
|
||||
ctx.fillRect(60, 60, 75, 50);
|
||||
ctx.globalAlpha = 0.5;
|
||||
|
||||
ctx.beginLayer();
|
||||
ctx.fillStyle = 'rgba(225, 0, 0, 1)';
|
||||
ctx.fillRect(50, 50, 75, 50);
|
||||
|
||||
ctx.beginLayer();
|
||||
ctx.fillStyle = 'rgba(0, 255, 0, 1)';
|
||||
ctx.fillRect(70, 70, 75, 50);
|
||||
|
||||
ctx.endLayer();
|
||||
// Missing ctx.endLayer() here.
|
||||
reference: |
|
||||
const canvas1 = document.createElement('canvas');
|
||||
const ctx1 = canvas1.getContext('2d');
|
||||
ctx1.fillStyle = 'rgba(0,255,0,1)';
|
||||
ctx1.fillRect(70,70,75,50);
|
||||
|
||||
const canvas2 = document.createElement('canvas');
|
||||
const ctx2 = canvas2.getContext('2d');
|
||||
ctx2.fillStyle = 'rgba(225,0,0,1)';
|
||||
ctx2.fillRect(50,50,75,50);
|
||||
ctx2.drawImage(canvas1, 0, 0);
|
||||
|
||||
ctx.fillStyle = 'rgba(0,0,255,1)';
|
||||
ctx.fillRect(60,60,75,50);
|
||||
ctx.globalAlpha = 0.5;
|
||||
ctx.drawImage(canvas2, 0, 0);
|
||||
|
||||
- name: 2d.layer.render-opportunities
|
||||
desc: Check that layers state stack is flushed and rebuilt on frame renders.
|
||||
|
@ -436,61 +470,119 @@
|
|||
ctx.drawImage(canvas2[i], i, i);
|
||||
}
|
||||
|
||||
|
||||
- name: 2d.layer.endlayer.unmatched
|
||||
desc: >-
|
||||
A test to make sure an unmatched endLayer is a no-op and has no effect on
|
||||
the code following it.
|
||||
size: [200, 200]
|
||||
- name: 2d.layer.reset
|
||||
desc: Checks that reset discards any pending layers.
|
||||
code: |
|
||||
ctx.fillStyle = 'rgba(0, 0, 255, 1)';
|
||||
ctx.fillRect(60, 60, 75, 50);
|
||||
// Global states:
|
||||
ctx.globalAlpha = 0.3;
|
||||
ctx.globalCompositeOperation = 'source-in';
|
||||
ctx.shadowOffsetX = -3;
|
||||
ctx.shadowOffsetY = 3;
|
||||
ctx.shadowColor = 'rgba(0, 30, 0, 0.3)';
|
||||
|
||||
ctx.globalAlpha = 0.5;
|
||||
ctx.beginLayer({filter: 'dropShadow', dx: -3, dy: 3});
|
||||
|
||||
// This endlayer call should no-op.
|
||||
ctx.endLayer();
|
||||
// Layer states:
|
||||
ctx.globalAlpha = 0.6;
|
||||
ctx.globalCompositeOperation = 'source-in';
|
||||
ctx.shadowOffsetX = -6;
|
||||
ctx.shadowOffsetY = 6;
|
||||
ctx.shadowColor = 'rgba(0, 60, 0, 0.6)';
|
||||
|
||||
ctx.beginLayer();
|
||||
ctx.fillStyle = 'rgba(225, 0, 0, 1)';
|
||||
ctx.fillRect(50, 50, 75, 50);
|
||||
ctx.fillStyle = 'rgba(0, 255, 0, 1)';
|
||||
ctx.fillRect(70, 70, 75, 50);
|
||||
ctx.endLayer();
|
||||
reference: |
|
||||
ctx.fillStyle = 'rgba(0, 0, 255, 1)';
|
||||
ctx.fillRect(60, 60, 75, 50);
|
||||
ctx.reset();
|
||||
|
||||
ctx.globalAlpha = 0.5;
|
||||
ctx.fillRect(10, 10, 75, 50);
|
||||
reference:
|
||||
ctx.fillRect(10, 10, 75, 50);
|
||||
|
||||
ctx.beginLayer();
|
||||
ctx.fillStyle = 'rgba(225, 0, 0, 1)';
|
||||
ctx.fillRect(50, 50, 75, 50);
|
||||
ctx.fillStyle = 'rgba(0, 255, 0, 1)';
|
||||
ctx.fillRect(70, 70, 75, 50);
|
||||
ctx.endLayer();
|
||||
- name: 2d.layer.valid-calls
|
||||
desc: No exception raised on {{ variant_desc }}.
|
||||
variants:
|
||||
save:
|
||||
variant_desc: lone save() calls
|
||||
code: ctx.save();
|
||||
beginLayer:
|
||||
variant_desc: lone beginLayer() calls
|
||||
code: ctx.beginLayer();
|
||||
restore:
|
||||
variant_desc: lone restore() calls
|
||||
code: ctx.restore();
|
||||
save_restore:
|
||||
variant_desc: save() + restore()
|
||||
code: |-
|
||||
ctx.save();
|
||||
ctx.restore();
|
||||
save_reset_restore:
|
||||
variant_desc: save() + reset() + restore()
|
||||
code: |-
|
||||
ctx.save();
|
||||
ctx.reset();
|
||||
ctx.restore();
|
||||
beginLayer-endLayer:
|
||||
variant_desc: beginLayer() + endLayer()
|
||||
code: |-
|
||||
ctx.beginLayer();
|
||||
ctx.save();
|
||||
save-beginLayer:
|
||||
variant_desc: save() + beginLayer()
|
||||
code: |-
|
||||
ctx.save();
|
||||
ctx.beginLayer();
|
||||
beginLayer-save:
|
||||
variant_desc: beginLayer() + save()
|
||||
code: |-
|
||||
ctx.beginLayer();
|
||||
ctx.save();
|
||||
|
||||
|
||||
- name: 2d.layer.endlayer.alone
|
||||
desc: A test to make sure a single endLayer with no beginLayer is a no-op.
|
||||
size: [200, 200]
|
||||
- name: 2d.layer.invalid-calls
|
||||
desc: Raises exception on {{ variant_desc }}.
|
||||
code: |
|
||||
ctx.fillStyle = 'rgba(0, 0, 255, 1)';
|
||||
ctx.fillRect(60, 60, 75, 50);
|
||||
ctx.globalAlpha = 0.5;
|
||||
|
||||
ctx.fillStyle = 'rgba(225, 0, 0, 1)';
|
||||
ctx.fillRect(50, 50, 75, 50);
|
||||
ctx.fillStyle = 'rgba(0, 255, 0, 1)';
|
||||
ctx.fillRect(70, 70, 75, 50);
|
||||
assert_throws_dom("INVALID_STATE_ERR", function() {
|
||||
{{ call_sequence | indent(2) }}
|
||||
});
|
||||
variants:
|
||||
endLayer:
|
||||
variant_desc: lone endLayer calls
|
||||
call_sequence: ctx.endLayer();
|
||||
save-endLayer:
|
||||
variant_desc: save() + endLayer()
|
||||
call_sequence: |-
|
||||
ctx.save();
|
||||
ctx.endLayer();
|
||||
beginLayer-restore:
|
||||
variant_desc: beginLayer() + restore()
|
||||
call_sequence: |-
|
||||
ctx.beginLayer();
|
||||
ctx.restore();
|
||||
save-beginLayer-restore:
|
||||
variant_desc: save() + beginLayer() + restore()
|
||||
call_sequence: |-
|
||||
ctx.save();
|
||||
ctx.beginLayer();
|
||||
ctx.restore();
|
||||
beginLayer-save-endLayer:
|
||||
variant_desc: beginLayer() + save() + endLayer()
|
||||
call_sequence: |-
|
||||
ctx.beginLayer();
|
||||
ctx.save();
|
||||
ctx.endLayer();
|
||||
beginLayer-reset-endLayer:
|
||||
variant_desc: beginLayer() + reset() + endLayer()
|
||||
call_sequence: |-
|
||||
ctx.beginLayer();
|
||||
ctx.reset();
|
||||
ctx.endLayer();
|
||||
|
||||
- name: 2d.layer.cross-layer-paths
|
||||
desc: Checks that path defined in a layer is usable outside.
|
||||
code: |
|
||||
ctx.beginLayer();
|
||||
ctx.translate(50, 0);
|
||||
ctx.moveTo(0, 0);
|
||||
ctx.endLayer();
|
||||
reference: |
|
||||
ctx.fillStyle = 'rgba(0, 0, 255, 1)';
|
||||
ctx.fillRect(60, 60, 75, 50);
|
||||
ctx.globalAlpha = 0.5;
|
||||
|
||||
ctx.fillStyle = 'rgba(225, 0, 0, 1)';
|
||||
ctx.fillRect(50, 50, 75, 50);
|
||||
ctx.fillStyle = 'rgba(0, 255, 0, 1)';
|
||||
ctx.fillRect(70, 70, 75, 50);
|
||||
ctx.lineTo(50, 100);
|
||||
ctx.stroke();
|
||||
reference:
|
||||
ctx.moveTo(50, 0);
|
||||
ctx.lineTo(50, 100);
|
||||
ctx.stroke();
|
||||
|
|
Загрузка…
Ссылка в новой задаче