Skip to content

Commit

Permalink
Fix a "Worker" test type error (#40240)
Browse files Browse the repository at this point in the history
* Add a "Worker" test type, separate from "OffscreenCanvas".

This will allow writing tests that work HtmlCanvas and OffscreenCanvas,
but not Worker. For example, the test 2d.fillStyle.CSSHSL.html exists
for both element and offscreen, but it can't be implemented for
workers because workers can't use the CSSHSL interface.

Change-Id: Iec0c07e2942e7e063183763ed02d29f57451bee2
Bug: 1275750
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4557546
Reviewed-by: Yi Xu <yiyix@chromium.org>
Commit-Queue: Jean-Philippe Gravel <jpgravel@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1148821}

* Add a "Worker" test type, separate from "OffscreenCanvas".

This will allow writing tests that work HtmlCanvas and OffscreenCanvas,
but not Worker. For example, the test 2d.fillStyle.CSSHSL.html exists
for both element and offscreen, but it can't be implemented for
workers because workers can't use the CSSHSL interface.

Change-Id: Iec0c07e2942e7e063183763ed02d29f57451bee2
Bug: 1275750
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4557546
Reviewed-by: Yi Xu <yiyix@chromium.org>
Commit-Queue: Jean-Philippe Gravel <jpgravel@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1148821}

---------

Co-authored-by: Jean-Philippe Gravel <jpgravel@chromium.org>
  • Loading branch information
sj0602 and graveljp authored May 25, 2023
1 parent af24983 commit c50c860
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions html/canvas/tools/yaml-new/compositing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@
expected: green

- name: 2d.composite.globalAlpha.canvas
canvasType: ['OffscreenCanvas']
canvasType: ['OffscreenCanvas', 'Worker']
code: |
var offscreenCanvas2 = new OffscreenCanvas(100, 50);
var ctx2 = offscreenCanvas2.getContext('2d');
Expand Down Expand Up @@ -203,7 +203,7 @@
expected: green

- name: 2d.composite.globalAlpha.canvaspattern
canvasType: ['OffscreenCanvas']
canvasType: ['OffscreenCanvas', 'Worker']
code: |
var offscreenCanvas2 = new OffscreenCanvas(100, 50);
var ctx2 = offscreenCanvas2.getContext('2d');
Expand All @@ -218,7 +218,7 @@
@assert pixel 50,25 ==~ 2,253,0,255;
- name: 2d.composite.globalAlpha.canvascopy
canvasType: ['OffscreenCanvas']
canvasType: ['OffscreenCanvas', 'Worker']
code: |
var offscreenCanvas2 = new OffscreenCanvas(100, 50);
var ctx2 = offscreenCanvas2.getContext('2d');
Expand Down
10 changes: 5 additions & 5 deletions html/canvas/tools/yaml-new/drawing-images-to-the-canvas.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@
@assert pixel 99,49 ==~ 0,255,0,255;
- name: 2d.drawImage.canvas
canvasType: ['OffscreenCanvas']
canvasType: ['OffscreenCanvas', 'Worker']
code: |
var offscreenCanvas2 = new OffscreenCanvas(100, 50);
var ctx2 = offscreenCanvas2.getContext('2d');
Expand All @@ -357,7 +357,7 @@
@assert pixel 99,49 ==~ 0,255,0,255;
- name: 2d.drawImage.zerocanvas
canvasType: ['OffscreenCanvas']
canvasType: ['OffscreenCanvas', 'Worker']
code: |
var offscreenCanvas2 = new OffscreenCanvas(0, 10);
@assert throws INVALID_STATE_ERR ctx.drawImage(offscreenCanvas2, 0, 0);
Expand Down Expand Up @@ -424,7 +424,7 @@
- name: 2d.drawImage.zerosource.image
desc: drawImage with zero-sized source rectangle from image draws nothing without exception
test_type: promise
canvasType: ['OffscreenCanvas']
canvasType: ['OffscreenCanvas', 'Worker']
code: |
ctx.fillStyle = '#0f0';
ctx.fillRect(0, 0, 100, 50);
Expand Down Expand Up @@ -519,7 +519,7 @@

- name: 2d.drawImage.outsidesource
DISABLED: fix this to match the current spec (transparent black outside source)
canvasType: ['OffscreenCanvas']
canvasType: ['OffscreenCanvas', 'Worker']
code: |
const response_red = await fetch('/images/red.png');
const blob_red = await response_red.blob();
Expand Down Expand Up @@ -572,7 +572,7 @@
- name: 2d.drawImage.svg
desc: drawImage() of an SVG image
test_type: promise
canvasType: ['OffscreenCanvas']
canvasType: ['OffscreenCanvas', 'Worker']
code: |
var promise = new Promise(function(resolve, reject) {
var xhr = new XMLHttpRequest();
Expand Down
2 changes: 1 addition & 1 deletion html/canvas/tools/yaml-new/filters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
- name: 2d.filter.canvasFilterObject.tentative
desc: Test CanvasFilter() object
canvasType: ['OffscreenCanvas']
canvasType: ['OffscreenCanvas', 'Worker']
code: |
@assert ctx.filter == 'none';
ctx.filter = 'blur(5px)';
Expand Down
4 changes: 2 additions & 2 deletions html/canvas/tools/yaml-new/layers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@
variants:
convertToBlob:
test_type: "promise"
canvasType: ['OffscreenCanvas']
canvasType: ['OffscreenCanvas', 'Worker']
flush_canvas: |-
await canvas.convertToBlob();
createImageBitmap:
Expand Down Expand Up @@ -352,7 +352,7 @@
- name: 2d.layer.render-opportunities.transferToImageBitmap
desc: Checks that transferToImageBitmap flushes and rebuilds the state stack.
size: 200, 200
canvasType: ['OffscreenCanvas']
canvasType: ['OffscreenCanvas', 'Worker']
code: |
ctx.fillStyle = 'purple';
ctx.fillRect(60, 60, 75, 50);
Expand Down
2 changes: 1 addition & 1 deletion html/canvas/tools/yaml-new/pixel-manipulation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -818,7 +818,7 @@

- name: 2d.imageData.put.cross
desc: putImageData() accepts image data got from a different canvas
canvasType: ['OffscreenCanvas']
canvasType: ['OffscreenCanvas', 'Worker']
code: |
var offscreenCanvas2 = new OffscreenCanvas(100, 50);
var ctx2 = offscreenCanvas2.getContext('2d');
Expand Down

0 comments on commit c50c860

Please sign in to comment.