Closed Bug 1234024 Opened 9 years ago Closed 6 years ago

Copy/Paste values between two sheets (tabs) in Google sheets

Categories

(Web Compatibility :: Site Reports, defect, P3)

defect

Tracking

(platform-rel +, firefox-esr52 ?, firefox57 ?, firefox58 ?, firefox59 affected)

RESOLVED FIXED
Tracking Status
platform-rel --- +
firefox-esr52 --- ?
firefox57 --- ?
firefox58 --- ?
firefox59 --- affected

People

(Reporter: campbell.zac, Unassigned)

References

Details

(Whiteboard: [country-all][sitewait][platform-rel-Google][platform-rel-GoogleSuite][platform-rel-GoogleSheets])

User Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:43.0) Gecko/20100101 Firefox/43.0
Build ID: 20151216175450

Steps to reproduce:

(NB tested OK in Chrome thus think this must be a Firefox bug)

1. Create two spreadsheets in Googlesheets (or take two you already have!).
2. Create a small range of numerical data using formulas to create the data in spreadsheet1.
3. Copy the range
4. In spreadsheet 2, go to edit menu and select "Paste Values"


Actual results:

After choosing Paste Values from the menu, nothing happens. There are a bunch of errors in the Browser Console but I'm not sure what is related to this specific issue! :)

Just doing a keyboard paste - ctrl-v - pastes the formulas fine.



Expected results:

The values only (not formulas) should be pasted into the cells with the same size range.

I've tested this in Google Chrome and it pastes values correctly between tabs.
I just tried this out in Nightly too and it is also broken there too.
Component: Untriaged → Desktop
Product: Firefox → Tech Evangelism
Version: 43 Branch → unspecified
Kohei can we leave this in the product "Firefox" until we confirm that it is or isn't a Firefox bug?

If it isn't a Firefox bug then I will raise it against googledocs and I can provide this bug as evidence that it is not Firefox causing the problem.
Flags: needinfo?(kohei.yoshino)
This works fine in Firefox 42. Interesting.. Do they rely on a clipboard format our implementation doesn't give them access to (in 43), and fall back to some internal thing if there's insufficient clipboard API support (42)?
Could also be O/S based - I've only tried it on one Windows machine so far. Which reminds me I have a Linux Mint machine and I can try that, too.

Do you have any advice as to how I might be able to debug it further?
I've just tried it on Mint with Firefox 41 and the same problem occurs.

It absolutely has to be copying from one spreadsheet in one tab and pasting values into a different spreadsheet in different tab.
Zac: Feel free to move the bug to a better component if possible. The Untriaged component is almost ignored anyway, that's why I have moved this.
Flags: needinfo?(kohei.yoshino)
Thanks Kohei. At the moment let's keep this in Firefox until we can prove it's not relevant to Firefox.

Here's some more data. Instead of using two Firefox tabs, I used one spreadsheet in Firefox and one in Chrome:

1. Copy in Firefox, Paste Values in Chrome - Works fine
2. Copy in Chrome, Paste Values in Firefox - Fails as per comment #1
Component: Desktop → General
Product: Tech Evangelism → Firefox
Version: unspecified → Trunk
This stuff is a bit inconsistent.. I've even seen it fail in Chrome but perhaps it's because attaching a debugger and setting breakpoints messes up the timing so that the "is this paste command user-initiated" logic fails.

Anyway, here are some snippets of code involved: the main entrypoint for the "paste values" calls a method that does this:

case "+paste":
                    return a.B.D()

That function is here:

function (){return tf||ej||GFa(this.B,BFa,!1)}

and now we dive into Google spreadsheet's mix of browser sniffing and feature detection. 

* tf is output from cea()

function cea(){return qf("Trident")||qf("MSIE")}

* ej is simply set like this:

ej=qf("iPad")

The GFa function starts enumerating some odd "permissions" that seem somewhat more internal:

function GFa(a,b,c){if(fj&&"ok"==EFa(a))try{var d;if(Yx())d=ea._docs_chrome_extension_permissions;else{var e=FFa();d=e?e.permissions||[]:[]}for(a=0;a<b.length;a++)if(wb(d,b[a].name)&&pw(b[a].RK))return!0;return!1}catch(f){return c}else return!1}

And EFa / FFa, if you're curious, looks like this:

function EFa(a){if(Yx())return"ok";try{if(ea.chrome.app.isInstalled)return"ok";var b=FFa();if(qa(b)){var c={},d;for(d in b){var e=b[d];c["appDetails_"+d]=qa(e)?JSON.stringify(e):e}a.C("Chrome Drive app is installed and enabled, but not effective (indicating a Chrome bug)",c);return"not-effective"}return"disabled-or-not-installed"}catch(f){return"disabled-or-not-installed"}}

function FFa(){if(!fj)return null;try{return ea.chrome.app.getDetails()}catch(a){return null}}

(fj is the return value from function dea(){return(qf("Chrome")||qf("CriOS"))&&!rf()&&!qf("Edge")})

So yes, it's mostly browser sniffing to detect clipboard "support" - if all this logic returns a false the script won't attempt to do document.execCommand('paste') and falls back to some logic checking if something was previously copied in that document. This fails if copying between browser tabs. 

They should rewrite some of this detection to account for the fact that new Firefoxes now support document.execCommand('paste') correctly.
(As for this appearing to be a regression, that was a misunderstanding on my part - I was first testing pasting into a different sheet inside one Google spreadsheet, which works due to the intra-document-paste fallback logic.)
Component: General → Desktop
Product: Firefox → Tech Evangelism
Whiteboard: [country-all][contactready]
Status: UNCONFIRMED → NEW
Ever confirmed: true
I've contacted the Google Sheets team to try to bring this to their attention.
Thanks, Zac! Both for reporting this and for contacting them :)
Whiteboard: [country-all][contactready] → [country-all][sitewait]
I've tried to raise this through a couple of channels but it's not yet been fixed (I hit the bug every couple of days so I get frequent chances to test it). 

Thus if anyone else with a closer relationship to the Google Docs team can bring it up, please do :)
I'm raising it with some liaisons at Google now. Thanks for the follow-up :)
Hi Hallvord,

While I see document.execCommand('copy') now working in user initiated contexts, it seems paste is still restricted.

- document.queryCommandSupported and document.queryCommandEnabled always return false for paste
- The developer release notes for 41 indicates the "programmatic copying and cutting  from JS for Web content" is now allowed, but not about paste.
https://developer.mozilla.org/en-US/Firefox/Releases/41
- MDC indicates paste needs user.js preference.
https://developer.mozilla.org/en-US/docs/Web/API/Document/execCommand

Let me know if there is something else I should be aware of.

Given this info, we could only enable the copy action from the menus and right click, not paste.
*Sigh*, you're right - seems there are some bugs to handle before this is fully functional. I will follow up and make sure we do something about that. What we *do* do correctly, however, is to return false from execCommand when the paste command failed, so it should be possible to already rely on that return value to fall back to the inside-document paste fallback. In any case I will get back to you when some build where this works fully is on the release channel.
No worries. We are very interested in improving copy/paste as best we can so please let us know when paste is available.

Note: If you are following up on copy/paste items :), this is another bug that will enhance copy/paste support for Google Docs.
https://bugzilla.mozilla.org/show_bug.cgi?id=860857

With paste and custom mimetype handling, copy/paste in FF will be significantly improved. Thanks for looking into this, Hallvord!
Hi Hallvord,

Any update on supporting paste? Just checking in.

Given you added handling of custom mimetypes to FF, a future release of Docs will support custom mimetypes for better fidelity cross-window copy/paste in FF48+.
(In reply to Steven Saviano from comment #17)
> Any update on supporting paste? Just checking in.

Hi Steven, thanks for checking - I realised the conversation I started earlier had stalled a bit - partly because another discussion about an improved API started happening. So I've reported some bugs concluding that discussion and hopefully helping us get some actual coding done here.

> Given you added handling of custom mimetypes to FF, a future release of Docs
> will support custom mimetypes for better fidelity cross-window copy/paste in
> FF48+.

Yay! :)
I still need to do some more work on the custom stuff spec-wise though.
Thanks! Great to hear the progress. As FF pieces are implemented, I am happy to prototype against nightly/dev instances to ensure this will work for Docs cases.
platform-rel: --- → +
Whiteboard: [country-all][sitewait] → [country-all][sitewait][platform-rel-Google][platform-rel-GoogleDocs]
(In reply to Steven Saviano from comment #14)
> While I see document.execCommand('copy') now working in user initiated
> contexts, it seems paste is still restricted.
> 
> - document.queryCommandSupported and document.queryCommandEnabled always
> return false for paste

I understand this is intentional but Michael and Ehsan can provide more reasons.
Flags: needinfo?(michael)
Flags: needinfo?(ehsan)
The users clipboard can often contain personal information which people don't want websites to have access to. We don't want to enable websites to, every time you click on them, be able to steal information off of your clipboard. 

In addition we don't currently want to add support for a permission for paste, because we haven't figured out a way to explain the permission in a way people will easily understand. 

I don't think paste will ever be avaliable in user initiated callbacks, but if a permission is added at some point in the future for arbitrary clipboard access, paste may be avaliable in that.
Flags: needinfo?(michael)
Bug 1272296 tracks the support for execCommand('paste').  Until as actually support this command, returning false from queryCommandSupported/Enabled is the right thing to do!
Flags: needinfo?(ehsan)
Whiteboard: [country-all][sitewait][platform-rel-Google][platform-rel-GoogleDocs] → [country-all][sitewait][platform-rel-Google][platform-rel-GoogleDocs][platform-rel-GoogleSheets]
Whiteboard: [country-all][sitewait][platform-rel-Google][platform-rel-GoogleDocs][platform-rel-GoogleSheets] → [country-all][sitewait][platform-rel-Google][platform-rel-GoogleSuite][platform-rel-GoogleSheets]
Rank: 20
Since only paste is missing, would it be possible to implement support for copy and cut?
We are a bit hesitant given the experience will be inconsistent for the various clipboard options. It would be great to see traction on the ability to trigger paste (whether permission or some other mechanism) - with paste, the functionality addition is straightforward. Any update on the possibility of supporting paste?
This seems fixed now?
Priority: -- → P3
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Product: Tech Evangelism → Web Compatibility
You need to log in before you can comment on or make changes to this bug.