Skip to content

Commit

Permalink
Bug 1700286 [wpt PR 28182] - Decrease canvas size in 2d.text.draw.gen…
Browse files Browse the repository at this point in the history
…eric.family, a=testonly

Automatic update from web-platform-tests
Decrease canvas size in 2d.text.draw.generic.family (#28182)

Comparing several over-sized canvases makes this test take much longer
than it needs to, decrease the font-size and trim the canvas size.
--

wpt-commits: 98167adbefd53a727efe724df9d5a588c8295d59
wpt-pr: 28182
  • Loading branch information
Cwiiis authored and moz-wptsync-bot committed Mar 27, 2021
1 parent fbbb639 commit 692f6be
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@
<script>
function drawCanvas(ctx, family)
{
ctx.font = '32px ' + family;
ctx.fillText(family, 0, 32);
ctx.font = '16px ' + family;
ctx.fillText(family, 0, 16);
}

function testDrawGenericFamily(family)
{
let offscreenCanvas = new OffscreenCanvas(300, 150);
let offscreenCanvas = new OffscreenCanvas(88, 24);
let oCtx = offscreenCanvas.getContext('2d');
drawCanvas(oCtx, family);
let canvas = document.createElement('canvas');
let ctx = canvas.getContext('2d');
drawCanvas(ctx, family);

let data1 = oCtx.getImageData(0, 0, 300, 150).data;
let data2 = ctx.getImageData(0, 0, 300, 150).data;
let data1 = oCtx.getImageData(0, 0, 88, 24).data;
let data2 = ctx.getImageData(0, 0, 88, 24).data;
assert_array_equals(data1, data2,
"The image data generated by drawing generic font family '" + family +
"' should be the same for both OffscreenCanvas and regular canvas");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
<script src="/html/canvas/resources/canvas-tests.js"></script>
<script id='myWorker' type='text/worker'>
self.onmessage = function(e) {
let oc = new OffscreenCanvas(300, 150);
let oc = new OffscreenCanvas(88, 24);
let ctx = oc.getContext('2d');
ctx.font = '32px ' + e.data.family;
ctx.fillText(e.data.family, 0, 32);
self.postMessage(ctx.getImageData(0, 0, 300, 150).data);
ctx.fillText(e.data.family, 0, 16);
self.postMessage(ctx.getImageData(0, 0, 88, 24).data);
};
</script>
<script>
Expand All @@ -20,8 +20,8 @@
worker.addEventListener('message', msg => {
let ctx = document.createElement('canvas').getContext('2d');
ctx.font = '32px ' + family;
ctx.fillText(family, 0, 32);
assert_array_equals(ctx.getImageData(0, 0, 300, 150).data, msg.data,
ctx.fillText(family, 0, 16);
assert_array_equals(ctx.getImageData(0, 0, 88, 24).data, msg.data,
"The image data generated by drawing generic font family '" + family +
"' should be the same for both OffscreenCanvas and regular canvas");
t.done();
Expand Down

0 comments on commit 692f6be

Please sign in to comment.