Skip to content

Commit

Permalink
Bug 1764698 - Move LanguageDetector.jsm and related files to toolkit.…
Browse files Browse the repository at this point in the history
… r=robwu

Differential Revision: https://phabricator.services.mozilla.com/D151606
  • Loading branch information
John Bieling committed Aug 23, 2022
1 parent 3ed8496 commit 24210e2
Show file tree
Hide file tree
Showing 75 changed files with 34 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .clang-format-ignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ toolkit/components/uniffi-js/UniFFIFixtureScaffolding.cpp

# Generated from ./tools/rewriting/ThirdPartyPaths.txt
# awk '{print ""$1".*"}' ./tools/rewriting/ThirdPartyPaths.txt
browser/components/translation/cld2/.*
browser/extensions/mortar/ppapi/.*
devtools/client/shared/sourceeditor/codemirror/.*
dom/canvas/test/webgl-conf/checkout/closure-library/.*
Expand Down Expand Up @@ -200,6 +199,7 @@ testing/web-platform/tests/tools/third_party/.*
third_party/.*
toolkit/components/jsoncpp/.*
toolkit/components/protobuf/.*
toolkit/components/translation/cld2/.*
toolkit/components/url-classifier/chromium/.*
toolkit/components/url-classifier/protobuf/.*
toolkit/crashreporter/breakpad-client/.*
Expand Down
5 changes: 3 additions & 2 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ browser/components/sessionstore/test/unit/data/sessionstore_invalid.js
# for documentation purposes (policies.json) but to be accessed by the
# code as a .jsm (schema.jsm)
browser/components/enterprisepolicies/schemas/schema.jsm
# generated & special files in cld2
browser/components/translation/cld2/
# generated or library files in pocket
browser/components/pocket/content/panels/js/tmpl.js
browser/components/pocket/content/panels/js/vendor.bundle.js
Expand Down Expand Up @@ -213,6 +211,9 @@ toolkit/components/reader/JSDOMParser.js
# Uses preprocessing
toolkit/components/reader/Readerable.jsm

# Generated & special files in cld2
toolkit/components/translation/cld2/

# Uses preprocessing
toolkit/mozapps/update/tests/data/xpcshellConstantsPP.js
toolkit/modules/AppConstants.jsm
Expand Down
2 changes: 1 addition & 1 deletion browser/components/translation/TranslationChild.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const lazy = {};
ChromeUtils.defineModuleGetter(
lazy,
"LanguageDetector",
"resource:///modules/translation/LanguageDetector.jsm"
"resource://gre/modules/translation/LanguageDetector.jsm"
);

const STATE_OFFER = 0;
Expand Down
5 changes: 0 additions & 5 deletions browser/components/translation/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,11 @@ with Files("**"):

EXTRA_JS_MODULES.translation = [
"BingTranslator.jsm",
"cld2/cld-worker.js",
"cld2/cld-worker.js.mem",
"GoogleTranslator.jsm",
"LanguageDetector.jsm",
"TranslationChild.jsm",
"TranslationDocument.jsm",
"TranslationParent.jsm",
"YandexTranslator.jsm",
]

BROWSER_CHROME_MANIFESTS += ["test/browser.ini"]

XPCSHELL_TESTS_MANIFESTS += ["test/unit/xpcshell.ini"]
5 changes: 0 additions & 5 deletions browser/installer/allowed-dupes.mn
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,3 @@ browser/chrome/browser/skin/classic/browser/customize.svg
# Bug 1718144 - De-duplicate lightbulb icon
browser/features/[email protected]/icons/lightbulb.svg
chrome/toolkit/skin/classic/global/icons/lightbulb.svg

# Bug 1710546 - Bundle Firefox extension as a builtin addon Nighly only
# We plan to remove this duplicity after Firefox Translations become pref'd on
browser/chrome/browser/builtin-addons/translations/wasm/cld-worker.js.mem
browser/modules/translation/cld-worker.js.mem
2 changes: 1 addition & 1 deletion dom/security/nsContentSecurityUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ bool nsContentSecurityUtils::IsEvalAllowed(JSContext* cx,
"resource://testing-common/content-task.js"_ns,

// Tracked by Bug 1584605
"resource:///modules/translation/cld-worker.js"_ns,
"resource://gre/modules/translation/cld-worker.js"_ns,

// require.js implements a script loader for workers. It uses eval
// to load the script; but injection is only possible in situations
Expand Down
2 changes: 1 addition & 1 deletion toolkit/components/extensions/ExtensionContent.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const lazy = {};
XPCOMUtils.defineLazyModuleGetters(lazy, {
ExtensionProcessScript: "resource://gre/modules/ExtensionProcessScript.jsm",
ExtensionTelemetry: "resource://gre/modules/ExtensionTelemetry.jsm",
LanguageDetector: "resource:///modules/translation/LanguageDetector.jsm",
LanguageDetector: "resource://gre/modules/translation/LanguageDetector.jsm",
Schemas: "resource://gre/modules/Schemas.jsm",
WebNavigationFrames: "resource://gre/modules/WebNavigationFrames.jsm",
});
Expand Down
2 changes: 1 addition & 1 deletion toolkit/components/extensions/parent/ext-i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
ChromeUtils.defineModuleGetter(
this,
"LanguageDetector",
"resource:///modules/translation/LanguageDetector.jsm"
"resource://gre/modules/translation/LanguageDetector.jsm"
);

this.i18n = class extends ExtensionAPI {
Expand Down
10 changes: 4 additions & 6 deletions toolkit/components/extensions/test/xpcshell/test_ext_i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,10 @@ add_task(async function test_get_accept_languages() {
await extension.startup();
await extension.awaitMessage("content-loaded");

let expectedLangs = ["en-US", "en"];
// TODO bug 1765375: ", en" is missing on Android.
// TODO bug 1785807: "en-us" should be "en-US" on Android
let expectedLangs =
AppConstants.platform == "android" ? ["en-us"] : ["en-US", "en"];
extension.sendMessage(["expect-results", expectedLangs]);
await extension.awaitMessage("background-done");
await extension.awaitMessage("content-done");
Expand Down Expand Up @@ -452,11 +455,6 @@ add_task(async function test_get_ui_language() {
});

add_task(async function test_detect_language() {
if (AppConstants.MOZ_BUILD_APP !== "browser") {
// This is not supported on Android.
return;
}

const af_string =
" aam skukuza die naam beteken hy wat skoonvee of hy wat alles onderstebo keer wysig " +
"bosveldkampe boskampe is kleiner afgeleë ruskampe wat oor min fasiliteite beskik daar is geen restaurante " +
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[test_ext_i18n.js]
skip-if = os == "android" || (os == "win" && debug) || (os == "linux")
skip-if = (os == "win" && debug) || (os == "linux")
[test_ext_i18n_css.js]
skip-if =
os == "mac" && debug && fission # Bug 1762638
Expand Down
1 change: 1 addition & 0 deletions toolkit/components/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ DIRS += [
"startup",
"statusfilter",
"telemetry",
"translation",
"thumbnails",
"timermanager",
"tooltiptext",
Expand Down
2 changes: 1 addition & 1 deletion toolkit/components/reader/ReaderMode.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ ChromeUtils.defineModuleGetter(
ChromeUtils.defineModuleGetter(
lazy,
"LanguageDetector",
"resource:///modules/translation/LanguageDetector.jsm"
"resource://gre/modules/translation/LanguageDetector.jsm"
);
ChromeUtils.defineModuleGetter(
lazy,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const { clearTimeout, setTimeout } = ChromeUtils.import(
"resource://gre/modules/Timer.jsm"
);

const WORKER_URL = "resource:///modules/translation/cld-worker.js";
const WORKER_URL = "resource://gre/modules/translation/cld-worker.js";

var workerManager = {
// Since Emscripten can handle heap growth, but not heap shrinkage, we
Expand Down
File renamed without changes.
File renamed without changes.
14 changes: 14 additions & 0 deletions toolkit/components/translation/moz.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

with Files("**"):
BUG_COMPONENT = ("Firefox", "Translation")

EXTRA_JS_MODULES.translation = [
"cld2/cld-worker.js",
"cld2/cld-worker.js.mem",
"LanguageDetector.jsm",
]

XPCSHELL_TESTS_MANIFESTS += ["test/unit/xpcshell.ini"]
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ const kTestPairs = [

const { setTimeout } = ChromeUtils.import("resource://gre/modules/Timer.jsm");
let { LanguageDetector, workerManager } = ChromeUtils.import(
"resource:///modules/translation/LanguageDetector.jsm"
"resource://gre/modules/translation/LanguageDetector.jsm"
);

function check_result(result, langCode, expected) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[DEFAULT]
head =
firefox-appdir = browser
skip-if = toolkit == 'android' # bug 1730213

[test_cld2.js]
4 changes: 2 additions & 2 deletions tools/esmify/map.json
Original file line number Diff line number Diff line change
Expand Up @@ -792,8 +792,6 @@
"browser/components/syncedtabs/util.js",
"resource:///modules/translation/BingTranslator.jsm":
"browser/components/translation/BingTranslator.jsm",
"resource:///modules/translation/LanguageDetector.jsm":
"browser/components/translation/LanguageDetector.jsm",
"resource:///modules/translation/TranslationChild.jsm":
"browser/components/translation/TranslationChild.jsm",
"resource:///modules/translation/TranslationDocument.jsm":
Expand Down Expand Up @@ -1944,6 +1942,8 @@
"toolkit/modules/third_party/fathom/fathom.jsm",
"resource://gre/modules/third_party/jsesc/jsesc.js":
"toolkit/modules/third_party/jsesc/jsesc.js",
"resource://gre/modules/translation/LanguageDetector.jsm":
"toolkit/components/translation/LanguageDetector.jsm",
"resource://gre/modules/txEXSLTRegExFunctions.jsm":
"dom/xslt/xslt/txEXSLTRegExFunctions.jsm",
"resource://gre/modules/vtt.jsm": "dom/media/webvtt/vtt.jsm",
Expand Down
2 changes: 1 addition & 1 deletion tools/rewriting/ThirdPartyPaths.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
browser/components/newtab/vendor/
browser/components/pocket/content/panels/js/vendor/
browser/components/storybook/node_modules/
browser/components/translation/cld2/
browser/extensions/formautofill/content/third-party/
browser/extensions/formautofill/test/fixtures/third_party/
browser/extensions/screenshots/build/raven.js
Expand Down Expand Up @@ -171,6 +170,7 @@ toolkit/components/jsoncpp/
toolkit/components/normandy/vendor/
toolkit/components/passwordmgr/PasswordRulesParser.jsm
toolkit/components/protobuf/
toolkit/components/translation/cld2/
toolkit/components/url-classifier/chromium/
toolkit/components/utils/mozjexl.js
toolkit/components/viaduct/fetch_msg_types.pb.cc
Expand Down

0 comments on commit 24210e2

Please sign in to comment.