New issue
Advanced search Search tips

Issue 906266 link

Starred by 2 users

Issue metadata

Status: Unconfirmed
Owner:
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Feature

Blocking:
issue 906276



Sign in to add a comment

Automated copying of HTML nodes (esp. images) for test use

Project Member Reported by huangdarwin@google.com, Nov 16

Issue description

document.execCommand() currently has capability to copy and paste, but can only copy items from a document. The ability to copy generalized nodes (ex. images) would facilitate writing of tests for such a purpose. An example usage could be something like below:

// retrieve <image id='img' src=<file>> node. For now, we can only test image copying 
// in an automated manner via <iframe src=<file>>, which has different behavior.
node = document.getElementById('img'); 
node.execCommand('copy');

Blink>Editing>Command is linked for the sake of execCommand(), but this could be just as helpful if implemented via eventSender or testing APIs.
 
Description: Show this description
Summary: Automated copying of HTML nodes (esp. images) for test use (was: Feature Request for automated copying of images (or hopefully any content) for test use)
Blocking: 906276
Labels: Needs-Feedback
Owner: huangdarwin@google.com
Status: Unconfirmed (was: Untriaged)
It seems you can done this by

function putElementOnClipboard(element) {
  const selection = window.getSelection();
  select.removeAllRanges();
  select.addRange((new Range).selectNode(element));
  node.execCommand('copy');
}

Does this work for you?

@4, Thank you, this should work. I'll try it and report back/close the bug.
Owner: huangdarwin@chromium.org
Project Member

Comment 7 by sheriffbot@chromium.org, Dec 6

Cc: yosin@chromium.org
Labels: -Needs-Feedback
Thank you for providing more feedback. Adding the requester to the cc list.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Labels: Needs-Feedback
Oops sorry for triggering the bot. I haven't had a chance to take a look at this yet.

Sign in to add a comment