Closed
Bug 1364708
Opened 8 years ago
Closed 5 years ago
Update test code to reflect recommended way to read clipboard from the background page
Categories
(WebExtensions :: General, enhancement, P5)
WebExtensions
General
Tracking
(Not tracked)
RESOLVED
WONTFIX
webextensions | ? |
People
(Reporter: zombie, Assigned: zombie)
Details
(Whiteboard: triaged)
See Andy's example https://github.com/andymckay/clippy
Assignee | ||
Comment 1•8 years ago
|
||
Will investigate what's the difference between this and our tests.
Assignee: nobody → tomica
Updated•8 years ago
|
webextensions: --- → ?
Priority: -- → P2
Whiteboard: triaged
Assignee | ||
Comment 2•8 years ago
|
||
So, it turns out a <textarea>, contentEditable and .value DOM property don't mix very well, and .textContent should be used instead. This code works for me (with extensions.remote=true).
let area = document.createElement("textarea");
area.contentEditable = true;
document.body.appendChild(area);
function paste() {
area.textContent = '';
area.select();
console.log('Pre-paste: ' + area.value);
console.log(document.execCommand("paste"));
console.log('Post-paste: ' + area.value);
}
function copy(text) {
area.textContent = text;
area.select();
console.log('Pre-copy: ' + area.value);
console.log(document.execCommand("copy"));
console.log('Post-copy: ' + area.value);
}
This bug could be about updating our test to use the same (recommended) code, but that's likely a lower priority.
Comment 3•8 years ago
|
||
I can't get copy to work by using a background page with remote set to true, in Nightly on Windows.
Comment 4•8 years ago
|
||
I'm an idiot, I was setting the value in the wrong browser. Ignore my last comment.
Assignee | ||
Updated•7 years ago
|
Priority: P2 → P5
Summary: Reading clipboard from the background page doesn't work → Update test code to reflect recommended way to read clipboard from the background page
Updated•6 years ago
|
Product: Toolkit → WebExtensions
Comment 5•6 years ago
|
||
This is still needed. Can probably use the Clipboard Web API for the text part.
Comment 6•5 years ago
|
||
The existing tests use .value
, which has been working for the past few years.
Setting .textContent
would be equivalent to setting .defaultValue
. That is not wrong, but it is not necessary either.
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → WONTFIX
You need to log in
before you can comment on or make changes to this bug.
Description
•