From 3b926816f1f81fdf9e7f7031e6dffa7f00695b65 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Tue, 12 Jul 2011 12:06:34 -0400 Subject: [PATCH] Bug 670452. Fix WindowSnapshot's windowutils codepath to work correctly for canvases of different sizes. r=joe --- .../mochitest/tests/SimpleTest/WindowSnapshot.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/testing/mochitest/tests/SimpleTest/WindowSnapshot.js b/testing/mochitest/tests/SimpleTest/WindowSnapshot.js index 4e1ee054c735..a838cfabac5e 100644 --- a/testing/mochitest/tests/SimpleTest/WindowSnapshot.js +++ b/testing/mochitest/tests/SimpleTest/WindowSnapshot.js @@ -36,7 +36,19 @@ function compareSnapshots(s1, s2, expected) { var s1Str, s2Str; var correct = false; if (gWindowUtils) { - correct = ((gWindowUtils.compareCanvases(s1, s2, {}) == 0) == expected); + // First, check that the canvases are the same size. + var equal; + if (s1.width != s2.width || s1.height != s2.height) { + equal = false; + } else { + try { + equal = (gWindowUtils.compareCanvases(s1, s2, {}) == 0); + } catch (e) { + equal = false; + ok(false, "Exception thrown from compareCanvases: " + e); + } + } + correct = (equal == expected); } if (!correct) {