summaryrefslogtreecommitdiffstats
path: root/dom/canvas
diff options
context:
space:
mode:
Diffstat (limited to 'dom/canvas')
-rw-r--r--dom/canvas/CanvasRenderingContext2D.cpp12
-rw-r--r--dom/canvas/test/test_accelerated_canvas_context_loss.html12
2 files changed, 19 insertions, 5 deletions
diff --git a/dom/canvas/CanvasRenderingContext2D.cpp b/dom/canvas/CanvasRenderingContext2D.cpp
index 1a79a9f734..54711aa981 100644
--- a/dom/canvas/CanvasRenderingContext2D.cpp
+++ b/dom/canvas/CanvasRenderingContext2D.cpp
@@ -2216,14 +2216,16 @@ void CanvasRenderingContext2D::Transform(double aM11, double aM12, double aM21,
already_AddRefed<DOMMatrix> CanvasRenderingContext2D::GetTransform(
ErrorResult& aError) {
- if (!EnsureTarget(aError)) {
+ // If we are silently failing, then we still need to return a transform while
+ // we are in the process of recovering.
+ Matrix transform;
+ if (EnsureTarget(aError)) {
+ transform = mTarget->GetTransform();
+ } else if (aError.Failed()) {
return nullptr;
}
- MOZ_ASSERT(IsTargetValid());
-
- RefPtr<DOMMatrix> matrix =
- new DOMMatrix(GetParentObject(), mTarget->GetTransform());
+ RefPtr<DOMMatrix> matrix = new DOMMatrix(GetParentObject(), transform);
return matrix.forget();
}
diff --git a/dom/canvas/test/test_accelerated_canvas_context_loss.html b/dom/canvas/test/test_accelerated_canvas_context_loss.html
index 6172420bcb..610c8d8fc3 100644
--- a/dom/canvas/test/test_accelerated_canvas_context_loss.html
+++ b/dom/canvas/test/test_accelerated_canvas_context_loss.html
@@ -58,6 +58,12 @@ let countRestoredEvents = 0;
function onContextLost() {
ok(context.isContextLost(), "Canvas context should be lost during contextlost event");
+
+ try {
+ let transform = context.getTransform();
+ ok(transform.isIdentity, "Canvas context should return identity transform while context lost");
+ } catch (e) {}
+
countLostEvents += 1;
}
@@ -88,6 +94,12 @@ async function start() {
ok(!context.isContextLost(), "Canvas context should not be lost after initial fill");
+ let transform = context.getTransform();
+ ok(transform.isIdentity, "Canvas context should default to identity transform");
+ context.setTransform(2.0, 3.0, 4.0, 5.0, 6.0, 7.0);
+ transform = context.getTransform();
+ ok(!transform.isIdentity, "Canvas context should have non-identity transform");
+
const restarted = await restartGPUProcess();
const expectedEvents = restarted ? 1 : 0;