Closed Bug 645792 Opened 14 years ago Closed 11 years ago

Implement correct behavior for getContext() failures

Categories

(Core :: Graphics: CanvasWebGL, defect)

x86_64
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla26

People

(Reporter: bjacob, Unassigned)

References

Details

(Whiteboard: webgl-conformance webgl-next)

Attachments

(1 file, 1 obsolete file)

We shoud: * return null and NOT generate an exception * generate a webglcontextcreationerror event As per the spec: http://www.khronos.org/registry/webgl/specs/latest/#5.14.3 Quote: webglcontextcreationerror This event occurs in response to a call to getContext() on the HTMLCanvasElement receiving the event, when some error occurs during that call. When such an error occurs the getContext() returns with a null value. Later, at the normal event delivery time, this event is delivered with the details of the failure. If the HTMLCanvasElement is listening for this event, it will be delivered whenever getContext() returns null. The statusMessage attribute may contain a platform dependent string about the nature of the failure.
I don't remember what the current status is, on whether we should generate an exception or not. Checking that is the first step here. http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-canvas-getcontext
Whiteboard: webgl-conformance webgl-next
This appears to still be the case. I'm amused that the 1.0.1 conformance suite doesn't test this. (Nor 1.0.2, I believe)
I didn't find any test either. I'm looking at the code in question, it seams to be very old... So the question I'm asking is: should we get away from stuff like: nsCOMPtr<nsICanvasRenderingContextInternal> ctx = do_CreateInstance(ctxString.get(), &rv); Should we re-write entirely HTMLCanvasElement::GetContextHelper and HTMLCanvasElement::GetContext?
Attached patch patch revision 1 (obsolete) — Splinter Review
Tested with a return false in WebGLContext::InitAndValidate and: > function init() { > outputInit(); > > var renderingCanvas = document.getElementById("renderingZone"); > > try > { > gl = renderingCanvas.getContext("experimental-webgl"); > } > catch (exp) > { > outputPrint("Test failed"); > return; > } > > outputPrint("Test passed"); > } https://tbpl.mozilla.org/?tree=Try&rev=a19e6557d5f5
Attachment #796641 - Flags: review?(bjacob)
Attached patch patch revision 2Splinter Review
This patch also fix unit tests using a try/catch in javascript.
Attachment #796641 - Attachment is obsolete: true
Attachment #796641 - Flags: review?(bjacob)
Attachment #796722 - Flags: review?(bjacob)
Attachment #796722 - Flags: review?(bjacob) → review+
Status: NEW → RESOLVED
Closed: 11 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Depends on: 1244480
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: