Closed Bug 1967510 Opened 8 months ago Closed 3 months ago

gemini.google.com - Copy does not work from prompt editing area to prompt input area

Categories

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

Desktop
All

Tracking

(Webcompat Priority:P2, Webcompat Score:3, firefox146 verified)

VERIFIED FIXED
146 Branch
Webcompat Priority P2
Webcompat Score 3
Tracking Status
firefox146 --- verified

People

(Reporter: sefeng211, Assigned: edgar)

References

(Depends on 2 open bugs, )

Details

(Keywords: webcompat:platform-bug, webcompat:site-report, webcompat:sitepatch-applied, Whiteboard: [webcompat-source:web-bugs][webcompat:sightline][webcompat:japan])

User Story

platform:windows,mac,linux
impact:feature-broken
configuration:general
affects:all
branch:release
diagnosis-team:dom
user-impact-score:45

Attachments

(7 files, 1 obsolete file)

This is very similar to bug 1945434, but about pasting it into a different location.

See https://bugzilla.mozilla.org/show_bug.cgi?id=1945434#c13

Severity: -- → S2
Priority: -- → P2
Attached file testcase.html

I think the issue is, Gemini does something like this in their "copy" event listener,

clipboardData.setData('text/html', '');
clipboardData.setData('text/plain', window.getSelection().toString());

And in their "paste" event listener, they do something like

if (event.clipboardData.types.includes("text/html")) {
   // Use clipboardData.getData('text/html')
} else {
   // Use clipboardData.getData('text/plain');
}

clipboardData.setData('text/html', ''); still creates an entry to the clipboard in Firefox, and it doesn't in Chrome.

Edgar, masayuki, thoughts about this? Is this our issue/Chrome issue/something undefined?

Flags: needinfo?(masayuki)
Flags: needinfo?(echen)

Safari also still creates an entry on the clipboard for an empty sting.
And spec doesn't specify that items with an empty string as data should be ignored. So I think it is a Chrome issue.

Flags: needinfo?(echen)

There's an old Chrome issue: https://issues.chromium.org/issues/40701751. Perhaps it has regressed again.

It looks like Webkit creates an entry but with empty content, whereas in Firefox it is the meta tag <meta http-equiv="content-type" content="text/html; charset=utf-8">

I wonder if the above differences cause it to work in Safari but not in Firefox.

I also confirmed in a local build of Firefox such that this issue is fixed if I force Gecko to not generating that entry.

(In reply to Sean Feng [:sefeng] from comment #5)

It looks like Webkit creates an entry but with empty content, whereas in Firefox it is the meta tag <meta http-equiv="content-type" content="text/html; charset=utf-8">

I wonder if the above differences cause it to work in Safari but not in Firefox.

Yes, the content is different, I will check.

Flags: needinfo?(masayuki) → needinfo?(echen)

Okay, although the content in system clipboard is different, but Gecko still returns an empty string for getData('text/html');, so it looks like the widget code is handling the conversion. From the Web API point of view, our behavior is actually the same as Safari’s on macOS.

I debugged the page a bit and found that it doesn’t handle the paste event directly, but instead lets the browser handle the paste action.
So I suspect the difference is from the Editor which perhaps our Editor always use the HTML data even if it is empty string, I will do more investigation.


Edited: Returning an empty string for getData('text/html') is macOS-only behavior, other platforms return whatever data is currently in the system clipboard.

Webcompat Priority: --- → P2
Webcompat Score: --- → 7
Attached file testcase2.html

I need to check the behavior on other platforms as well.

(In reply to Edgar Chen [:edgar] from comment #7)

Okay, although the content in system clipboard is different, but Gecko still returns an empty string for getData('text/html');, so it looks like the widget code is handling the conversion. From the Web API point of view, our behavior is actually the same as Safari’s.

Oh, this is macOS-only behavior, since only macOS uses the data from clipboard cache; other platforms return whatever data is currently in the system clipboard.

So there are two things here,
1). We always wrap string with HTML tags for HTML type when copying, even if the string is empty.
2). Other browser's editors fall back to using text/plain data if text/html is an empty string.

Assignee: nobody → echen
Flags: needinfo?(echen)

Thanks Edgar!

Sounds like you are going to making a change, I'll conclude this as platform-bug then. Let me know if you disagree!

Are there any possible workarounds while waiting for a platform-bug fix to ride to release (even if uplifted that will take ~1 month)?

Flags: needinfo?(twisniewski)
Flags: needinfo?(sefeng)
Flags: needinfo?(dschubert)
Webcompat Score: 7 → 8

One possible workaround is to add a JS intervention that calls clearData('text/html') on event.clipboardData to remove text/html data when it’s an empty string during copy.

Flags: needinfo?(sefeng)
Flags: needinfo?(dschubert)

This doesn't seem to affect Fenix. I can copy-paste just fine there from my earlier prompts to the new-prompt input (but not on desktop). I've added Sean's suggested intervention to the bug for desktop.

Severity: S2 → S3
User Story: (updated)
Webcompat Score: 8 → 6
Flags: needinfo?(twisniewski)
Keywords: leave-open

(It was Edgar suggested the intervention :) )

Depends on: 1968590, 1841058
Pushed by twisniewski@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/3ebe23ad6824 https://hg.mozilla.org/integration/autoland/rev/43759e8aa63b add a desktop-only JS webcompat intervention for gemini.google.com to fix copy-pasting between inputs; r=denschub,webcompat-reviewers
Webcompat Score: 6 → 3
Hey guys - wanted to let you guys know that currently pasting on gemini.google.com does not work at all. I

Hey guys - wanted to let you guys know that currently pasting on gemini.google.com does not work at all.

I (In reply to Yuval Meshorer from comment #20)

Hey guys - wanted to let you guys know that currently pasting on
gemini.google.com does not work at all.

I

(In reply to Yuval Meshorer from comment #20)

Hey guys - wanted to let you guys know that currently pasting on
gemini.google.com does not work at all.

If I go to about:compat and remove the intervention of "Bug 1967510", then pasting works again.

Sorry, I'm new to the forums here and didn't know that uploading an attachment also means sending the comment. And also that you can't update your own comments :)

In short, the current issue is that it seems that the intervention done in https://github.com/mozilla-firefox/firefox/commit/3ebe23ad6824 currently breaks pasting on https://gemini.google.com rather than fixing it.

To prove this, I went to about:compat and disabled the compatibility for gemini.google.com and now pasting seems to work as intended.

I am on version 141.0a1, as seen in the badly pasted 'Troubleshooting information' in one of my previous comments.

I attempted to open a pull request to fix this issue from the commit here: https://github.com/mozilla-firefox/firefox/commit/3a757622f8af107712ae58a6eb1484a17901ef9c
If anyone is interested in continuing this, please feel free :)

(In reply to Yuval Meshorer from comment #21)

Hey guys - wanted to let you guys know that currently pasting on gemini.google.com does not work at all.

I could not reproduce it, pasting on gemini.google.com works on my side.
I also didn't found any suspicious from the information you provided in comment #20.


Could you share some more information?

  • Where did you copy the data from? (same web page, another web page or another application)
  • Where did you paste the clipboard content to? (I guess you paste the content to the prompt input area?)
  • It would be helpful if you can help to capture some log,
    • Open about:logging
    • Set log modules to timestamp,sync,Clipboard:5,WidgetClipboard:5.
    • Start logging.
    • (reproduce the issue)
    • Stop logging, which will open profiler in a new tab.
    • Upload local profile.
    • And then share the link to us.
Flags: needinfo?(yuval)

(In reply to Edgar Chen [:edgar] from comment #24)

Hi, sorry for the late reply.

I have looked into this yesterday a bit more and here are my findings:

  1. I have noticed that gemini.google.com now works with or without this intervention, thus making it obsolete.
  2. I am developing a Firefox extension that "holds" certain events then re-triggers them manually. For example, I "catch" a paste event and then call .setData manually on it. This triggers the error of:
TypeError: 'setData' called on an object that does not implement interface DataTransfer.
  1. To answer your questions about the paste itself, it was to the prompt area (the textbox), and the data pasted is just plain text (so I think the source does not matter here?).
  2. Reproduced with logs: https://share.firefox.dev/3TvvCyC

It seems like the main issue this change now causes is that Firefox extensions cannot call wrappedJSObject.DataTransfer.setData. Here's a link to a script to reproduce this error: https://pastebin.com/3QSPsBN7 (dump this anywhere in your extension). This will cause pastes to not work.

Note that this works correctly when you disable the gemini.google.com compatibility.

If there is any more information I can provide, please reach out.
And if you want me to file a proper bug report, I will happily do that as well.

Thank you very much for your time!

Flags: needinfo?(yuval)

(In reply to Yuval Meshorer from comment #25)

And if you want me to file a proper bug report, I will happily do that as well.

Yes, please file a separated bug, we could continue discussion there. Thanks!

Flags: needinfo?(yuval)

(In reply to Edgar Chen [:edgar] from comment #26)

Yes, please file a separated bug, we could continue discussion there. Thanks!

Opened https://webcompat.com/issues/162351 :)

Although this was created on a different site (this can be fine, I'm new here :)

Flags: needinfo?(yuval)

Thanks, Yuval! I'll make a patch to remove the Gemini intervention, and will keep an eye out in the future to not let that kind of bug slip through in future interventions.

The STR for this bug, where the clipboard data is copied from the prompt editing area, still doesn't work for me without the intervention. Perhaps we should make the extension use case work instead?

Flags: needinfo?(twisniewski)

Hmm. Ok, I'll take a look, thanks.

Flags: needinfo?(twisniewski)
Attachment #9495508 - Attachment is obsolete: true
Pushed by twisniewski@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/c01e03e1bb7a https://hg.mozilla.org/integration/autoland/rev/7cfdbdda0ddd fix a bug with our gemini.google.com webcompat intervention which can break add-on use of setData on the page; r=denschub,webcompat-reviewers

@twisniewski thank you very much!

When is this expected to hit Nightly? I'm guessing tomorrow (hence the name)? :)

If so, I'll update tomorrow as to if it works for me or not.

@Yuval, hopefully it will land within the next twelve hours, and make it into tomorrow's nightly, yes. It might take a little longer if there's an unexpected delay, but you'll see the version number of the webcompat addon (easiest to see in about:support) change form 141.2.0 to 141.3.0 once the update is active.

Hi @twisniewski, just wanted to say that your solution works!
Validated now with the browser extension. Thank you very very much! Have a fantastic weekend.

You too, thanks Yuval!

Pushed by amarc@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/e758a16d23c4 https://hg.mozilla.org/mozilla-central/rev/3d1868136790 add a regression test for the bug described in comment 25 of the bug, where addons could not call setData on paste events due to a flaw with our webcompat intervention; r=denschub
Whiteboard: [webcompat-source:web-bugs][webcompat:sightline] → [webcompat-source:web-bugs][webcompat:sightline][webcompat:japan]
User Story: (updated)

It looks like they have fixed the bug, so we can remove our intervention \o/

User Story: (updated)
Keywords: leave-open
Pushed by twisniewski@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/fa9c5cdb882a https://hg.mozilla.org/integration/autoland/rev/741d746550eb remove our webcompat copy/paste intervention for gemini.google.com; r=webcompat-reviewers,ksenia
Status: NEW → RESOLVED
Closed: 3 months ago
Resolution: --- → FIXED
Target Milestone: --- → 146 Branch

Verified as FIXED using the RC Build

Tested with:

Browser / Version: Firefox 146.0-candidate build 1
Operating System: Windows 10 PRO x64

Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: