diff --git a/layout/base/AccessibleCaretManager.cpp b/layout/base/AccessibleCaretManager.cpp index bdf0ebaf9224..af0a67a5aa77 100644 --- a/layout/base/AccessibleCaretManager.cpp +++ b/layout/base/AccessibleCaretManager.cpp @@ -820,9 +820,23 @@ already_AddRefed AccessibleCaretManager::GetFrameSelection() return nullptr; } + nsFocusManager* fm = nsFocusManager::GetFocusManager(); + MOZ_ASSERT(fm); + + nsIContent* focusedContent = fm->GetFocusedElement(); + if (!focusedContent) { + // For non-editable content + return mPresShell->FrameSelection(); + } + + nsIFrame* focusFrame = focusedContent->GetPrimaryFrame(); + if (!focusFrame) { + return nullptr; + } + // Prevent us from touching the nsFrameSelection associated with other // PresShell. - RefPtr fs = mPresShell->GetLastFocusedFrameSelection(); + RefPtr fs = focusFrame->GetFrameSelection(); if (!fs || fs->GetPresShell() != mPresShell) { return nullptr; } diff --git a/layout/base/tests/marionette/test_accessiblecaret_selection_mode.py b/layout/base/tests/marionette/test_accessiblecaret_selection_mode.py index 003daaa9e9e4..6f42c3652ff0 100644 --- a/layout/base/tests/marionette/test_accessiblecaret_selection_mode.py +++ b/layout/base/tests/marionette/test_accessiblecaret_selection_mode.py @@ -31,7 +31,6 @@ class AccessibleCaretSelectionModeTestCase(MarionetteTestCase): _input_size_id = "input-size" _textarea_id = "textarea" _textarea2_id = "textarea2" - _textarea_disabled_id = "textarea-disabled" _textarea_one_line_id = "textarea-one-line" _textarea_rtl_id = "textarea-rtl" _contenteditable_id = "contenteditable" @@ -171,7 +170,6 @@ class AccessibleCaretSelectionModeTestCase(MarionetteTestCase): @parameterized(_input_id, el_id=_input_id) @parameterized(_textarea_id, el_id=_textarea_id) - @parameterized(_textarea_disabled_id, el_id=_textarea_disabled_id) @parameterized(_textarea_rtl_id, el_id=_textarea_rtl_id) @parameterized(_contenteditable_id, el_id=_contenteditable_id) @parameterized(_content_id, el_id=_content_id) @@ -195,7 +193,6 @@ class AccessibleCaretSelectionModeTestCase(MarionetteTestCase): @parameterized(_input_id, el_id=_input_id) @parameterized(_textarea_id, el_id=_textarea_id) - @parameterized(_textarea_disabled_id, el_id=_textarea_disabled_id) @parameterized(_textarea_rtl_id, el_id=_textarea_rtl_id) @parameterized(_contenteditable_id, el_id=_contenteditable_id) @parameterized(_content_id, el_id=_content_id) @@ -229,7 +226,6 @@ class AccessibleCaretSelectionModeTestCase(MarionetteTestCase): @parameterized(_input_id, el_id=_input_id) @parameterized(_textarea_id, el_id=_textarea_id) - @parameterized(_textarea_disabled_id, el_id=_textarea_disabled_id) @parameterized(_textarea_rtl_id, el_id=_textarea_rtl_id) @parameterized(_contenteditable_id, el_id=_contenteditable_id) @parameterized(_content_id, el_id=_content_id) @@ -267,7 +263,6 @@ class AccessibleCaretSelectionModeTestCase(MarionetteTestCase): @parameterized(_input_id, el_id=_input_id) @parameterized(_textarea_id, el_id=_textarea_id) - @parameterized(_textarea_disabled_id, el_id=_textarea_disabled_id) @parameterized(_textarea_rtl_id, el_id=_textarea_rtl_id) @parameterized(_contenteditable_id, el_id=_contenteditable_id) @parameterized(_content_id, el_id=_content_id) @@ -400,7 +395,6 @@ class AccessibleCaretSelectionModeTestCase(MarionetteTestCase): @parameterized(_input_id, el_id=_input_id) @parameterized(_textarea_id, el_id=_textarea_id) - @parameterized(_textarea_disabled_id, el_id=_textarea_disabled_id) @parameterized(_textarea_rtl_id, el_id=_textarea_rtl_id) @parameterized(_contenteditable_id, el_id=_contenteditable_id) @parameterized(_content_id, el_id=_content_id) diff --git a/testing/marionette/harness/marionette_harness/www/layout/test_carets_selection.html b/testing/marionette/harness/marionette_harness/www/layout/test_carets_selection.html index f992ee1ba3bd..bd36f45b2396 100644 --- a/testing/marionette/harness/marionette_harness/www/layout/test_carets_selection.html +++ b/testing/marionette/harness/marionette_harness/www/layout/test_carets_selection.html @@ -28,7 +28,6 @@
-