Allow async call to document.execCommand('copy') from handler of user-initiated event

Confirmed Issue #7728456 • Assigned to Amit J.

Details

Author
Hans M.
Created
May 29, 2016
Privacy
This issue is public.
Found in
  • Microsoft Edge
  • Firefox
Reports
Reported by 3 people

Sign in to watch or report this issue.

Steps to reproduce

  1. Navigate to http://hansifer.com/clipboardCopyTest.html
  2. Click on “Copy Async”
    • Note that execCommand(‘copy’) is reported to return false
  3. Paste contents of clipboard into textbox
    • Note that paste is reported as not matching copy attempt

The above page tests whether execCommand(‘copy’) can be successfully called outside of the call stack (eg, via setTimeout()) of the handler of a user-initiated event such as a click. Chrome allows this within a 1 second interval.

This capability is important to support use cases such as:

  1. Copy to clipboard from within handlers of extension browser_action clicks, page_action clicks, context menu clicks, and keyboard shortcut commands

  2. Using setTimeout() to rate-limit clicks or detect double/triple click

  3. Using an extension API, many of which are async, as the source of text to copy

    • Eg, browser.tabs.query()

The following browsers currently support this:

  • Chrome (1 sec delay)
  • Opera (1 sec delay)
  • IE11 (with user prompt; unlimited delay)
  • Safari Desktop Technology Preview

Attachments

0 attachments

    Comments and activity

    • Microsoft Edge Team

      Changed Assigned To to “Ibrahim O.”

      Changed Assigned To to “Travis L.”

      Changed Assigned To to “Amit J.”

      Changed Status to “Confirmed”

      Changed Assigned To to “Amit J.”

      Changed Assigned To from “Amit J.” to “Grisha L.”

      Changed Assigned To from “Grisha L.” to “Amit J.”

    • Experiencing the same issue. Building an Edge Extension that adds a contextMenu item for copying text from a webpage. Here’s the workflow:

      1. Right-click, select ‘copy formatted text’ (this is my custom contextMenuItem)
      2. Background script sends message to the content_script loaded in the webpage
      3. Content_script processes the request (catches the message from the background script via browser.runtime.onMessage.addListener() ), including a call to document.execCommand(‘copy’), but the call returns ‘false’

      Would really like to know the status on this, as it seems like a big limitation that it is not supported.

      Hans example from above is right on the mark. If this can work, that’d be awesome!

      Thanks!

    You need to sign in to your Microsoft account to add a comment.

    Sign in