Cannot Paste Text in YouTube Comment Box

VERIFIED FIXED

Status

defect
P1
normal
VERIFIED FIXED
Last year
4 months ago

People

(Reporter: dalef, Unassigned)

Tracking

Firefox 60

Firefox Tracking Flags

(Not tracked)

Details

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

Reporter

Description

Last year
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.

Updated

Last year
Component: Untriaged → Desktop
Product: Firefox → Tech Evangelism
Version: 60 Branch → Firefox 60

Updated

Last year
Duplicate of this bug: 1466684

Updated

Last year
Duplicate of this bug: 1466745
Priority: -- → P1
Whiteboard: [platform-rel-youtube][needsdiagnosis]
Flags: needinfo?(oana.arbuzov)

Updated

Last year
Duplicate of this bug: 1468322

Updated

Last year
Duplicate of this bug: 1468344
Tom, can you dig into this please?
Flags: needinfo?(oana.arbuzov) → needinfo?(twisniewski)

Updated

Last year
Duplicate of this bug: 1468596
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

Comment 9

Last year
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())
},

Updated

Last year
Duplicate of this bug: 1469275
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: Last year
Resolution: --- → FIXED

Comment 13

Last year
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.