Closed Bug 1135244 Opened 5 years ago Closed 5 years ago

CanvasRenderingContext2D not allowing polyfill

Categories

(Core :: Canvas: 2D, defect)

31 Branch
x86
Windows 7
defect
Not set

Tracking

()

RESOLVED INVALID

People

(Reporter: tyler, Unassigned)

References

Details

(Keywords: regression)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.111 Safari/537.36

Steps to reproduce:

Upon using a well-known polyfill (canvas-5-polyfill*) to add an ellipse method to the CanvasRenderingContext2D prototype, we noticed that Firefox 3.5.01 regressed and does not allow the method to be added via a script.

1) include polyfill script in <head>
2) add a canvas to the page
3) ctx = getContext('2d')
4) note that ctx.ellipse is undefined


Actual results:

The ellipse method remained undefined, although the script adding it to the CanvasRenderingContext2D prototype had fully loaded and executed before the getContext('2d') call.

This polyfill worked with Firefox v. 30 (and continues to work with IE9 & 10).


Expected results:

Until Firefox supports the ellipse function and other canvas v5 capabilities (https://bugzilla.mozilla.org/show_bug.cgi?id=910138), developers should at least be able to augment the existing Context2D object. Polyfills such as canvas-5-polyfill library have become the industry-standard way of adopting new features that may not be supported in all browsers.

* https://github.com/google/canvas-5-polyfill
OS: Mac OS X → Windows 7
Note, we first noticed this on Windows 7, but I just confirmed the same behavior on Mac OS-X after updating from FF v. 30.
Could you upload a simple test file? It'd also be useful to know in which version exactly this would have regressed.
Component: Untriaged → Canvas: 2D
Flags: needinfo?(tyler)
Product: Firefox → Core
Here is a JSFiddle showing the issue:
http://jsfiddle.net/rhf3wdwq/1/

An ellipse is drawn in:

Firefox v. 22 (Win 7 pro)
Internet Explorer 10.0.9 (Win 7 pro)
Chrome 40.0.2214.111 (native method)

An ellipse is NOT drawn and the method is undefined despite the polyfill in FF 35.0.1 on OS-X and Windows.

Unfortunately I can't pinpoint where between version 30 and 35.0.1 the regression occurred, but it was functioning in 30 before I updated.
Flags: needinfo?(tyler)
Flags: needinfo?(cabanier)
Version: 35 Branch → 31 Branch
I'm unsure why this was assigned to me. I don't think the addition of path2d changes polyfilll behavior.
(In reply to Rik Cabanier from comment #5)
> I'm unsure why this was assigned to me. I don't think the addition of path2d
> changes polyfilll behavior.

ctx.ellipse is undefined after landing Bug 988409 you assigned.
(In reply to Alice0775 White from comment #6)
> (In reply to Rik Cabanier from comment #5)
> > I'm unsure why this was assigned to me. I don't think the addition of path2d
> > changes polyfilll behavior.
> 
> ctx.ellipse is undefined after landing Bug 988409 you assigned.

How did you come to that conclusion? Does it work if you turn the pref off?
Flags: needinfo?(cabanier)
Looks like a bug in the library. <https://github.com/google/canvas-5-polyfill/blob/master/canvasv5.js> does roughly:

if (typeof Path2D !== 'function') {
  if (CanvasRenderingContext2D.prototype.ellipse == undefined) {
    CanvasRenderingContext2D.prototype.ellipse = ...
Status: UNCONFIRMED → RESOLVED
Closed: 5 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.