I am developing a webextension for a security product which manage passwords. We have a feature which will allow our users to copy a password, which will be cleared from clipboard after their preffered timeout. I had to move the code for coping the string to the popup script, since firefox does not allow an element to be focussed nor selected. This does not work in google chrome for us, the timer placed in popup script works only when the popup is open and it doesn’t clear the copied text in firefox for some unknown reason(could be the same as in chrome). Please Advice.
If you use a timer - make sure that the page is still visible (i.e. that the popup is not closed).
If you use the clipboard API (i.e. adding a listener to the “copy” event and then trigger the event via document.execCommand("copy")), don’t use just clear the data, but also set some data, e.g. event.clipboardData.setData("text/plain", " ");.
And note that you are able to copy data to the clipboard from the background page when out-of-process WebExtensions are enabled. Eventually this is going to be enabled by default, but until then, visit about:config and set extensions.webextensions.remote to true.