Closed Bug 1883367 Opened 2 years ago Closed 2 years ago

Disable editor commands for read-only editors

Categories

(Core :: DOM: Editor, defect)

defect

Tracking

()

RESOLVED FIXED
125 Branch
Tracking Status
firefox125 --- fixed

People

(Reporter: john, Assigned: john)

References

Details

Attachments

(1 file, 1 external file, 1 obsolete file)

I encountered this bug while working on Thunderbird Bug 1758469.

STR:

  • Run latest Thunderbird with https://phabricator.services.mozilla.com/D202887 applied (Locking is currently broken entirely, I hope the fix lands soon, so you can test with Daily: Go to https://www.thunderbird.net/en-US/thunderbird/all/ and scroll to the bottom and select "Daily Channel" on the right.)
  • Install the attached add-on (which helps to see the compose editor in the read-only state).
  • Create a new message (make sure it is an HTML message - which is default - and not a plain text message).
  • Enter a "to" address (can be a dummy).
  • Enter a subject.
  • Enter some text in the message body.
  • Click on "Send". The installed add-on will block sending and instead lock the composer.
  • Observe that neither the subject nor the body can be modified.
  • Observe however, that text in the body can be selected (which is not an error), and the bold command is still enabled
    • clicking the bold icon modifies the composer
    • using shortcuts (CTRL+B) modifies the composer

The proposed patch adds a check for EditorBase::IsModifiable() to EditorCommand::IsCommandEnabled and disables all editor commands, when the editor is read-only

Attached file lock.xpi —
Blocks: 1758469
Assignee: nobody → john
Status: NEW → ASSIGNED
Attachment #9389076 - Attachment description: Bug 1883367 - Make isSelectionEditable() return false, if the editor is readOnly. r=hsinyi → Bug 1883367 - Make isSelectionEditable() return false, if the editor is readOnly. r=masayuki
Severity: -- → S3

The purpose of this patch is to prevent users to make changes to
read-only editors.

This patch forces IsCommandEnabled() to return false for read-only
editors for "standard" editor commands that could have an associated
icon or menu entry and are therefore user-accessible.

Advanced internal editor commands are not touched.

Attachment #9389076 - Attachment is obsolete: true
Summary: Make isSelectionEditable() return false, if the editor is readOnly → Disable editor commands for read-only editors
Pushed by john@thunderbird.net: https://hg.mozilla.org/integration/autoland/rev/dd6b961d3b69 Disable editor commands for read-only editors. r=masayuki

Backed out for causing mochites failures in test_command_state_when_readonly_in_chrome.html

  • Backout link
  • Push with failures
  • Failure Log
  • Failure line: TEST-UNEXPECTED-FAIL | editor/libeditor/tests/test_command_state_when_readonly_in_chrome.html | Enabled state of command cmd_paste should be TRUE for {"content":"empty","selected":true,"readonly":false} - got false, expected true
Flags: needinfo?(john)

Removing the broken new test (it is not testing new behavior, but is wrongly testing existing behavior)

Flags: needinfo?(john)
Pushed by john@thunderbird.net: https://hg.mozilla.org/integration/autoland/rev/2c3d04d02bf0 Disable editor commands for read-only editors. r=masayuki
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 125 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: