Closed Bug 1824155 Opened 2 years ago Closed 5 months ago

Accessible Caret shows on both iframes

Categories

(Core :: DOM: UI Events & Focus Handling, defect)

Unspecified
All
defect

Tracking

()

VERIFIED FIXED
128 Branch
Tracking Status
firefox128 --- verified
firefox129 --- verified

People

(Reporter: m_kato, Assigned: sefeng)

References

(Blocks 1 open bug, Regressed 1 open bug)

Details

(Whiteboard: [fxdroid], [wptsync upstream])

Attachments

(3 files)

Attached image screen shot

Environment

  • Firefox Nightly or GeckoView Example with Fission (./mach run --enable-fission)
  • Android
  • Windows 10 tablet mode.

Step

  1. Run with Fission
  2. Open https://wontfix.net/bugs/iframe1.html. (all iframe are OOP)
  3. Select "area" text in 3rd iframe by long tap
  4. Select "foo" text in 2nd iframe by long tap

Result

2nd iframe and 3rd iframe show accessible caret. If not fission (or https://wontfix.dev/bugs/iframe1.html), it isn't show on both. See attached screen shot.

Expected Result

Don't show 2 accessible carets at same time.

Notes

After this, when moving accessible caret, It seems to hit this assertion.

MOZ_Assert: Assertion failure: GetCaretMode() != CaretMode::None, at /builds/worker/checkouts/gecko/layout/base/AccessibleCaretManager.cpp:510
Whiteboard: [fxdroid]

Hi Edgar, the Firefox Android is preparing to run Fission related experiments staring around the end of Q3, and would like to get any remaining blocking bugs addressed by 128 Release. Could you help triage and fix this issue?

Flags: needinfo?(echen)
Attached file focus.html

I think this is a focus bug,

STR:

  1. click input in first iframe.
  2. focus moves to the first iframe.
  3. click second iframe (not on input element).

Actual behavior:
There is no blur event fired on first iframe.

Expected behavior:
blur event is fired on first iframe.

Component: DOM: Selection → DOM: UI Events & Focus Handling

Forwarding the needinfo to me that I need to explore resourcing plan on the team.

Flags: needinfo?(echen) → needinfo?(htsai)

I guess that we have to handle blur of iframe window on Accessible Caret. But I don't know we can receive something event like blur of OOP frame.

Ting-Yu, do you have an idea to to fix this?

Flags: needinfo?(aethanyc)

AccessibleCaret already handles blur event by hiding the carets in AccessibleCaretManager::OnBlur(). Per comment 2, we don't fire blur event on <input> when switching focus to a different iframe. I can also reproduce it in desktop. Note that if I repeat the step 3 again, the blur event does fire.

Unfortunately, I'm not familiar with focus handling and blur events, so I don't have any idea to fix this bug. But I believe if the blur events are fired correctly, AccessibleCaret should be able to react on it.

Flags: needinfo?(aethanyc)

(In reply to Edgar Chen [:edgar] from comment #2)

  1. click second iframe (not on input element).

When user clicks on the iframe body, nsFocusManager::SetFocusedWindow() is called in EventStateManager::PostHandleEvent() to switch focus to the target window. Since it is an OOP iframe, we cannot get the frame element (that lives in different process). So we end up at https://searchfox.org/mozilla-central/rev/8e885f04a0a4ff6d64ea59741c10d9b8e45d9ff8/dom/base/nsFocusManager.cpp#413-421. From the code comment, those code are for top-level window, but the target frame isn't a top-level window.

Compare to e10s, it runs https://searchfox.org/mozilla-central/rev/8e885f04a0a4ff6d64ea59741c10d9b8e45d9ff8/dom/base/nsFocusManager.cpp#409-411 instead, which will trigger blur steps in https://searchfox.org/mozilla-central/rev/8e885f04a0a4ff6d64ea59741c10d9b8e45d9ff8/dom/base/nsFocusManager.cpp#1784.

Triggering blur steps for OOP iframe, something like https://hg.mozilla.org/try/rev/7d44e47b09b38400495a778b7dd5543348b67e92#l1.19, can make the AccessibleCaret behave as expected. But I am not sure if it is sufficient or even correct from focus handling point of view. There are some failures on try result, https://treeherder.mozilla.org/jobs?repo=try&revision=6013e04e41fb5b252402f9ddd25a50e343dbe64b&group_state=expanded, haven't checked those failures, either.

I am working on this

Assignee: nobody → sefeng
Flags: needinfo?(htsai)
Attachment #9403592 - Attachment description: Bug 1824155 - Ensure focused browsing context is blurred when an OOP window is focused → Bug 1824155 - Ensure focused browsing context is blurred when an OOP window is focused r=#dom-core,edgar
Pushed by sefeng@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/c1fdd0149a3b Ensure focused browsing context is blurred when an OOP window is focused r=edgar,dom-core

Backed out for causing linting opt failures.

  • Backout link
  • Push with failures
  • Failure Log
  • Failure line: TEST-UNEXPECTED-ERROR | /builds/worker/checkouts/gecko/testing/web-platform/tests/focus/focus-event-after-switching-iframes.sub.html:0 | Missing <script src='/resources/testdriver-vendor.js'> (MISSING-TESTDRIVER-VENDOR)
Flags: needinfo?(sefeng)
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/46519 for changes under testing/web-platform/tests
Whiteboard: [fxdroid] → [fxdroid], [wptsync upstream]
Flags: needinfo?(sefeng)
Upstream PR was closed without merging
Pushed by sefeng@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/24f2a6791095 Ensure focused browsing context is blurred when an OOP window is focused r=edgar,dom-core
Regressions: 1899441
Upstream PR merged by moz-wptsync-bot
Status: NEW → RESOLVED
Closed: 5 months ago
Resolution: --- → FIXED
Target Milestone: --- → 128 Branch
Flags: qe-verify+

Issue is reproducible on a 2024-05-28 Nightly build on Windows 10, using the STR and testcase from Comment 2.
Verified as fixed on Firefox 128.0b2 and Firefox Nightly 129.0a1 on Windows 10, Ubuntu 22, macOS 14.

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

Attachment

General

Created:
Updated:
Size: