Closed Bug 732716 Opened 12 years ago Closed 12 years ago

canvas.drawImage does not work in SDK 1.1-1.5 (it does work in 1.0) when injected using contentScriptFile for context-menu (injection using tab.attach works for all versions - 1.0-1.5)

Categories

(Add-on SDK Graveyard :: General, defect, P2)

defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: mingyiliu, Assigned: ochameau)

Details

Attachments

(3 files)

User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0.2) Gecko/20100101 Firefox/10.0.2
Build ID: 20120215223356

Steps to reproduce:

I made a demo addon at https://builder.addons.mozilla.org/addon/1043006/revision/6/

Once installed, user can right click on an image and choose "convert image to favicon" -> "16x16".


Actual results:

This error is thrown: 

[Exception... "Component returned failure code: 0x80040111 (NS_ERROR_NOT_AVAILABLE) [nsIDOMCanvasRenderingContext2D.drawImage]"  nsresult: "0x80040111 (NS_ERROR_NOT_AVAILABLE)"  location: "JS frame :: resource://jid0-iwx0m9sttnzsm7zvbazdhtqblze-at-jetpack/api-utils/lib/cuddlefish.js -> resource://jid0-iwx0m9sttnzsm7zvbazdhtqblze-at-jetpack/api-utils/lib/sandbox.js -> resource://jid0-iwx0m9sttnzsm7zvbazdhtqblze-at-jetpack/api-utils/data/content-proxy.js :: <TOP_LEVEL> :: line 100"  data: no]


Expected results:

There shouldn't be any error message. Instead an image of 16x16 size will appear along with its data URI encoded data.  This is the behavior when the addon is packed with SDK 1.0.  But when packed with SDK 1.1-1.5, the above error throws. Interestingly, if I injected the content script convert.js using tab.attach and then packed with SDK 1.0-1.5, canvas.drawImage call worked fine for all these versions.  This suggests that this issue is a pure bug, not a security restriction preventing canvas.drawImage from working.
With addon SDK1.6.1's clearer error message, I was able to figure out that this issue was due to the fact that the image node sent over by context-menu is NOT a real image node any more.  I didn't check the context-menu.js code, but I'm certain that's the case through my test.  That's why if one packs the addon using SDK1.6.1 one would see canvas.drawImage complaining the parameter type is incompatible.
Alex, is this the same security issue we were seeing elsewhere?
Assignee: nobody → poirot.alex
Whiteboard: [triage:followup]
No it should be the cross domain issue we are seing elsewhere.
The cross domain issue is for addons repacked from version older than 1.0b5.

We changed some code in context menu in order to fix context menu leak in 1.6.1,
it will be most likely due to these changes. Having said that, I looked at the code and the node shouldn't be wrapped on context menu click event.
We will have to take a deeper look at this one.
Are you still looking at this one, Alex?
Attached file Pull request 494
More details in pull request.
Attachment #642597 - Flags: review?(rFobic)
Priority: -- → P2
Whiteboard: [triage:followup]
Attachment #642597 - Flags: review?(rFobic) → review+
Commits pushed to master at https://github.com/mozilla/addon-sdk

https://github.com/mozilla/addon-sdk/commit/735c995c03f880c082beec312fb9c4ebd7ef07fb
Bug 732716: Wrap into content proxies nodes sent by context-menu to content scripts.

https://github.com/mozilla/addon-sdk/commit/d3bb7937988aecd78824521de96ef23053fd32c3
Merge pull request #494 from ochameau/bug/732716-wrap-context-menu-click-nodes

Bug 732716: Wrap into content proxies nodes sent by context-menu to content scripts. r=@gozala
Target Milestone: --- → 1.10
Status: UNCONFIRMED → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: