[clipboard-apis] Fix the handling of password fields with the copy and cut actions (#5)

For privacy reasons, UAs typically don't allow the user to cut/copy anything from within the a password field (`<input type=password>`).  The current spec ignores this case in the cut and copy action, and at least in Gecko we're probably not going to implement that.  Here is my proposal for how the spec should be changed to deal with this:

I propose the step 3 of the spec should be changed as below:

```
If the event was not cancelled
    If the currently focused element of the Document is a input element with type=password, return false and abort these steps.
    Copy the selected contents, if any, to the clipboard. Implementations should create alternate text/html and text/plain clipboard formats when content in a web page is selected.
else, if the event was cancelled
    Call the writing contents to the clipboard algorithm, passing on the DataTransferItemList list items, a clear-was-called flag and a types-to-clear list.
```

And similarly for cut, I propose to change step 3 to:

```
If the event was not cancelled
    If the currently focused element of the Document is a input element with type=password, return false and abort these steps.
    If there is a selection in an editable context
            Copy the selected contents, if any, to the clipboard. Implementations should create alternate text/html and text/plain clipboard formats when content in a web page is selected.
            Remove the contents of the selection from the document and collapse the selection.
            Queue tasks to fire any events that should fire due to the modification, see interaction with other events for details.
    Else, if there is no selection or the context is not editable
        Do nothing
Else, if the event was cancelled
    Call the writing contents to the clipboard algorithm, passing on the DataTransferItemList list items, a clear-was-called flag and a types-to-clear list.
```

---
Reply to this email directly or view it on GitHub:
https://github.com/w3c/clipboard-apis/issues/5

Received on Friday, 8 May 2015 18:44:19 UTC