Skip to content

Commit 0bb9469

Browse files
graveljpchromium-wpt-export-bot
authored andcommitted
Extend context loss/restoration test coverage to desynchronized canvas
Desynchronize canvases use a resource dispatcher to push frames and since the dispatcher is descarded on context loss [1], it's worth adding test coverage for this. Note that the frame dispatcher is never recreated after the context is restored, so the canvas doesn't fully recover from the context loss. The canvas can be read back though, so the tests still works and we can at least validate that the context state transitions work properly. Also note that the OffscreenCanvas doesn't do much with the `desynchronized` flag, but the test coverage is still useful given that this flag is listed as supported in MDN [1] and the specification [2]. [1] https://crsrc.org/c/third_party/blink/renderer/modules/canvas/canvas2d/canvas_rendering_context_2d.cc;l=290;drc=8abea14deda089834ba142a35e8342014812df55 [2] https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvas/getContext [3] https://html.spec.whatwg.org/multipage/canvas.html#canvas-setting-init-bitmap Change-Id: I300d1f2827406120896cc7dc38794cb450ea3ed5 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7770647 Reviewed-by: Vasiliy Telezhnikov <vasilyt@chromium.org> Commit-Queue: Jean-Philippe Gravel <jpgravel@chromium.org> Cr-Commit-Position: refs/heads/main@{#1617254}
1 parent e852977 commit 0bb9469

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,13 @@ function runCanvasTestsInWorker({dependencies = []} = {}) {
144144
const dependencyScripts =
145145
await Promise.all(allDeps.map(dep => fetch(dep).then(r => r.text())));
146146
const canvasTests = currentScript.textContent;
147-
const allScripts = dependencyScripts.concat([canvasTests, 'done();']);
147+
const allScripts = [
148+
// Forward `location.search` to the worker so that it could run the right
149+
// test variants. `location.search` is read-only in workers, so the whole
150+
// object has to be replaced.
151+
`var location = {search: '${self.location.search}'};`,
152+
].concat(dependencyScripts)
153+
.concat([canvasTests, 'done();']);
148154

149155
const workerBlob = new Blob(allScripts);
150156
const worker = new Worker(URL.createObjectURL(workerBlob));

0 commit comments

Comments
 (0)