mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-17 14:25:49 +00:00
Bug 1776940 - Part 1: Test should expect canvas readback to succeed when video element's readyState is HAVE_METADATA in test_mixed_principals.html r=aosmond
The test was failing when `readyState == HAVE_METADATA`, which happens ~5% of the time. In this state, we return from `nsLayoutUtils::SurfaceFromElement` early [here](https://searchfox.org/mozilla-central/rev/b580e3f77470b2337bc8ae032b58a85c11e66aba/layout/base/nsLayoutUtils.cpp#7569-7573) in [accordance with the spec](https://html.spec.whatwg.org/multipage/canvas.html#check-the-usability-of-the-image-argument), which means that we never hit [this statement](https://searchfox.org/mozilla-central/rev/b580e3f77470b2337bc8ae032b58a85c11e66aba/layout/base/nsLayoutUtils.cpp#7593-7594) where we would set `mIsWriteOnly` to `true`. Since `mIsWriteOnly` is false, the test fails since the readback attempt succeeds [here](https://searchfox.org/mozilla-central/rev/b580e3f77470b2337bc8ae032b58a85c11e66aba/dom/media/test/test_mixed_principals.html#60-64). In this situation, it appears that the canvas has never actually been written to, as `toDataURL` returns an empty canvas. This seems to match step 3 in [the standard](https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-drawimage), which is to return without drawing anything to the canvas. This return happens before step 7 when we mark `origin-clean` as `false`, and so the canvas is never set to write-only. Since the code appears to be within spec, the fix for the test is to expect readback to succeed when `readyState` is `HAVE_METADATA`, and fail when it is not. A possible issue with this is that what we end up with in `readyState` nondeterministically changes from test to test, and I'm not sure how we'd force both particular states given the test setup. Differential Revision: https://phabricator.services.mozilla.com/D197553
This commit is contained in:
parent
256866b361
commit
f57f525829
@ -32,7 +32,13 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=489415
|
||||
var ctx = c.getContext("2d");
|
||||
ctx.drawImage(video, 0, 0);
|
||||
try {
|
||||
c.toDataURL();
|
||||
var data_url = c.toDataURL();
|
||||
var empty_canvas = document.createElement("canvas");
|
||||
if (empty_canvas.toDataURL() === data_url) {
|
||||
info("Readback check returned same data URL as empty canvas.");
|
||||
} else {
|
||||
info("Readback check returned different data URL than empty canvas.");
|
||||
}
|
||||
return true;
|
||||
} catch (ex) {
|
||||
return false;
|
||||
@ -58,7 +64,12 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=489415
|
||||
});
|
||||
|
||||
once(video, "error", () => {
|
||||
is(canReadBack(video), false, "Should not be able to readback after error");
|
||||
if(video.readyState == video.HAVE_METADATA) {
|
||||
is(canReadBack(video), true, "Should be able to readback with readyState == HAVE_METADATA");
|
||||
} else {
|
||||
is(canReadBack(video), false, "Should not be able to readback with readyState != HAVE_METADATA");
|
||||
}
|
||||
|
||||
removeNodeAndSource(video);
|
||||
resolve();
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user