Closed Bug 803014 Opened 12 years ago Closed 9 years ago

Failing to paste screenshot images for Gmail using Firefox but works for Chrome - insufficient support for clipboard event API (event.clipboardData , DataTransferItem)

Categories

(Core :: DOM: Events, defect)

defect
Not set
normal

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: sameer, Unassigned)

References

()

Details

User Agent: Mozilla/5.0 (Windows NT 5.1; rv:16.0) Gecko/20100101 Firefox/16.0 Build ID: 20121010144125 Steps to reproduce: I drafted a mail and pasted few screenshot images onto it. Actual results: After sending the mail when i checked the images did not show up in any browser but when I sent the same mail through chrome it worked fine. It even showed up in fire fox. So there is some issue while sending the emails. Expected results: It should work fine in pasting.
Group: core-security
Sam, could try the basic troubleshooting steps: 1) Safe mode: https://support.mozilla.org/en-US/kb/troubleshoot-firefox-issues-using-safe-mode 2) New profile: https://support.mozilla.org/en-US/kb/profile-manager-create-and-remove-firefox-profiles Does it fix your issue about pasting?
I can report same problem.. Startings in Safe mode and creating new profile with profile manager dont fix problem.
(In reply to Mārcis Koloda from comment #2) > I can report same problem.. Startings in Safe mode and creating new profile > with profile manager dont fix problem. I have problem with FireFox version 26 in Windows XP, Windows Server 2008 R2 and Linux MINT 15 Olivia..
Same issue with a different browser (IE, Chrome, Opera)?
Flags: needinfo?(marcis.koloda)
No Chrome, IE dont have that problem.
Flags: needinfo?(marcis.koloda)
Same issue here, Firefox 27/28 (and before as well), Windows 7. This is really a widely known issue, and it's not restricted to GMail only. For example this doesn't work with Firefox and Confluence (v4) either. I'm not really sure why this bug (and similar ones in this Bugzilla) are still listed as "unconfirmed". Confirming this really could not be easier: 1. Open http://www.mozilla.org 2. Right-click on the Firefox logo and select "Copy Image" 3. Open GMail and open a compose window. 4. For "To:" enter your own GMail address 5. Click in the compose area and type CTRL-V. The Firefox logo will show 6. Hit "Send" 7. Open the new email you receive -> The firefox logo does not show Now try the same thing with Chrome and see that it works as expected.
(In reply to Maarten Boekhold from comment #6) > Same issue here, Firefox 27/28 (and before as well), Windows 7. This is > really a widely known issue, and it's not restricted to GMail only. For > example this doesn't work with Firefox and Confluence (v4) either. > > I'm not really sure why this bug (and similar ones in this Bugzilla) are > still listed as "unconfirmed". Confirming this really could not be easier: > > 1. Open http://www.mozilla.org > 2. Right-click on the Firefox logo and select "Copy Image" > 3. Open GMail and open a compose window. > 4. For "To:" enter your own GMail address > 5. Click in the compose area and type CTRL-V. The Firefox logo will show > 6. Hit "Send" > 7. Open the new email you receive -> The firefox logo does not show > > Now try the same thing with Chrome and see that it works as expected. However, this works fine for me, Fx28 & 29 on Win8.1.
This bug occurs for me on all my Win7 computers with Firefox 28. It does not occur with Chrome or Opera. MSIE 11 gives a popup error message on paste, and does not paste anything. Can anyone else with Win8.1 corroborate YF(Yang)? Note that it appears to work until step 7. Also this bug appears to be a duplicate of bug 720443. More on this persistent problem: https://support.mozilla.org/en-US/questions/937454 (Noah_Sumo's post at the bottom has a lot of good info) http://www.pcworld.com/article/2049440/imageinsertion-bug-locks-people-out-of-gmail.html https://www.google.com/#q=firefox+bugs+gmail+paste
Ah, so it *is* platform dependent! I just tested on a VM with Linux Mint 16 (based on Ubuntu 13.10) with Firefox 28, and this copy/paste works! I don't have Windows 8(.1) available to test there, but then again YF already confirmed above that it works on that combination. Considering that most businesses will be on Windows 7 for years to come, this should probably be fixed. Also, since this seems to work on other OSes and versions, this looks like a specific incompatibility issue rather than some inherent issue with Firefox. So should be possible to address this.
This issue occurs on OS X as well with Firefox 29.0. It has been a problem for many versions for me. Some previous versions would send what appeared as a giant base64 string when viewed in the browser version of gmail, but the image would appear correctly when viewed in stand-alone clients. Pasting in Chrome works correctly.
Confirmed, this doesn't work for me on OS X either with Firefox Nightly (34). STR: 1. Copy an image to the clipboard (e.g. on OS X press Cmd+Ctrl+Shift+4 and select a region of the screen to copy). 2. Open Gmail. 3. Click "Compose". 4. Click in the body area of the email compose popup. 5. Press Cmd+V / Ctrl+V. In Chrome, this will show a little progress spinner while it uploads the image, and then the image finally is shown in the email. In Firefox, nothing happens. Haven't looked into whether this is a problem with Gmail or us. Putting in Tech Evangelism :: Desktop for the moment.
Status: UNCONFIRMED → NEW
Component: Untriaged → Desktop
Ever confirmed: true
OS: Windows XP → All
Product: Firefox → Tech Evangelism
Hardware: x86 → All
Version: 16 Branch → Trunk
Can someone create a testcase that shows this problem? It'd be a lot faster for us to debug this with a testcase that shows just this not working rather than debugging this in gmail which is a huge application. Thanks!
Testing this with http://www-archive.mozilla.org/editor/midasdemo/, neither Chrome nor Firefox can paste the image, but Safari can. So I suspect whatever is happening here, it's something that Gmail does for Chrome, but not Firefox.
+Hallvord, who's quite skilled in debugging Gmail issues.
As far as I can tell, we simply don't support enough of the underlying functionality GMail is using. Here's some code, annotated: if (this.ea()) { // is rich text compose mode var b = null, c = a.Bg.clipboardData; if (c) { // event.clipboardData is supported var d = c.items; d && 1 == d.length && // clipboardData.items and there's an "item" on clipboard "file" == d[0].kind && // "item" is a file ob(G1b, d[0].type) ? // type is supported b = d[0].getAsFile() : // DataTransferItem.getAsFile() (c = c.getData("text/html").trim().match(ved)) && (b = c[2]); b && (this.o.execCommand("insertfile", b), a.preventDefault()) } (There's some more related code but it's basically a fallback for IE, using window.clipboardData instead of event.clipboardData) If I break in a paste event in Mozilla when pasting an image, clipboardData.items is empty, at least in Nightly on Windows. It seems this stuff isn't fully supported yet: http://www.w3.org/TR/html5/editing.html#datatransferitem http://www.w3.org/TR/html5/editing.html#dom-datatransferitem-getasfile I have test cases for this already, but they aren't fully merged into web-platform-tests yet. Right now there's no good, stable URL for the most relevant test.
Note when trying to test this that some of the people commenting used "copy image" from Firefox's right-click menu before pasting, and some people took screenshots. These are different cases because if you use "copy image" the clipboard contents will likely be annotated with the source URL and GMail will quite possibly use the URL to insert the image. I suggest we limit this bug to be about pasting screenshots only - i.e. when clipboard contains image data without any associated URL or file name.
A nearly relevant test is this one: http://w3c-test.org/submissions/1242/clipboard-apis/095.html Try pasting a screenshot instead of copying the file from the file manager. If there's JPEG data on the clipboard the test should pass in Chrome and fail in Firefox. (Note that some graphic software prefers putting PNG on the clipboard, in this case the test will appear to fail even though breaking inside the clipboard_api_test() function defined inline lets you inspect the implementation and note Gecko's missing bits) (TC will likely move to http://w3c-test.org/clipboard-apis/095.html when the review and pull request is done, but because these tests are auto-generated the number 095 might change - sorry about that)
Component: Desktop → DOM: Events
Product: Tech Evangelism → Core
Summary: Failing to paste screenshot images for Gmail using Firefox but works for Chrome → Failing to paste screenshot images for Gmail using Firefox but works for Chrome - insufficient support for clipboard event API (event.clipboardData , DataTransferItem)
(BTW, this is probably a dup of bug 891247 or vice versa)
See Also: → 891247
We also don't support execCommand("insertfile"). Aryeh/Ehsan, is this something that should be in the spec (I couldn't see it in HTML Editing APIs) and we should be implementing?
Flags: needinfo?(ehsan.akhgari)
Flags: needinfo?(ayg)
And thanks for tracing through the script, Hallvord!
I haven't ever heard of execCommand("insertfile"), so I don't currently have any opinion as to whether it should be specced or implemented. In any event, the editing spec has not been maintained for a long time.
Flags: needinfo?(ayg)
That execCommand() method is not document.execCommand() but a custom one defined by Google's JS, comes with its own commands and actions. No worries about stuff missing from the spec :)
Flags: needinfo?(ehsan.akhgari)
Just to clarify something I wrote earlier: > (Note that some graphic software prefers putting PNG on the > clipboard, in this case the test will appear to fail I meant fail *in Chrome* - i.e. if the content on the clipboard isn't the JPG data the test is looking for, the implementations may seem equivalent when the test fails in both browsers. Chrome's implementation is more complete than Gecko's. It still has limitations - from what I can tell, Chrome doesn't yet implement pasting a file that you "copy" from the OS's file manager, but it certainly implements enough to allow pasting image data which was placed on the clipboard by some graphics software or screenshot utility.
Neil did the work on the previous bits of the clipboard API support...
Images can only be pasted currently if the source included a url or a file in the data. Bug 891247 is about adding support for image data directly. The 'items' property isn't supported. Not sure if there is a bug for that. That feature didn't exist in the spec when this was implemented
The @items property part is in Bug 906420, adding both as dependencies to this bug.
Depends on: 891247, 906420
I think that gmail has been updated in a way which fixes this bug, as I can't seem to reproduce it anymore. Can someone else confirm that gmail handles copying correctly? (the dependent bugs are still relevant and need to be fixed, but gmail seems to have changed and now works)
It has indeed. We support creating an IMG tag with a data: URI on-the-fly when pasting into a contentEditable element, and GMail likely uses that to upload image data on paste. That's progress, but it would still be good to have clipboardData.items to avoid such hacks.. We may get it in bug 891247
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → WORKSFORME
Yes, this seems to work for GMail now. I realize the original case is about GMail, but there are other web-based applications where it would be incredibly useful for this to work. For myself the application that comes to mind is Confluence. At least on our Confluence 5.0.2 instance pasting an image still does not work.
(In reply to Maarten Boekhold from comment #31) > there are other web-based applications where it would be > incredibly useful for this to work. Sure - it's being worked on. See the bugs this one depends on :)
(In reply to Hallvord R. M. Steen [:hallvors] from comment #32) > (In reply to Maarten Boekhold from comment #31) > > there are other web-based applications where it would be > > incredibly useful for this to work. > > Sure - it's being worked on. See the bugs this one depends on :) Just to add: my company recently upgraded our Confluence instance to 5.8.6, and pasting images into this version of Confluence is now working. Not sure if this is due to enhancements in Firefox or in Confluence...
You need to log in before you can comment on or make changes to this bug.