New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.
Starred by 21 users

Issue metadata

Status: Fixed
Closed: Oct 2015
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 2
Type: Bug

Sign in to add a comment

Issue 476508: document.queryCommandSupported('copy') returns false until user interaction

Reported by, Apr 13 2015 Project Member

Issue description

Version: =44.0.2367.0 (Official Build) canary (64-bit)

What steps will reproduce the problem?
1. Visit:
2. The buttons disabled state is determined by the result of queryCommandSupported() for cut and copy

What is the expected output? What do you see instead?
I would expect true to be returned by queryCommandSupported('cut') and queryCommandSupported('copy'). Instead it returns false. IF I didn't handle the state, both queryCommandSupported would return true after user click.

I think the implementation is confusing queryCommandSupported and queryCommandEnabled. queryCommandSupported should always return true so the developer can set the state accordingly. queryCommandEnabled should be the place that we allow the user to determine if the comment will work or not.

Comment 2 by, Apr 13 2015


Comment 3 by, Apr 14 2015

Similar yes, however that bug references a difference between running the command and the command running in a page.

This bug is referring to a wrong value when running the command in the page. They may get fixed up in the same place, but for now would like the testing of these to be handled separately.

Comment 4 by, Apr 16 2015


Comment 5 by, Apr 17 2015

@ mattgaunt,
I think is not working anymore. Could you please share test.

Comment 6 by, Apr 17 2015

It is using the queryCommandSupported to set the button state - so it does work, but because of this issue - it disables the button since the api is suggesting the command isn't supported.

You can view the source code for the demo here:

Comment 7 by, Apr 17 2015

Patch is uploaded for review :

Comment 8 by, May 15 2015

Any movement on this bug?

Comment 9 by, May 19 2015

There's a patch in progress that is in review.

Comment 10 Deleted

Comment 11 by, Jun 2 2015

Any new internal updates on the patch review? Seems to have gone stagnant again.

Comment 12 by, Jun 4 2015

Labels: -OS-Mac OS-All Cr-Blink-DataTransfer
Status: Started
I'm picking this up, because it has a lot of interaction with some of the clipboard permissions work.

The short story is we need to figure out some details wrt the spec. Feel free to follow along (and comment) on

Comment 13 by, Sep 17 2015

The last comment on this was on June 3rd. Its now September 17 and this is still an issue.

Is anyone still working on this?

Comment 14 by, Oct 13 2015

Any news? I had to write a poyfill to fix this

Comment 15 by, Oct 14 2015

It seems we just return true for copy/cut for queryCommandSupported.

Current implementation is:
static bool supportedCopyCut(LocalFrame* frame)
    if (!frame)
        return false;

    Settings* settings = frame->settings();
    bool defaultValue = (settings && settings->javaScriptCanAccessClipboard()) || UserGestureIndicator::processingUserGesture();
    return frame->editor().client().canCopyCut(frame, defaultValue);

An implementation of queryCommandEnable for copy/cut:
static bool enabledCopy(LocalFrame& frame, Event*, EditorCommandSource)
    return frame.editor().canDHTMLCopy() || frame.editor().canCopy();

Comment 16 by, Oct 14 2015

Owner: ----
Status: Available
The issue of queryCommandEnabled(cut|copy|paster) is filed into  issue 542948 , since
queryCommandSupported() and queryCommandEnabled() are different thing.

queryCommandSupported(cut|copy|paste) will return true always.

Simple change,, failed following tests:
- ContentCapabilitiesTest.NoCapabilities
- ContentCapabilitiesTest.ClipboardWrite
- ContentCapabilitiesTest.ClipboardRead
- ContentCapabilitiesTest.ClipboardReadWrite
- ClipboardApiTest.HostedAppNoPermission
- ClipboardApiTest.ExtensionNoPermission

Comment 17 by, Oct 14 2015

Status: Started
Here is return value of execCommand for copy/cut/paste with value of isEnabled() and isSupported()

isEnabled isSupported execCommand
true      true        true
true      false       false
false     true        true; by allowExecutionWhenDisabled
false     false       false

My patch will make isSupported() always returns true, so, we can get rid of allowExecutionWhenDisabled.
In other words, we move isSupported(), clipboard access permission check, to isEnabled() and execute().

Comment 18 by, Oct 15 2015

Project Member
The following revision refers to this bug:

commit bf9013658c0eb493db5dd0941532160dc9fdd0c7
Author: yosin <>
Date: Thu Oct 15 09:18:52 2015

Make queryCommandSupported(copy|cut|paste) always return true

This patch makes |document.queryCommandSupported(name)| always return true for
"Copy", "Cut", and "Paste" commands to follow the editing API specification.

Before this patch, |queryCommandSupported()| returns value based on clipboard
accessibility, e.g. "clipboardRead" and "clipboardWrite" permission in Chrome
extensions. This behavior ins't compatible with the editing specification and
its intention. |queryCommandSupported()| should returns true for command
which can be passed to |execCommand()|, and other |queryCommandXXX()|.

Here is a table of return value of |execute()| and |isEnabled()| with
clipboard access permission and Editor.canCopy/Cut/Paste

Can R/W   Editor.can isEnabled execute
Clipboard Copy/Paste
true      true       true      true
true      false      false     true
false     true       false     false
false     false      false     false

BUG= 476508 ,  475868 

Review URL:

Cr-Commit-Position: refs/heads/master@{#354240}


Comment 19 by, Oct 16 2015

Status: Fixed

Comment 20 by, Oct 20 2015

Labels: TE-Verified-M48 TE-Verified-48.0.2541.0
Rechecked the issue on chrome version 48.0.2541.0 on MAC 10.10.5, Ubuntu 14.04

document.queryCommandSupported(cut), document.queryCommandSupported(copy) , document.queryCommandSupported(paste) returned true on Console and Invoking the test Page : returns true in console.

Attached screen shot for the same.

Adding TE-Verified labels.
Screen Shot 2015-10-20 at 11.16.59 AM.png
103 KB View Download

Sign in to add a comment