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
Owner:
Closed: Oct 2015
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 2
Type: Bug



Sign in to add a comment

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

Project Member Reported by mattgaunt@chromium.org, Apr 13 2015

Issue description

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

What steps will reproduce the problem?
1. Visit: http://jsbin.com/taliso/quiet
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.
 
Cc: abhijee...@samsung.com
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 tkent@chromium.org, Apr 16 2015

Cc: dcheng@chromium.org
@ mattgaunt,
I think http://jsbin.com/taliso/quiet is not working anymore. Could you please share test.
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: http://jsbin.com/taliso/latest/edit
Patch is uploaded for review :
https://codereview.chromium.org/1097693003/
Any movement on this bug?

Comment 9 by dcheng@chromium.org, May 19 2015

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

Comment 10 Deleted

Any new internal updates on the patch review? Seems to have gone stagnant again.
Cc: -dcheng@chromium.org
Labels: -OS-Mac OS-All Cr-Blink-DataTransfer
Owner: dcheng@chromium.org
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 https://github.com/w3c/clipboard-apis/issues/4
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?
Any news? I had to write a poyfill to fix this https://github.com/zenorocha/document.queryCommandSupported

Comment 15 by yosin@chromium.org, 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 yosin@chromium.org, 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, http://crrev.com/1406713002, failed following tests:
- ContentCapabilitiesTest.NoCapabilities
- ContentCapabilitiesTest.ClipboardWrite
- ContentCapabilitiesTest.ClipboardRead
- ContentCapabilitiesTest.ClipboardReadWrite
- ClipboardApiTest.HostedAppNoPermission
- ClipboardApiTest.ExtensionNoPermission



Comment 17 by yosin@chromium.org, Oct 14 2015

Owner: yosin@chromium.org
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().
Project Member

Comment 18 by bugdroid1@chromium.org, Oct 15 2015

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/bf9013658c0eb493db5dd0941532160dc9fdd0c7

commit bf9013658c0eb493db5dd0941532160dc9fdd0c7
Author: yosin <yosin@chromium.org>
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 
TEST=LayoutTests/editing/pasteboard/copy-cut-paste-supported.html

Review URL: https://codereview.chromium.org/1406713002

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

[add] http://crrev.com/bf9013658c0eb493db5dd0941532160dc9fdd0c7/third_party/WebKit/LayoutTests/editing/pasteboard/copy-cut-paste-supported.html
[modify] http://crrev.com/bf9013658c0eb493db5dd0941532160dc9fdd0c7/third_party/WebKit/Source/core/editing/commands/EditorCommand.cpp

Comment 19 by yosin@chromium.org, Oct 16 2015

Status: Fixed
Cc: ranjitkan@chromium.org
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 : http://jsbin.com/taliso/quiet 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