Closed Bug 1857303 Opened 8 months ago Closed 7 months ago

Copy event is not fired when pressing CTRL+C on contenteditable without selection

Categories

(Core :: DOM: Editor, defect)

Firefox 117
defect

Tracking

()

VERIFIED FIXED
121 Branch
Tracking Status
firefox121 --- verified
firefox122 --- verified

People

(Reporter: sefeng, Assigned: hereisdx, Mentored, NeedInfo)

References

Details

(Keywords: good-first-bug, Whiteboard: [lang=c++] )

Attachments

(1 file)

STR:

  1. Load data:text/html,<div contenteditable=true oncopy='alert(1)'>Copy</div>
  2. Click the div and press CTRL+C

Actual results:

  • No alert

Expected results:

  • Alert fired

The fix is to change the starting point to ComputeEditingHost(LimitInBodyElement::Yes) if IsHTMLEditor() is true. We'd also need a test case for this.

Severity: -- → S3
No longer depends on: 1853650
Mentor: sefeng, masayuki

I'll take this one. Thanks for filing!

Assignee: nobody → hereisdx
Status: NEW → ASSIGNED

@segeng @masayuki I've created a patch to fix this bug. Can you please take a look? I've manually verified that it works, and also added a test.

Flags: needinfo?(sefeng)
Flags: needinfo?(masayuki)

(In reply to sheep424242 from comment #1)

I'll take this one. Thanks for filing!

Thank you for taking this :)

Attachment #9357302 - Attachment description: Bug 1857303 - Fire copy event when pressing Ctrl+C on contenteditable without selection. r?sefeng,masayuki → Bug 1857303 - Fire copy event when pressing Ctrl+C on contenteditable without selection. r?masayuki
Pushed by sefeng@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/bf2277419073
Fire copy event when pressing Ctrl+C on contenteditable without selection. r=sefeng,masayuki
Flags: needinfo?(sefeng)
Flags: needinfo?(masayuki)
Flags: needinfo?(sefeng)
Pushed by sefeng@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/cf6b9d74c2f9
Fire copy event when pressing Ctrl+C on contenteditable without selection. r=sefeng,masayuki
Regressions: 1858233

Backed out for causing failures on test_contenteditable_copy_empty_selection.html

[task 2023-10-10T20:17:04.265Z] 20:17:04     INFO - TEST-START | editor/libeditor/tests/test_contenteditable_copy_empty_selection.html
[task 2023-10-10T20:17:04.319Z] 20:17:04     INFO - GECKO(4888) | [Child 4893, Main Thread] WARNING: '!originalEventTargetNode', file /builds/worker/checkouts/gecko/editor/libeditor/EditorEventListener.cpp:1152
[task 2023-10-10T20:17:04.320Z] 20:17:04     INFO - GECKO(4888) | [Child 4893, Main Thread] WARNING: EditorEventListener::Focus() failed: 'NS_SUCCEEDED(rv)', file /builds/worker/checkouts/gecko/editor/libeditor/EditorEventListener.cpp:473
[task 2023-10-10T20:17:04.320Z] 20:17:04     INFO - GECKO(4888) | [Child 4893, Main Thread] WARNING: EditorEventListener::HandleEvent() failed: 'NS_SUCCEEDED(rv)', file /builds/worker/checkouts/gecko/editor/libeditor/HTMLEditorEventListener.cpp:104
[task 2023-10-10T20:17:04.320Z] 20:17:04     INFO - GECKO(4888) | [Child 4893, Main Thread] WARNING: '!content', file /builds/worker/checkouts/gecko/editor/libeditor/HTMLEditor.cpp:6983
[task 2023-10-10T20:17:04.323Z] 20:17:04     INFO - GECKO(4888) | [Child 4893, Main Thread] WARNING: '!content', file /builds/worker/checkouts/gecko/editor/libeditor/HTMLEditor.cpp:6983
[task 2023-10-10T20:17:04.340Z] 20:17:04     INFO - TEST-INFO | started process screencapture
[task 2023-10-10T20:17:04.462Z] 20:17:04     INFO - TEST-INFO | screencapture: exit 0
[task 2023-10-10T20:17:04.462Z] 20:17:04     INFO - Buffered messages logged at 20:17:04
[task 2023-10-10T20:17:04.463Z] 20:17:04     INFO - must wait for load
[task 2023-10-10T20:17:04.463Z] 20:17:04     INFO - Buffered messages finished
[task 2023-10-10T20:17:04.463Z] 20:17:04     INFO - TEST-UNEXPECTED-FAIL | editor/libeditor/tests/test_contenteditable_copy_empty_selection.html | Copy event should be fired 
[task 2023-10-10T20:17:04.463Z] 20:17:04     INFO -     SimpleTest.ok@SimpleTest/SimpleTest.js:426:16
[task 2023-10-10T20:17:04.463Z] 20:17:04     INFO -     @editor/libeditor/tests/test_contenteditable_copy_empty_selection.html:27:15
[task 2023-10-10T20:17:04.463Z] 20:17:04     INFO -     SimpleTest.waitForFocus/<@SimpleTest/SimpleTest.js:1058:13
[task 2023-10-10T20:17:04.464Z] 20:17:04     INFO - GECKO(4888) | MEMORY STAT | vsize 7089MB | residentFast 161MB | heapAllocated 23MB
[task 2023-10-10T20:17:04.465Z] 20:17:04     INFO - TEST-OK | editor/libeditor/tests/test_contenteditable_copy_empty_selection.html | took 186ms
Flags: needinfo?(hereisdx)
Blocks: 1853650
Pushed by sefeng@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/5fc128a7751b
Fire copy event when pressing Ctrl+C on contenteditable without selection. r=sefeng,masayuki
Status: ASSIGNED → RESOLVED
Closed: 7 months ago
Resolution: --- → FIXED
Target Milestone: --- → 121 Branch
Duplicate of this bug: 1853650
QA Whiteboard: [qa-121b-p2]

Reproduced this issue on an affected nightly build from 2023-10-05 on Win 10.
Verified as fixed on Firefox 121.0b4 (20231127091758) and 122.0a1 (20231129050021) on Ubuntu 22, macOS 11 and Windows 10.

Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: