Implement `tabs.detectLanguage` for Android
Categories
(GeckoView :: Extensions, enhancement, P3)
Tracking
(firefox117 wontfix, firefox118 fixed)
People
(Reporter: willdurand, Assigned: hliu728, Mentored)
References
(Blocks 1 open bug)
Details
(Keywords: dev-doc-complete, good-first-bug, Whiteboard: [addons-jira])
Attachments
(1 file)
Updated•3 years ago
|
Comment 1•3 years ago
|
||
This has already been implemented in bug 1764698.
| Reporter | ||
Updated•3 years ago
|
| Reporter | ||
Updated•3 years ago
|
Comment 2•3 years ago
|
||
Bug 1764698 added the necessary implementation of i18n.detectLanguage.
But tabs.detectLanguage is not yet available on Android.
With the implementation from i18n.detectLanguage being part of toolkit/ now (bug 1764698), the implementation of tabs.detectLanguage should be quite trivial:
- Add
detectLanguagemethod to Android's ext-tabs.js (desktop version). - Remove
"unsupported": truefromdetectLanguagein Android's schemas/tabs.json. - Move this file from browser/ to toolkit/components/extensions/test/mochitest/ : https://searchfox.org/mozilla-central/rev/0e3779abe6ad44feb787a295fbb67bc9fe4e927a/browser/components/extensions/test/browser/browser_ext_tabs_detectLanguage.js
- This was a browser-chrome test, but does not have to be. It can be a mochitest, which is the only supported "browser" test on Android.
| Reporter | ||
Updated•3 years ago
|
| Reporter | ||
Updated•3 years ago
|
Updated•3 years ago
|
Comment 3•3 years ago
|
||
This is a good first bug for those who want to familiarize themselves with contributing to extensions code in Android. Comment 2 offers pointers.
Hi, I would like to take on this bug! Is there other information that I should know?
Comment 5•3 years ago
|
||
See comment 2 for the code that needs to be changed (along with examples of how the implementation could look like).
If you haven't contributed to extensions code before, here is an article with lots of info (and external links with more info): https://wiki.mozilla.org/WebExtensions/Contribution_Onramp
Hi Rob,
Will moving the test file https://searchfox.org/mozilla-central/rev/0e3779abe6ad44feb787a295fbb67bc9fe4e927a/browser/components/extensions/test/browser/browser_ext_tabs_detectLanguage.js suffice or do we need to rewrite it into a mochitest html test? Thanks!
Comment 7•2 years ago
|
||
The code in the test does not use any special browser chrome APIs, so you can indeed just move the test and wrap it in the necessary HTML. For an example of the HTML, see https://searchfox.org/mozilla-central/rev/ea65de7c7b01ce5e7b2c0d2b6684ce0219cc2914/mobile/android/components/extensions/test/mochitest/test_ext_tabs_create.html#1-14,150-153
To follow the convention of the naming, use test_ext_tabs_detectLanguage.html as the file name.
Note: while you are at it, I suggest to replace http://example.co.jp/ in the test with https://example.com/ . The reason for that is that the test server does not have a SNI for example.co.jp, which breaks the test when run in the HTTPS-First, http2 or http3 test configurations. You can see evidence of the test being skipped on https-first at https://searchfox.org/mozilla-central/rev/ea65de7c7b01ce5e7b2c0d2b6684ce0219cc2914/browser/components/extensions/test/browser/browser.ini#310-311
Hi, I have made all the changes, but am stuck with trying to get the tests working. First thing: it seems like the test is having issues with the browser.tabs.create(), which will result in a unexpected error thrown. Is there any clues as to why this happens? I have also tried copying the support files into mochitest directory, as well as adding the entries into the manifest files for the mochitest.
Also, should the test be added into the mochitest.ini manifest or the mochitest-common.ini manifest?
Looking forward to hearing back! Thanks!
Comment 9•2 years ago
|
||
(In reply to hliu728 from comment #8)
Hi, I have made all the changes, but am stuck with trying to get the tests working. First thing: it seems like the test is having issues with the browser.tabs.create(), which will result in a unexpected error thrown. Is there any clues as to why this happens?
If you run ./mach test with the --log-mach-verbose flag you can see more output than the default. If you are running the test in an Android emulator, use adb logcat to see even more logs that aren't shown by mach test.
I have also tried copying the support files into mochitest directory, as well as adding the entries into the manifest files for the mochitest.
Also, should the test be added into the mochitest.ini manifest or the mochitest-common.ini manifest?
mochitest-common.ini
Looking forward to hearing back! Thanks!
If you are still stuck, feel free to already upload your patch for early review and feedback.
| Assignee | ||
Comment 10•2 years ago
|
||
Updated•2 years ago
|
| Assignee | ||
Comment 11•2 years ago
|
||
I have just uploaded a patch for feedback, and would like more information if possible on why it is failing the test_ext_tabs_detectLanguage.html test. Thanks!
Comment 12•2 years ago
|
||
(In reply to hliu728 from comment #11)
I have just uploaded a patch for feedback, and would like more information if possible on why it is failing the test_ext_tabs_detectLanguage.html test. Thanks!
I responded on the patch itself. The test was failing because the implementation had a typo, see my review at https://phabricator.services.mozilla.com/D184942#6132852
Comment 13•2 years ago
|
||
Comment 14•2 years ago
|
||
Backed out for causing mochitest-plain failures on test_ext_all_apis.html.
[task 2023-08-14T14:54:01.967Z] 14:54:01 INFO - TEST-PASS | mobile/android/components/extensions/test/mochitest/test_ext_all_apis.html | namespaces are same object
[task 2023-08-14T14:54:01.967Z] 14:54:01 INFO - add_task | Leaving test_enumerate_content_script_apis
[task 2023-08-14T14:54:01.967Z] 14:54:01 INFO - add_task | Entering test_enumerate_background_script_apis
[task 2023-08-14T14:54:01.967Z] 14:54:01 INFO - Extension loaded
[task 2023-08-14T14:54:01.967Z] 14:54:01 INFO - Buffered messages finished
[task 2023-08-14T14:54:01.967Z] 14:54:01 WARNING - TEST-UNEXPECTED-FAIL | mobile/android/components/extensions/test/mochitest/test_ext_all_apis.html | background script APIs - Structures begin differing at:
[task 2023-08-14T14:54:01.967Z] 14:54:01 INFO - got['65'] = "browser.tabs.detectLanguage"
[task 2023-08-14T14:54:01.968Z] 14:54:01 INFO - expected['65'] = "browser.tabs.executeScript"
[task 2023-08-14T14:54:01.968Z] 14:54:01 INFO - SimpleTest.isDeeply@SimpleTest/SimpleTest.js:1942:16
[task 2023-08-14T14:54:01.968Z] 14:54:01 INFO - test_enumerate_background_script_apis@mobile/android/components/extensions/test/mochitest/test_ext_all_apis.js:211:11
[task 2023-08-14T14:54:01.968Z] 14:54:01 INFO - async*nextTick/<@SimpleTest/SimpleTest.js:2147:34
[task 2023-08-14T14:54:01.968Z] 14:54:01 INFO - async*nextTick@SimpleTest/SimpleTest.js:2182:11
[task 2023-08-14T14:54:01.968Z] 14:54:01 INFO - setTimeout handler*SimpleTest_setTimeoutShim@SimpleTest/SimpleTest.js:920:41
[task 2023-08-14T14:54:01.968Z] 14:54:01 INFO - add_task@SimpleTest/SimpleTest.js:2096:17
[task 2023-08-14T14:54:01.969Z] 14:54:01 INFO - @mobile/android/components/extensions/test/mochitest/test_ext_all_apis.js:166:9
[task 2023-08-14T14:54:01.969Z] 14:54:01 INFO - TEST-PASS | mobile/android/components/extensions/test/mochitest/test_ext_all_apis.html | namespaces are different objects
[task 2023-08-14T14:54:01.969Z] 14:54:01 INFO - add_task | Leaving test_enumerate_background_script_apis
[task 2023-08-14T14:54:01.969Z] 14:54:01 INFO - add_task | Entering test_enumerate_background_script_apis_mv3
[task 2023-08-14T14:54:01.969Z] 14:54:01 INFO - Extension loaded
[task 2023-08-14T14:54:01.969Z] 14:54:01 WARNING - TEST-UNEXPECTED-FAIL | mobile/android/components/extensions/test/mochitest/test_ext_all_apis.html | background script APIs in MV3 - Structures begin differing at:
[task 2023-08-14T14:54:01.969Z] 14:54:01 INFO - got['62'] = "browser.tabs.detectLanguage"
[task 2023-08-14T14:54:01.969Z] 14:54:01 INFO - expected['62'] = "browser.tabs.get"
[task 2023-08-14T14:54:01.969Z] 14:54:01 INFO - SimpleTest.isDeeply@SimpleTest/SimpleTest.js:1942:16
[task 2023-08-14T14:54:01.970Z] 14:54:01 INFO - test_enumerate_background_script_apis_mv3@mobile/android/components/extensions/test/mochitest/test_ext_all_apis.js:238:11
[task 2023-08-14T14:54:01.970Z] 14:54:01 INFO - async*nextTick/<@SimpleTest/SimpleTest.js:2147:34
[task 2023-08-14T14:54:01.970Z] 14:54:01 INFO - async*nextTick@SimpleTest/SimpleTest.js:2182:11
[task 2023-08-14T14:54:01.970Z] 14:54:01 INFO - setTimeout handler*SimpleTest_setTimeoutShim@SimpleTest/SimpleTest.js:920:41
[task 2023-08-14T14:54:01.970Z] 14:54:01 INFO - add_task@SimpleTest/SimpleTest.js:2096:17
[task 2023-08-14T14:54:01.970Z] 14:54:01 INFO - @mobile/android/components/extensions/test/mochitest/test_ext_all_apis.js:166:9
[task 2023-08-14T14:54:01.970Z] 14:54:01 INFO - TEST-PASS | mobile/android/components/extensions/test/mochitest/test_ext_all_apis.html | namespaces are same object
[task 2023-08-14T14:54:01.970Z] 14:54:01 INFO - add_task | Leaving test_enumerate_background_script_apis_mv3
[task 2023-08-14T14:54:01.971Z] 14:54:01 INFO - TEST-OK | mobile/android/components/extensions/test/mochitest/test_ext_all_apis.html | took 3304ms
[task 2023-08-14T14:54:01.971Z] 14:54:01 INFO - TEST-START | mobile/android/components/extensions/test/mochitest/test_ext_downloads_event_page.html
Comment 15•2 years ago
|
||
To fix the above test failure, please update the patch by adding tabs.detectLanguage in the following file, after line 24: https://searchfox.org/mozilla-central/rev/da1e39f50ef43145623938141c970437b226da9e/mobile/android/components/extensions/test/mochitest/test_ext_all_apis.html#24-25
Comment 16•2 years ago
|
||
Comment 17•2 years ago
|
||
| bugherder | ||
Comment 18•2 years ago
|
||
Android entry in BCD should be updated.
Updated•2 years ago
|
Comment 19•2 years ago
|
||
(In reply to Rob Wu [:robwu] from comment #18)
Android entry in BCD should be updated.
I fixed that along with other issues in https://github.com/mdn/browser-compat-data/pull/22337
Description
•