Open Bug 1695659 Opened 3 years ago Updated 2 years ago

Inconsistent document.execCommand('paste') behaviour in tabs with iframes

Categories

(WebExtensions :: General, defect, P3)

defect

Tracking

(Not tracked)

People

(Reporter: eros_uk, Unassigned, NeedInfo)

Details

Attachments

(1 file)

804 bytes, application/zip
Details

Firefox 88.0a1 (2021-03-01) (64-bit) Win7

Info

  • activeTab permission
  • paste into textarea, input and contenteditable
  • Pasting from clipboard into above on context-menu onclick
  • same origin file:///C:/Users/.... in test
  • using tabs.executeScript() to inject
  • Injection into all applicable frames are confirmed
  • there are no errors
  • document.execCommand('paste') returns true when works and returns false when it fails

Testing on 2 HTML pages

  • An HTML page with input, textarea & contenteditable elements
  • As above plus an iframe that also has input, textarea & contenteditable elements

Also tested on random web pages.

allFrames: false

const code = `(() => document.execCommand('paste'))();`;
chrome.tabs.executeScript({code}, (result = []) => {
  console.log(result);
});

Result

  • tab with 1 frame: ✅ paste works in top-frame // Array [ true ]
  • tab with 1+ frames: ❌ paste fails in top-frame // Array [ false ]
  • tab with 1+ frames: ❌ paste fails in sub-frame // Array [ false ]

allFrames: true

const code = `(() => document.execCommand('paste'))();`;
chrome.tabs.executeScript({code, allFrames: true}, (result = []) => {
  console.log(result);
});

Result

  • tab with 1 frame: ✅ paste works in top-frame // Array [ true ]
  • tab with 1+ frames: ❌ paste fails in top-frame // Array [ false, true ]
  • tab with 1+ frames: ✅ paste works in sub-frame // Array [ false, true ]

Result Summary
The behaviour of document.execCommand('paste') appears to be inconsistent when there are more than one frames in a tab.

Attached file 1695659.zip

Bug 1695659 minimal test extension

Does this happen with an extension only or is there some testcase showing the issue also in web pages?

Flags: needinfo?(eros_uk)

I am not sure how to test it in a web page and into top-frame as well as sub-frames and trigger it from a user-action while keeping the document.activeElement the target of the paste.

Flags: needinfo?(eros_uk)
Component: DOM: Editor → General
Product: Core → WebExtensions

Tomislav wants to investigate.

Flags: needinfo?(tomica)
Severity: -- → S4
Priority: -- → P3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: