Skip to content

Commit efde053

Browse files
graveljpchromium-wpt-export-bot
authored andcommitted
Split 2d-invalid-size-context-lost.html into test variants
With this change, each canvas types (HTMLCanvasElement, OffscreenCanvas, offscreen + placeholder, etc.) run into different test instances. This makes each of these instances run faster (potentially avoiding timeouts). This will also be useful in a follow-up CL (https://crrev.com/c/7770807), where tests will be added to validate GPU process loss. Tests are normally running one after the other, so an individual test can kill and restore the GPU process without impacting the others. But this is not true for worker tests because workers run in a parallel thread. Killing the GPU process in the main thread would break the test running in the worker. The solution to this is to run the workers in a different variant, which will either run with a different test runner, or before/after other variants. Change-Id: I95ec34c070d0908e687b5d7c8d207c2e012f585e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7770727 Commit-Queue: Jean-Philippe Gravel <jpgravel@chromium.org> Reviewed-by: Vasiliy Telezhnikov <vasilyt@chromium.org> Cr-Commit-Position: refs/heads/main@{#1617255}
1 parent b225b38 commit efde053

2 files changed

Lines changed: 31 additions & 6 deletions

File tree

html/canvas/resources/canvas-promise-test-worker.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
function canvasPromiseTest(
99
testBody, description,
1010
{testTypes = Object.values(CanvasTestType)} = {}) {
11-
if (testTypes.includes(CanvasTestType.WORKER)) {
11+
if (testTypes.includes(CanvasTestType.WORKER) &&
12+
isTestTypeEnabled(CanvasTestType.WORKER)) {
1213
promise_test(() => testBody(new OffscreenCanvas(300, 150),
1314
{canvasType: CanvasTestType.WORKER}),
1415
'Worker: ' + description);

html/canvas/resources/canvas-promise-test.js

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,21 @@ WORKER_CANVAS_TEST_TYPES = [
5151
CanvasTestType.WORKER,
5252
];
5353

54+
var enabledTestTypeVariant = null;
55+
setup(() => {
56+
const urlParams = new URLSearchParams(self.location.search);
57+
const testTypeVariant = urlParams.get('testType');
58+
if (testTypeVariant) {
59+
enabledTestTypeVariant = CanvasTestType[testTypeVariant.toUpperCase()];
60+
assert_true(!!enabledTestTypeVariant,
61+
`Unrecognized test type variant: ${testTypeVariant}`);
62+
}
63+
});
64+
65+
function isTestTypeEnabled(testType) {
66+
return enabledTestTypeVariant === null || enabledTestTypeVariant === testType;
67+
}
68+
5469
/**
5570
* Run `testBody` in a `promise_test` against multiple types of canvases. By
5671
* default, the test is executed against an HTMLCanvasElement, a main thread
@@ -66,7 +81,8 @@ WORKER_CANVAS_TEST_TYPES = [
6681
function canvasPromiseTest(
6782
testBody, description,
6883
{testTypes = DEFAULT_CANVAS_TEST_TYPES} = {}) {
69-
if (testTypes.includes(CanvasTestType.WORKER)) {
84+
if (testTypes.includes(CanvasTestType.WORKER) &&
85+
isTestTypeEnabled(CanvasTestType.WORKER)) {
7086
setup(() => {
7187
const currentScript = document.currentScript;
7288
assert_true(
@@ -79,7 +95,8 @@ function canvasPromiseTest(
7995
});
8096
}
8197

82-
if (testTypes.includes(CanvasTestType.HTML)) {
98+
if (testTypes.includes(CanvasTestType.HTML) &&
99+
isTestTypeEnabled(CanvasTestType.HTML)) {
83100
promise_test(async () => {
84101
if (!document.body) {
85102
document.documentElement.appendChild(document.createElement("body"));
@@ -91,19 +108,22 @@ function canvasPromiseTest(
91108
}, 'HTMLCanvasElement: ' + description);
92109
}
93110

94-
if (testTypes.includes(CanvasTestType.DETACHED_HTML)) {
111+
if (testTypes.includes(CanvasTestType.DETACHED_HTML) &&
112+
isTestTypeEnabled(CanvasTestType.DETACHED_HTML)) {
95113
promise_test(() => testBody(document.createElement('canvas'),
96114
{canvasType: CanvasTestType.DETACHED_HTML}),
97115
'Detached HTMLCanvasElement: ' + description);
98116
}
99117

100-
if (testTypes.includes(CanvasTestType.OFFSCREEN)) {
118+
if (testTypes.includes(CanvasTestType.OFFSCREEN) &&
119+
isTestTypeEnabled(CanvasTestType.OFFSCREEN)) {
101120
promise_test(() => testBody(new OffscreenCanvas(300, 150),
102121
{canvasType: CanvasTestType.OFFSCREEN}),
103122
'OffscreenCanvas: ' + description);
104123
}
105124

106-
if (testTypes.includes(CanvasTestType.PLACEHOLDER)) {
125+
if (testTypes.includes(CanvasTestType.PLACEHOLDER) &&
126+
isTestTypeEnabled(CanvasTestType.PLACEHOLDER)) {
107127
promise_test(async () => {
108128
if (!document.body) {
109129
document.documentElement.appendChild(document.createElement("body"));
@@ -122,6 +142,10 @@ function canvasPromiseTest(
122142
* via the `dependencies` parameter so that the worker could load them.
123143
*/
124144
function runCanvasTestsInWorker({dependencies = []} = {}) {
145+
if (!isTestTypeEnabled(CanvasTestType.WORKER)) {
146+
return;
147+
}
148+
125149
const currentScript = document.currentScript;
126150
// Keep track of whether runCanvasTestsInWorker was invoked on the current
127151
// script. `canvasPromiseTest` will fail if `runCanvasTestsInWorker` hasn't

0 commit comments

Comments
 (0)