document.execCommand('copy') causes 'too much recursion' in ver42

NEW
Unassigned

Status

()

Core
Event Handling
2 years ago
2 years ago

People

(Reporter: mikagenic, Unassigned)

Tracking

42 Branch
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

2 years ago
User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.73 Safari/537.36

Steps to reproduce:

see http://jsfiddle.net/Lxjdfe7e/

select the line in the teaxtarea and press control+C

The relevant code is:

function copyHtmlToClipboard(html) {
  var div = document.createElement("div");
  div.style.position = 'absolute';
  div.style.top = '-1000px';
  div.style.left = '-1000px';
  div.innerHTML = html;
  document.body.appendChild(div);
  
  window.getSelection().removeAllRanges();  
  var range = document.createRange();  
  range.selectNode(div.firstChild); 
  window.getSelection().addRange(range);  

  var ok=false;
  try {
    ok = document.execCommand('copy');
  } catch (err) {
  }
  if (!ok) console.log('execCommand failed!');

  window.getSelection().removeAllRanges();  
  document.body.removeChild(div);
}




Actual results:

Firefox 42 does not copy the text to the clipboard. In the firebug console I see 'too much recursion'


Expected results:

In chrome and IE11 this will copy xx in bold to the clipboard. This can be verified by for example pasting into a gmail new email.

Updated

2 years ago
Status: UNCONFIRMED → NEW
Component: Untriaged → Event Handling
Ever confirmed: true
Product: Firefox → Core
You need to log in before you can comment on or make changes to this bug.