Closed Bug 1817779 Opened 3 years ago Closed 2 years ago

Implement `tabs.detectLanguage` for Android

Categories

(GeckoView :: Extensions, enhancement, P3)

All
Android
enhancement

Tracking

(firefox117 wontfix, firefox118 fixed)

RESOLVED FIXED
118 Branch
Tracking Status
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)

This has already been implemented in bug 1764698.

Status: NEW → RESOLVED
Closed: 3 years ago
Duplicate of bug: 1764698
Resolution: --- → DUPLICATE
Whiteboard: [addons-jira]

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:

Status: RESOLVED → REOPENED
No longer duplicate of bug: 1764698
Resolution: DUPLICATE → ---
Whiteboard: [addons-jira]
Depends on: 1764698
Whiteboard: [addons-jira]
Whiteboard: [addons-jira]

This is a good first bug for those who want to familiarize themselves with contributing to extensions code in Android. Comment 2 offers pointers.

Mentor: rob
Keywords: good-first-bug

Hi, I would like to take on this bug! Is there other information that I should know?

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!

Flags: needinfo?(rob)

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

Flags: needinfo?(rob)

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!

(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: nobody → hliu728

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!

(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

Pushed by rob@robwu.nl: https://hg.mozilla.org/integration/autoland/rev/c8c9ef33bbcf Implemented tabs.detectLanguage for Android, r=robwu,geckoview-reviewers,extension-reviewers,owlish

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
Flags: needinfo?(hliu728)

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

Pushed by archaeopteryx@coole-files.de: https://hg.mozilla.org/integration/autoland/rev/3cb2ac7b7567 Implemented tabs.detectLanguage for Android, r=robwu,geckoview-reviewers,extension-reviewers,owlish,amejiamarmol
Status: REOPENED → RESOLVED
Closed: 3 years ago2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 118 Branch

Android entry in BCD should be updated.

Flags: needinfo?(hliu728)
Keywords: dev-doc-needed

(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

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: