Closed Bug 1217031 Opened 10 years ago Closed 10 years ago

createPattern throws NS_ERROR_NOT_AVAILABLE

Categories

(Core :: Graphics: Canvas2D, defect)

40 Branch
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla49
Tracking Status
firefox49 --- fixed

People

(Reporter: tenner.joshua, Assigned: mkohler)

Details

(Whiteboard: gfx-noted)

Attachments

(3 files, 3 obsolete files)

Attached image Example Of Code run
User Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36 Steps to reproduce: Use createPattern on an image with a dataurl in the same context. var img = new Image(); img.src = 'data:image/gif;base64,...'; ctx.createPattern(img, 'no-repeat); Visit: http://codepen.io/jtenner/pen/PPELad?editors=001 This is a codepen that creates a pattern from a dataurl (an asterisk) and fills a rect on the screen with the pattern. Normally I would wait for the image to load, but chrome, IE, and opera don't seem to have a problem with this. If the image is cached this problem doesn't occur. Repeated refreshes will show the asterisk but a hard refresh (ctrl-f5) reproduces the issue. I happen to be maintaining a JavaScript library so I was just curious if this is normal proposed behavior for the browser? Actual results: Firefox throws: "NS_ERROR_NOT_AVAILABLE:" Expected results: It should create a fill pattern, I think.
Component: Untriaged → Canvas: 2D
Product: Firefox → Core
Summary: createPattern throws → createPattern throws NS_ERROR_NOT_AVAILABLE
Attached file test.html
Sounds like a spec question.
Flags: needinfo?(jmuizelaar)
Whiteboard: gfx-noted
It sounds like this behaviour is according to spec. See https://bugzilla.mozilla.org/show_bug.cgi?id=1164458#c6
Flags: needinfo?(jmuizelaar)
Status: UNCONFIRMED → RESOLVED
Closed: 10 years ago
Resolution: --- → DUPLICATE
Indeed. createPattern does exactly the same "Check the usability of the image argument" that drawImage does and the rest of the spec behavior is described in bug 1164458 comment 9. That said, on "bad" return it should return null, not throw. So if we're throwing, that's clearly buggy per spec.
Status: RESOLVED → REOPENED
Ever confirmed: true
Resolution: DUPLICATE → ---
Of course the IDL for createPattern says it never returns null, so speccing it to return null is quite odd. ;)
Flags: needinfo?(annevk)
https://github.com/whatwg/html/issues/655 filed on the spec self-inconsistency wrt null.
Seems like the resolution here is that we'll change the specification to make that nullable. (ETA for that change is unknown, the more experienced editors try to leave "good first bug" issues alone.)
Flags: needinfo?(annevk)
I just wanted to be clear: (In reply to Boris Zbarsky [:bz] from comment #6) > Of course the IDL for createPattern says it never returns null, so speccing > it to return null is quite odd. ;) This is exactly the problem :). Also, I didn't mean to file a duplicate issue. I searched for createPattern and fillStyle to check and make sure I wasn't wasting people's time. Looks like this is being taken care of. Thanks everyone!
Attached patch canvas_createPattern.patch (obsolete) — Splinter Review
This also includes two removals of trailing whitespaces, I can take them out if you want me too.
Assignee: nobody → mkohler
Attachment #8732544 - Flags: review?(bas)
Attachment #8732544 - Flags: review?(bas) → review?(gwright)
Attachment #8732544 - Flags: review?(gwright) → review+
Keywords: checkin-needed
Attached patch bug_1217031.patch_commitmessage (obsolete) — Splinter Review
Attachment #8732544 - Attachment is obsolete: true
Attachment #8744590 - Flags: review+
Whiteboard: gfx-noted → checkin-needed
Keywords: checkin-needed
Whiteboard: checkin-needed
Whiteboard: gfx-noted
For future reference, your commit messages should be explaining what the patch is actually doing, not just restating the problem they're solving.
Also, webidl changes need review from a DOM peer.
Keywords: checkin-needed
Attachment #8744590 - Attachment is obsolete: true
Attachment #8744734 - Flags: review?(bzbarsky)
Comment on attachment 8744734 [details] [diff] [review] bug_1217031_goodcommitmessage.patch r=me if security check failure is the only way res.GetSourceSurface() can return null. If there are other reasons (e.g. OOM), we should probably pass an Errorresult to either SurfaceFromElement or GetSourceSurface to throw an exception on it as needed.
Attachment #8744734 - Flags: review?(bzbarsky) → review+
Seems like this needs a test
Flags: needinfo?(me)
Looks like the test expectations needs to be updated; we're now passing the test when we used to fail it. Note that this means we don't actually need to add another test. ;)
Attachment #8744734 - Attachment is obsolete: true
Flags: needinfo?(me)
Attachment #8748292 - Flags: review?(bzbarsky)
Comment on attachment 8748292 [details] [diff] [review] 0001-Bug-1217031-createPattern-should-not-throw-NS_ERROR_.patch r=me
Attachment #8748292 - Flags: review?(bzbarsky) → review+
Keywords: checkin-needed
Status: REOPENED → RESOLVED
Closed: 10 years ago10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla49
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: