Disable by default translation when the content is a pdf
Categories
(Firefox :: Translations, defect, P3)
Tracking
()
Tracking | Status | |
---|---|---|
firefox-esr115 | --- | unaffected |
firefox116 | --- | wontfix |
firefox120 | --- | wontfix |
firefox121 | --- | wontfix |
firefox122 | --- | fixed |
People
(Reporter: calixte, Assigned: peterodejobi9, Mentored)
References
Details
(Keywords: good-first-bug)
Attachments
(2 files, 7 obsolete files)
In running the profiler when loading a pdf (https://share.firefox.dev/3qwqZcF) I saw that the translation worker is active.
For now, I think it's useless to waste some resources since we don't have something to propose to the user to read the translation, hence we should disable translations in the pdf case.
Comment 1•10 months ago
|
||
This will be mitigated by Bug 1836974, but we should at least look into loading random content types like SVG and PDF that are not html pages.
Comment 2•10 months ago
|
||
Adding a check of this.document.nodePrincipal.originNoSuffix === "resource://pdf.js"
in the TranslationsChild would do it, but it doesn't seem like a very elegant solution, since we'd want to do the same for other non-translatable document types.
Comment 4•9 months ago
|
||
Ah, I found: gBrowser.selectedBrowser.documentContentType
Which reports:
"application/pdf"
Comment 5•6 months ago
|
||
This would be a good first bug.
I think it may be best to make isRestrictedPage
aware of the documentContentType
as well as the scheme.
A contributor will have to investigate isRestrictedPage
and its current usage, then adapt it to check the documentContentType
in addition to the scheme that it already checks.
https://searchfox.org/mozilla-central/search?q=isRestrictedPage
A contributor will also have to add tests to show that Translations is not available on pdf pages.
https://searchfox.org/mozilla-central/source/browser/components/translations/tests/browser
Updated•6 months ago
|
Assignee | ||
Comment 7•6 months ago
|
||
(In reply to Erik Nordin [:nordzilla] from comment #5)
This would be a good first bug.
I think it may be best to make
isRestrictedPage
aware of thedocumentContentType
as well as the scheme.A contributor will have to investigate
isRestrictedPage
and its current usage, then adapt it to check thedocumentContentType
in addition to the scheme that it already checks.https://searchfox.org/mozilla-central/search?q=isRestrictedPage
A contributor will also have to add tests to show that Translations is not available on pdf pages.
https://searchfox.org/mozilla-central/source/browser/components/translations/tests/browser
Hi Erik. so i have made the isRestricted method check for the documentContentType but i need help understanding how to run tests in the Test files, they are a lot and i don't know where or how to start.
Comment 8•6 months ago
•
|
||
To run the Translations test suite you would run the following command:
mach test browser/components/translations/tests toolkit/components/translations/tests
That runs all of the tests in our two paths where we keep Translations tests.
You can add the --headless
flag to disable the GUI and only run them in the terminal, if you want.
But you'll also need to add a new test to test this PDF behavior.
Just grabbing a blank PDF file should be fine. It looks like one already exists in tree:
https://searchfox.org/mozilla-central/search?q=empty_pdf_file&path=&case=false®exp=false
You'll need to copy this file and add it as a support file in our test code.
Follow translations-tester-es.html
as an example. You'll need to add the pdf file in similar places to make it available from shared-head.js
:
Then you will need to add a new test file itself which navigates to a PDF page and ensures that the Translations icon does not appear, and that the option to translations the page is disabled in the app menu.
We have a lot of helper functions in head.js
to help with this. Please look at the way the other tests work, and model a new test after those.
When you add a new test file, you'll have to enable it in brwoser.toml
.
You can run a specific test (instead of the entire test suite) by typing a test name specifically.
For example if I wanted to run the test file browser_translations_panel_switch_languages.js
I could just invoke:
./mach test panel_switch_lang
since panel_switch_lang
is a substring of that file name.
Comment 9•6 months ago
|
||
hy @peterodejobi9 are still working on this let e know cus i was about to submit a patch until i see you have been working on it too
Comment 10•6 months ago
|
||
i would like to work on this bug, i am kindly requesting to have it assigned to me.
Comment 11•6 months ago
|
||
sorry i had not noticed someone is working on it already
Assignee | ||
Comment 12•6 months ago
|
||
(In reply to bugembe25 from comment #11)
sorry i had not noticed someone is working on it already
Hi Yes please i am working on testing and i will be sending my patch today. Thank you so much.
Assignee | ||
Comment 13•6 months ago
|
||
Updated•6 months ago
|
Assignee | ||
Comment 14•6 months ago
|
||
Depends on D191589
Updated•6 months ago
|
Updated•6 months ago
|
Assignee | ||
Comment 15•6 months ago
|
||
Depends on D191589
Updated•6 months ago
|
Updated•6 months ago
|
Updated•6 months ago
|
Updated•6 months ago
|
Assignee | ||
Comment 16•6 months ago
|
||
Depends on D191589
Comment 17•6 months ago
|
||
peterodejobi9
There is still something chaotic going on with your revision history (see attached screenshot).
There are 4 revisions attached to this bug now, and 2 of them are abandoned, however they are all linked together.
You need to go into Phabricator and look on the right side for "Edit Related Revisions..." and disassociate all of these chains of revisions from each other.
Then you need to go into your local build and consolidate them all. We need to reduce this down to just one single revision, with no parent revisions, and no child revisions. Just one revision to review with all the code changes in one spot.
I understand that you're trying out Mercurial, which you are not familiar with. I think it's great that you're trying out new tools. I also am not familiar with Mercurial and I don't use it myself.
I use Git. If you know how to use Git well, I would recommend that you just switch to Git because we do support both.
I don't know which operating system you are using, but on the setup page each OS has detailed instructions on how to build Firefox with Git instead of Mercurial.
Assignee | ||
Comment 18•6 months ago
|
||
(In reply to Erik Nordin [:nordzilla] from comment #17)
Created attachment 9360138 [details]
revisions.pngpeterodejobi9
There is still something chaotic going on with your revision history (see attached screenshot).
There are 4 revisions attached to this bug now, and 2 of them are abandoned, however they are all linked together.
You need to go into Phabricator and look on the right side for "Edit Related Revisions..." and disassociate all of these chains of revisions from each other.
Then you need to go into your local build and consolidate them all. We need to reduce this down to just one single revision, with no parent revisions, and no child revisions. Just one revision to review with all the code changes in one spot.
I understand that you're trying out Mercurial, which you are not familiar with. I think it's great that you're trying out new tools. I also am not familiar with Mercurial and I don't use it myself.
I use Git. If you know how to use Git well, I would recommend that you just switch to Git because we do support both.
I don't know which operating system you are using, but on the setup page each OS has detailed instructions on how to build Firefox with Git instead of Mercurial.
After doing this do I abandon the other patches ?
Assignee | ||
Comment 19•6 months ago
|
||
Updated•6 months ago
|
Assignee | ||
Comment 20•6 months ago
|
||
Assignee | ||
Comment 21•6 months ago
|
||
Erik i am so sorry about the email notifications, I keep adding the empty pdf file (for test file) to be tracked but it's not submitting along with the rest of the patch so i'm trying to fix it. I'm sorry about the email notifications once again!
Updated•6 months ago
|
Assignee | ||
Comment 22•6 months ago
|
||
Assignee | ||
Comment 23•6 months ago
|
||
Depends on D191824
Comment 24•6 months ago
|
||
peterodejobi9
You are continuing to upload brand new revisions instead of working on a single revision with a single commit.
If you need help modifying your commits, please just ask for help instead of continuing to upload brand new commits and then abandon them.
Here is an article on amending commits using Git:
https://www.atlassian.com/git/tutorials/rewriting-history
I am less familiar with Mercurial, but it looks like it also has a commit --amend
option.
https://www.selenic.com/mercurial/hg.1.html#commit
Please reduce your open revisions down to just one single revision.
Assignee | ||
Comment 25•6 months ago
|
||
(In reply to Erik Nordin [:nordzilla] from comment #24)
peterodejobi9
You are continuing to upload brand new revisions instead of working on a single revision with a single commit.
If you need help modifying your commits, please just ask for help instead of continuing to upload brand new commits and then abandon them.
Here is an article on amending commits using Git:
https://www.atlassian.com/git/tutorials/rewriting-historyI am less familiar with Mercurial, but it looks like it also has a
commit --amend
option.
https://www.selenic.com/mercurial/hg.1.html#commitPlease reduce your open revisions down to just one single revision.
Why i upload new commit is because the last time you talked about always having all the changes in one patch that's why i always create a new patch, Thank you for the review it's noted!.
Updated•6 months ago
|
Updated•6 months ago
|
Updated•6 months ago
|
Updated•6 months ago
|
Updated•6 months ago
|
Updated•5 months ago
|
Updated•5 months ago
|
Comment 26•5 months ago
|
||
Pushed by enordin@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/ed7db9ec0966 [Browser Translations Engine] Modified TranslationsParent.isRestricted method to be aware of contentType and the scheme, also created a testing file.r=nordzilla,translations-reviewers
Comment 27•5 months ago
|
||
bugherder |
Updated•5 months ago
|
Description
•