Open Bug 1494266 Opened 6 years ago Updated 2 years ago

Please extend the clipboard API with access to the X selection buffer


(Core :: XPCOM, enhancement, P5)

63 Branch





(Reporter: dam, Unassigned)


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:

(All that follows is under 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 (

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[';1']
        if (!clip) return null;

        var trans = Components.classes[';1']
        if (!trans) return null;

        if (typeof(trans.init) === 'function')

// Here we can request the X selection
                ? clip.kSelectionClipboard
                : clip.kGlobalClipboard

Please extend the clipboard API with access to the X selection.
Component: General → DOM
Product: WebExtensions → Core
Nika, any thoughts on this?
Flags: needinfo?(nika)
Exposing this on the web would require an extension to the clipboard standard 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.
Flags: needinfo?(nika)
Priority: -- → P3
Component: DOM → DOM: Core & HTML
Type: defect → enhancement
Blocks: 1619251
Priority: P3 → P5

Moving this back to WebExtensions as this is not part of the standard and I suspect it will not be standardized as it is highly platform-specific.

Component: DOM: Core & HTML → Untriaged
Product: Core → WebExtensions
No longer blocks: 1619251

The Bugbug bot thinks this bug should belong to the 'Core::XPCOM' component, and is moving the bug to that component. Please revert this change in case you think the bot is wrong.

Component: Untriaged → XPCOM
Product: WebExtensions → Core
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.