From d2ad89c8f40b127e18bb8d6b888596e286740500 Mon Sep 17 00:00:00 2001 From: Guillaume Abadie Date: Thu, 29 Aug 2013 10:14:22 -0400 Subject: [PATCH] Bug 645792 - Replace throwing an exception by returning null on HTMLCanvasElement::GetContext. r=bjacob CLOSED TREE --- .../test/crossorigin/test_webgl_crossorigin_textures.html | 5 ++--- content/html/content/src/HTMLCanvasElement.cpp | 1 + dom/bindings/test/test_integers.html | 5 ++--- dom/bindings/test/test_sequence_wrapping.html | 5 ++--- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/content/canvas/test/crossorigin/test_webgl_crossorigin_textures.html b/content/canvas/test/crossorigin/test_webgl_crossorigin_textures.html index 29a5edee5a31..2ca9a342427b 100644 --- a/content/canvas/test/crossorigin/test_webgl_crossorigin_textures.html +++ b/content/canvas/test/crossorigin/test_webgl_crossorigin_textures.html @@ -66,9 +66,8 @@ MochiKit.DOM.addLoadEvent(function () { var canvas = document.getElementById("canvas"); - try { - gl = canvas.getContext("experimental-webgl"); - } catch (e) { + gl = canvas.getContext("experimental-webgl"); + if (!gl) { todo(false, "Canvas WebGL not supported"); SimpleTest.finish(); return; diff --git a/content/html/content/src/HTMLCanvasElement.cpp b/content/html/content/src/HTMLCanvasElement.cpp index 6b57910efdc3..21eee4079c87 100644 --- a/content/html/content/src/HTMLCanvasElement.cpp +++ b/content/html/content/src/HTMLCanvasElement.cpp @@ -804,6 +804,7 @@ HTMLCanvasElement::GetContext(JSContext* aCx, rv = UpdateContext(aCx, aContextOptions); if (rv.Failed()) { + rv = NS_OK; // See bug 645792 return nullptr; } mCurrentContextId.Assign(aContextId); diff --git a/dom/bindings/test/test_integers.html b/dom/bindings/test/test_integers.html index 0b1cdacea2fb..c74b68216c84 100644 --- a/dom/bindings/test/test_integers.html +++ b/dom/bindings/test/test_integers.html @@ -16,9 +16,8 @@ function testInt64NonFinite(arg) { // We can use a WebGLRenderingContext to test conversion to 64-bit signed // ints edge cases. - try { - var gl = $("c").getContext("experimental-webgl"); - } catch (ex) { + var gl = $("c").getContext("experimental-webgl"); + if (!gl) { // No WebGL support on MacOS 10.5. Just skip this test todo(false, "WebGL not supported"); return; diff --git a/dom/bindings/test/test_sequence_wrapping.html b/dom/bindings/test/test_sequence_wrapping.html index e4f18f9986c3..7132e56019d7 100644 --- a/dom/bindings/test/test_sequence_wrapping.html +++ b/dom/bindings/test/test_sequence_wrapping.html @@ -20,9 +20,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=775852 /** Test for Bug 775852 **/ function doTest() { - try { - var gl = $("c").getContext("experimental-webgl"); - } catch (e) { + var gl = $("c").getContext("experimental-webgl"); + if (!gl) { // No WebGL support on MacOS 10.5. Just skip this test todo(false, "WebGL not supported"); return;