Closed Bug 1841656 Opened 11 months ago Closed 8 months ago

Firefox Translations doesn't deal with Shadow DOM

Categories

(Firefox :: Translations, defect, P3)

Firefox 117
defect

Tracking

()

RESOLVED FIXED
120 Branch
Tracking Status
firefox118 --- fixed
firefox119 --- fixed
firefox120 --- fixed

People

(Reporter: mozinet, Assigned: sefeng)

References

(Blocks 1 open bug)

Details

Attachments

(3 files)

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/117.0

Steps to reproduce:

Open https://ko-fi.com/post/If-You-Suffer-from-Urgent-Normal-Syndrome-Ask-for-K3K6MN65U in Firefox Nightly.

Translate the page with the built-in Firefox Translations feature, in French, for example.

Actual results:

The title of the article and the page menus have been translated, however, the article text remains in its original English language.

Expected results:

All the text of the page needs to be translated.

Attachment #9342242 - Attachment description: firefox_o2YzChCgt9.png → Partially translated page in French
Component: Untriaged → Translation
Blocks: 1838721
No longer blocks: fx-translation

This is a more general problem. The article contents are inside a shadow root. Greg, Translations don't seem to handle shadow dom at all which seems like it could affect a bunch of pages.

Flags: needinfo?(gtatum)
Summary: Firefox Translations in Nightly just doesn't translate the article text on this page → Firefox Translations doesn't deal with Shadow DOM

Seems the TreeWalker class doesn't handle the shadow DOM. I found some discussion here: https://github.com/whatwg/dom/issues/665

I guess we'll need to find a way to recurse into it. The extension also can't handle the shadow DOM.

Flags: needinfo?(gtatum)

We expose .openOrClosedShadowRoot to extensions and chrome code.

Status: UNCONFIRMED → NEW
Ever confirmed: true

So it looks like we'll need to call addRootElement for shadow DOMs that we encounter while walking the nodes.

The severity field is not set for this bug.
:nordzilla, could you have a look please?

For more information, please visit BugBot documentation.

Flags: needinfo?(enordin)
Severity: -- → S2
Priority: -- → P3
Flags: needinfo?(enordin)
Blocks: 1845772
No longer blocks: 1838721
Assignee: nobody → sefeng
Status: NEW → ASSIGNED

The test page isn't loading for me on Nightly. I can't confirm the fix, and I'm having trouble finding examples to try.

Attached file simple-testcase.html

Here's a simple test case for this.

I just updated the patch (there's was a bug in my original approach), and have tested it with both sites.

Pushed by sefeng@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/c12f569ae50b
Make Firefox Translation iterates nodes inside ShadowDOM r=gregtatum
Status: ASSIGNED → RESOLVED
Closed: 8 months ago
Resolution: --- → FIXED
Target Milestone: --- → 120 Branch

Sean, what do you think of uplifting the fix to 119 or even 118?

Flags: needinfo?(sefeng)
Blocks: 1855307

Macro found out some content on https://www.suewag.de/privatkunden were still not being translated.

It turned out there were two issues. One related to slotted content and the other related to ShadowDOM mutations.

I plan to land a patch in Bug 1855307 to address those. We have an existing bugs open for ShadowDOM mutations as Bug 1842820, unfortunately I tested it with my current approach for ShadowDOM mutations and it didn't fix it. So I'll leave Bug 1842820 as is.

Leave my NI for uplifting this patch along with Bug 1855307.

Duplicate of this bug: 1852337
No longer duplicate of this bug: 1852337

Comment on attachment 9354420 [details]
Bug 1841656 - Make Firefox Translation iterates nodes inside ShadowDOM r=gregtatum

Beta/Release Uplift Approval Request

  • User impact if declined: Content in shadow dom won't be translated by Firefox Translation
  • Is this code covered by automated tests?: Yes
  • Has the fix been verified in Nightly?: Yes
  • Needs manual test from QE?: No
  • If yes, steps to reproduce:
  • List of other uplifts needed: Bug 1855307
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): This is low risky because the change is trivial and is covered by automated test.
  • String changes made/needed:
  • Is Android affected?: No
Flags: needinfo?(sefeng)
Attachment #9354420 - Flags: approval-mozilla-beta?

Comment on attachment 9354420 [details]
Bug 1841656 - Make Firefox Translation iterates nodes inside ShadowDOM r=gregtatum

Beta/Release Uplift Approval Request

  • User impact if declined: Content in shadow dom will not be translated
  • Is this code covered by automated tests?: Yes
  • Has the fix been verified in Nightly?: Yes
  • Needs manual test from QE?: No
  • If yes, steps to reproduce:
  • List of other uplifts needed: Bug 1855307
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): This is low risky because the change is trivial and is covered by automated test
  • String changes made/needed:
  • Is Android affected?: No
Attachment #9354420 - Flags: approval-mozilla-release?

Comment on attachment 9354420 [details]
Bug 1841656 - Make Firefox Translation iterates nodes inside ShadowDOM r=gregtatum

Approved for 119.0b5

Attachment #9354420 - Flags: approval-mozilla-beta? → approval-mozilla-beta+

Comment on attachment 9354420 [details]
Bug 1841656 - Make Firefox Translation iterates nodes inside ShadowDOM r=gregtatum

Approved for our next 118 dot release, thanks.

Attachment #9354420 - Flags: approval-mozilla-release? → approval-mozilla-release+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: