Closed Bug 1466391 Opened 6 years ago Closed 6 years ago

Cannot Paste Text in YouTube Comment Box

Categories

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

Firefox 60
defect

Tracking

(Not tracked)

VERIFIED FIXED

People

(Reporter: dalef, Unassigned)

References

Details

(Whiteboard: [platform-rel-youtube][needsdiagnosis])

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:60.0) Gecko/20100101 Firefox/60.0
Build ID: 20180516032328

Steps to reproduce:

1. Select text from Firefox or any other application.

2. Right-click on selected text and left-click on Copy or press Control-C to copy text.

3. Open any YouTube video and click in the "Add a public comment..." box or reply to any pre-existing comment.

4. Attempt to paste text in comment box by right-clicking on comment box and left-clicking Paste or pressing Control-V to paste text.


Actual results:

The text was NOT pasted into the YouTube comment box. There were no observable changes when attempting to paste text; nothing happened.


Expected results:

The text stored in the Windows 10 clipboard should have been pasted in the YouTube comment box.

I have not encountered this problem with other Web sites.
Component: Untriaged → Desktop
Product: Firefox → Tech Evangelism
Version: 60 Branch → Firefox 60
Priority: -- → P1
Whiteboard: [platform-rel-youtube][needsdiagnosis]
Flags: needinfo?(oana.arbuzov)
Tom, can you dig into this please?
Flags: needinfo?(oana.arbuzov) → needinfo?(twisniewski)
Sent a message to Youtube on our partner mailing list.
Flags: needinfo?(twisniewski)
They've found the issue and have created a fix for it. Waiting to hear when it will be released.

They were affected by https://bugzilla.mozilla.org/show_bug.cgi?id=1220696#c15 when trying to use document.execCommand('insertText' on textarea/input) and provided a test case https://codepen.io/cheng-lee/pen/rKzbPx
See Also: → 1220696
Yes. I have same issue.
Here code from YouTube (desktop_polymer.js):

document.addEventListener('paste', this.onPaste_)
[...]
onPaste_: function (a) {
w2(a.target) && (a.preventDefault(), a = a.clipboardData.getData('text/plain'), document.execCommand('insertText', !1, a))
},

Here my test:

function handler(a){
	a.preventDefault();
	var b = a.clipboardData.getData('text/plain'); 
	var c = document.execCommand('insertText', !1, b);
	console.log(c, document.designMode);
	
	a.stopPropagation();
}
addEventListener('paste', handler, true);

On FF 60.0.2 it not paste and show in console: false off
On Chrome 67.0.3396.87 it paste and show in console: true "off"

According MDN https://developer.mozilla.org/ru/docs/Web/API/Document/execCommand
execCommand must not work if document.designMode == 'off' but it is work on Chrome and this behavior used in YouTube code.

Possible two solution:
1. Fix code on YouTube
2. Fix FF behavior.

For Youtube, code must check return result from execCommand and do not preventDefault if it fail.

For example instead 

onPaste_: function (a) {
w2(a.target) && (a.preventDefault(), a = a.clipboardData.getData('text/plain'), document.execCommand('insertText', !1, a))
},

use 

onPaste_: function (a) {
w2(a.target) && (b = a.clipboardData.getData('text/plain'), document.execCommand('insertText', !1, b) && a.preventDefault())
},
Just to follow up on the bug 1220696 dependency, execCommand is not specified for form controls (e.g. textarea/input) only contenteditable. Discussion is going on in [1] to specify this but Youtube should not be relying on this behavior.

[1] https://github.com/w3c/editing/issues/160
This has been fixed by Google. Tested using Firefox 62 for MacOS.

Thanks everyone!
Status: UNCONFIRMED → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Now fixed. Confirm for FF 60.0.2 32-bit on Windows.
Status: RESOLVED → VERIFIED
Product: Tech Evangelism → Web Compatibility
You need to log in before you can comment on or make changes to this bug.