зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1436506 [wpt PR 9286] - drawImage with zero size canvas as the source image should throw, a=testonly
Automatic update from web-platform-tests This change list corrects the behavior of 2D context drawImage to throw an InvalidStateError exception when the source image is a canvas with size zero. It also matches the behavior for OffscreenCanvas and adds respective wpt tests. Associated spec change: https://github.com/whatwg/html/pull/3398 Bug: 805677 Change-Id: Id938af6683f5fc4e94e97327e4d729838f4bfb00 Reviewed-on: https://chromium-review.googlesource.com/893423 Commit-Queue: Mohammad Reza Zakerinasab <zakerinasab@chromium.org> Reviewed-by: Justin Novosad <junov@chromium.org> Cr-Commit-Position: refs/heads/master@{#535123} <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/w3c/web-platform-tests/9286) <!-- Reviewable:end --> wpt-commits: 04c852bf64d1d30309fa963c8b7148959ae11b92 wpt-pr: 9286 reapplied-commits: 370e267e160568862f1fd9ec246ab5bb840f586e, fe4514c84e7ad28e46bad5da93381deb99b177f3, 7806af854343c043a2645a4034fdc7812f65daad, 9ddfd21554293dec5a4bf2e5375ae4f3c9f2ded0, 75f63c4d1ebc949647184fd60972fc7b9fd4affb, 1f3a5b496acd2288cc8cf0c32af86cb35157ea4e, 88b42bd5847abac58a62c4d6b33c1509bfce5f3d, 15c2e4c690700c6c115f8afe5e44ded10d943538, c8d461ef1437641ae7d4ea1d21e1e60cd62910b0, a6088a5f48ee299386a84d2f771902267d7355b1, 0634cd8f08ebe0905a9188fb1398c7b5f889c5dc, c8ee4a012dae506ae06bb5b2ad50942b04c1aaaa, c2c352456a4cf62dcc12f851138b04397675a445, b93a8879555d2fa7e7d4e00a275513a3a6338b35, b86e1331cb36634fd33677043b61fc0c1d8485bc, 44ddf14fd3346658c3223f13652073fafbfa48fa, a1a5840a6bb53e305ba02bcbeb215659342d0edb, 7465cb110ae5ec2e2ca73182caf5293f0efc8fd5, aad5349b3458bc3414e274b33fa86a1123901ff2, eca0907980d2769c449894a6277c60c1a306792f, 38626987c0cfd6e715cfcc6f4f1a1209191a03c5, e4a67f7ddcde6cd99348e9104bd7ed07074da44a, bb3c9990840a0fae2afc840b5952d7874785b112, 042d7adef0bdb9dc80e825c3997ace7519477c42, 99f1ea44fc7915b8b7b33bce4732fa8765fd3ac2, b81999f30c1516a70c153de51a0331d14c8faead
This commit is contained in:
Родитель
2f2755895e
Коммит
40a08ec487
|
@ -386602,7 +386602,7 @@
|
|||
"testharness"
|
||||
],
|
||||
"2dcontext/drawing-images-to-the-canvas/2d.drawImage.zerocanvas.html": [
|
||||
"2b10225d76ad749b305a966f055b79e43f949b78",
|
||||
"9050f39a7cca4caca0a113e0454415a940885995",
|
||||
"testharness"
|
||||
],
|
||||
"2dcontext/drawing-images-to-the-canvas/2d.drawImage.zerosource.html": [
|
||||
|
@ -389706,7 +389706,7 @@
|
|||
"support"
|
||||
],
|
||||
"2dcontext/tools/spec.yaml": [
|
||||
"4692cedcc0d1d5af9ac917fa19d3979e2129a933",
|
||||
"232dbb047756e3cef85089de215e492c3550f927",
|
||||
"support"
|
||||
],
|
||||
"2dcontext/tools/specextract.py": [
|
||||
|
@ -389722,7 +389722,7 @@
|
|||
"support"
|
||||
],
|
||||
"2dcontext/tools/tests2d.yaml": [
|
||||
"057e6bc1199bb897e84a0d2ed7efefb616ba978c",
|
||||
"b25e82429ec7963e85a760247906839f9e631b24",
|
||||
"support"
|
||||
],
|
||||
"2dcontext/tools/tests2dtext.yaml": [
|
||||
|
@ -567962,11 +567962,11 @@
|
|||
"testharness"
|
||||
],
|
||||
"offscreen-canvas/drawing-images-to-the-canvas/2d.drawImage.zerocanvas.html": [
|
||||
"6af600ae8e09335caac85715358736fe9939bc93",
|
||||
"64541bbd1d8ceff92a5c2a69821572c8d1483dfd",
|
||||
"testharness"
|
||||
],
|
||||
"offscreen-canvas/drawing-images-to-the-canvas/2d.drawImage.zerocanvas.worker.js": [
|
||||
"0714f09495ad37384995324a0644047cb51e1533",
|
||||
"e097f9d9b64416668b3cac956af4f910b607524c",
|
||||
"testharness"
|
||||
],
|
||||
"offscreen-canvas/drawing-images-to-the-canvas/2d.drawImage.zerosource.html": [
|
||||
|
@ -572686,7 +572686,7 @@
|
|||
"support"
|
||||
],
|
||||
"offscreen-canvas/tools/tests2d.yaml": [
|
||||
"d2e4f9e53a36426b9d62f9e0969d31a46b88b6b3",
|
||||
"0e1cf2837f41da2e37a0a4786fba207a104e2e0b",
|
||||
"support"
|
||||
],
|
||||
"offscreen-canvas/transformations/2d.transformation.order.html": [
|
||||
|
|
|
@ -8,34 +8,29 @@
|
|||
<body class="show_output">
|
||||
|
||||
<h1>2d.drawImage.zerocanvas</h1>
|
||||
<p class="desc"></p>
|
||||
<p class="desc">drawImage with zero-sized canvas as the source shoud throw exception</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("");
|
||||
var t = async_test("drawImage with zero-sized canvas as the source shoud throw exception");
|
||||
_addTest(function(canvas, ctx) {
|
||||
|
||||
ctx.fillStyle = '#0f0';
|
||||
ctx.fillRect(0, 0, 100, 50);
|
||||
|
||||
var canvas2 = document.createElement('canvas');
|
||||
canvas2.width = 0;
|
||||
canvas2.height = 10;
|
||||
ctx.drawImage(canvas2, 0, 0);
|
||||
canvas2.height = 50;
|
||||
assert_throws("INVALID_STATE_ERR", function() { ctx.drawImage(canvas2, 0, 0); });
|
||||
|
||||
canvas2.width = 10;
|
||||
canvas2.width = 50;
|
||||
canvas2.height = 0;
|
||||
ctx.drawImage(canvas2, 0, 0);
|
||||
assert_throws("INVALID_STATE_ERR", function() { ctx.drawImage(canvas2, 0, 0); });
|
||||
|
||||
canvas2.width = 0;
|
||||
canvas2.height = 0;
|
||||
ctx.drawImage(canvas2, 0, 0);
|
||||
|
||||
_assertPixelApprox(canvas, 50,25, 0,255,0,255, "50,25", "0,255,0,255", 2);
|
||||
assert_throws("INVALID_STATE_ERR", function() { ctx.drawImage(canvas2, 0, 0); });
|
||||
|
||||
|
||||
});
|
||||
|
|
|
@ -586,7 +586,7 @@ assertions:
|
|||
text: "If the image argument is <...> an HTMLVideoElement object whose readyState attribute is either HAVE_NOTHING or HAVE_METADATA<^>, then the implementation *must* return without drawing anything."
|
||||
- id: 2d.drawImage.zerocanvas
|
||||
previously: [ 10, "dw and dh" ]
|
||||
text: "If the image argument is an HTMLCanvasElement object with either a horizontal dimension or a vertical dimension equal to zero, then the implementation *must* return without drawing anything<^>."
|
||||
text: "If the image argument is an HTMLCanvasElement or an OffscreenCanvas object with either a horizontal dimension or a vertical dimension equal to zero, then the implementation *must* throw an INVALID_STATE_ERR exception<^>."
|
||||
- id: 2d.drawImage.zerosource
|
||||
text: "If one of the sw or sh arguments is zero<^>, the implementation *must* return without drawing anything."
|
||||
- id: 2d.drawImage.paint
|
||||
|
|
|
@ -9002,27 +9002,22 @@
|
|||
expected: green
|
||||
|
||||
- name: 2d.drawImage.zerocanvas
|
||||
desc: drawImage with zero-sized canvas as the source shoud throw exception
|
||||
testing:
|
||||
- 2d.drawImage.zerocanvas
|
||||
code: |
|
||||
ctx.fillStyle = '#0f0';
|
||||
ctx.fillRect(0, 0, 100, 50);
|
||||
|
||||
var canvas2 = document.createElement('canvas');
|
||||
canvas2.width = 0;
|
||||
canvas2.height = 10;
|
||||
ctx.drawImage(canvas2, 0, 0);
|
||||
canvas2.height = 50;
|
||||
@assert throws INVALID_STATE_ERR ctx.drawImage(canvas2, 0, 0);
|
||||
|
||||
canvas2.width = 10;
|
||||
canvas2.width = 50;
|
||||
canvas2.height = 0;
|
||||
ctx.drawImage(canvas2, 0, 0);
|
||||
@assert throws INVALID_STATE_ERR ctx.drawImage(canvas2, 0, 0);
|
||||
|
||||
canvas2.width = 0;
|
||||
canvas2.height = 0;
|
||||
ctx.drawImage(canvas2, 0, 0);
|
||||
|
||||
@assert pixel 50,25 ==~ 0,255,0,255;
|
||||
expected: green
|
||||
@assert throws INVALID_STATE_ERR ctx.drawImage(canvas2, 0, 0);
|
||||
|
||||
- name: 2d.drawImage.svg
|
||||
desc: drawImage() of an SVG image
|
||||
|
|
|
@ -16,17 +16,16 @@ t.step(function() {
|
|||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
ctx.fillStyle = '#0f0';
|
||||
ctx.fillRect(0, 0, 100, 50);
|
||||
var offscreenCanvas2 = new OffscreenCanvas(0, 10);
|
||||
ctx.drawImage(offscreenCanvas2, 0, 0);
|
||||
assert_throws("INVALID_STATE_ERR", function() { ctx.drawImage(offscreenCanvas2, 0, 0); });
|
||||
|
||||
offscreenCanvas2.width = 10;
|
||||
offscreenCanvas2.height = 0;
|
||||
ctx.drawImage(offscreenCanvas2, 0, 0);
|
||||
assert_throws("INVALID_STATE_ERR", function() { ctx.drawImage(offscreenCanvas2, 0, 0); });
|
||||
|
||||
offscreenCanvas2.width = 0;
|
||||
offscreenCanvas2.height = 0;
|
||||
ctx.drawImage(offscreenCanvas2, 0, 0);
|
||||
_assertPixelApprox(offscreenCanvas, 50,25, 0,255,0,255, "50,25", "0,255,0,255", 2);
|
||||
assert_throws("INVALID_STATE_ERR", function() { ctx.drawImage(offscreenCanvas2, 0, 0); });
|
||||
|
||||
t.done();
|
||||
|
||||
|
|
|
@ -12,17 +12,16 @@ t.step(function() {
|
|||
var offscreenCanvas = new OffscreenCanvas(100, 50);
|
||||
var ctx = offscreenCanvas.getContext('2d');
|
||||
|
||||
ctx.fillStyle = '#0f0';
|
||||
ctx.fillRect(0, 0, 100, 50);
|
||||
var offscreenCanvas2 = new OffscreenCanvas(0, 10);
|
||||
ctx.drawImage(offscreenCanvas2, 0, 0);
|
||||
assert_throws("INVALID_STATE_ERR", function() { ctx.drawImage(offscreenCanvas2, 0, 0); });
|
||||
|
||||
offscreenCanvas2.width = 10;
|
||||
offscreenCanvas2.height = 0;
|
||||
ctx.drawImage(offscreenCanvas2, 0, 0);
|
||||
assert_throws("INVALID_STATE_ERR", function() { ctx.drawImage(offscreenCanvas2, 0, 0); });
|
||||
|
||||
offscreenCanvas2.width = 0;
|
||||
offscreenCanvas2.height = 0;
|
||||
ctx.drawImage(offscreenCanvas2, 0, 0);
|
||||
_assertPixelApprox(offscreenCanvas, 50,25, 0,255,0,255, "50,25", "0,255,0,255", 2);
|
||||
assert_throws("INVALID_STATE_ERR", function() { ctx.drawImage(offscreenCanvas2, 0, 0); });
|
||||
|
||||
t.done();
|
||||
|
||||
|
|
|
@ -4417,17 +4417,16 @@
|
|||
testing:
|
||||
- 2d.drawImage.zerocanvas
|
||||
code: |
|
||||
ctx.fillStyle = '#0f0';
|
||||
ctx.fillRect(0, 0, 100, 50);
|
||||
var offscreenCanvas2 = new OffscreenCanvas(0, 10);
|
||||
ctx.drawImage(offscreenCanvas2, 0, 0);
|
||||
@assert throws INVALID_STATE_ERR ctx.drawImage(offscreenCanvas2, 0, 0);
|
||||
|
||||
offscreenCanvas2.width = 10;
|
||||
offscreenCanvas2.height = 0;
|
||||
ctx.drawImage(offscreenCanvas2, 0, 0);
|
||||
@assert throws INVALID_STATE_ERR ctx.drawImage(offscreenCanvas2, 0, 0);
|
||||
|
||||
offscreenCanvas2.width = 0;
|
||||
offscreenCanvas2.height = 0;
|
||||
ctx.drawImage(offscreenCanvas2, 0, 0);
|
||||
@assert pixel 50,25 ==~ 0,255,0,255;
|
||||
@assert throws INVALID_STATE_ERR ctx.drawImage(offscreenCanvas2, 0, 0);
|
||||
|
||||
- name: 2d.drawImage.wrongtype
|
||||
desc: Incorrect image types in drawImage do not match any defined overloads, so WebIDL throws a TypeError
|
||||
|
|
Загрузка…
Ссылка в новой задаче