Open Bug 1494266 Opened 5 years ago Updated 1 year ago
Please extend the clipboard API with access to the X selection buffer
User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0 Build ID: 20100101 Steps to reproduce: I have a web-extension that uses the clipboard's content to offer quick queries: https://addons.mozilla.org/en-US/firefox/addon/debian-buttons/ (All that follows is under X.org or Wayland under Debian/sid) Upon activation, it does an automatic Paste in a text input. However, this gets the contents of the desktop environment's clipboard, and I'd like to be able to get the X selection instead (https://en.wikipedia.org/wiki/Clipboard_(computing)#X_Window_System). Actual results: execCommand('Paste') or clipboard.readText() get the contents of the desktop environment's clipboard and there is no way to retrieve the X selection Expected results: In the XPCOM era it was possible to get the contents of the X selection: var clip = Components.classes['@mozilla.org/widget/clipboard;1'] .getService(Components.interfaces.nsIClipboard); if (!clip) return null; var trans = Components.classes['@mozilla.org/widget/transferable;1'] .createInstance(Components.interfaces.nsITransferable); if (!trans) return null; if (typeof(trans.init) === 'function') trans.init(null); trans.addDataFlavor("text/unicode"); // // Here we can request the X selection // clip.getData(trans, clip.supportsSelectionClipboard() ? clip.kSelectionClipboard : clip.kGlobalClipboard ); Please extend the clipboard API with access to the X selection.
Nika, any thoughts on this?
Exposing this on the web would require an extension to the clipboard standard https://w3c.github.io/clipboard-apis/. There is no mechanism to select which selection to read from in that mechanism. Currently we avoid specialized APIs for webextensions when possible, so there's no obvious place to add a webextension-only capability. Currently the standard expects a single clipboard.
Component: DOM → DOM: Core & HTML
Component: DOM: Core & HTML → Untriaged
Product: Core → WebExtensions
Component: Untriaged → XPCOM
Product: WebExtensions → Core
You need to log in before you can comment on or make changes to this bug.