Skip to content
This repository has been archived by the owner on Sep 4, 2023. It is now read-only.

Commit

Permalink
Adding instrumentation for in-tree gecko integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
andrenatal committed Jan 15, 2022
1 parent e853575 commit afe073d
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 7 deletions.
2 changes: 1 addition & 1 deletion extension/controller/experiments/TranslationBar/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
);

const notificationBox = tab.browser.ownerGlobal.gBrowser.getNotificationBox(tab.browser);
let notif = notificationBox.appendNotification(`translation-notification-${chromeWin.now}`, {
let notif = notificationBox.appendNotification("fxtranslation-notification", {
priority: notificationBox.PRIORITY_INFO_HIGH,
notificationIs: `translation-notification-${chromeWin.now}`,
});
Expand Down
3 changes: 2 additions & 1 deletion extension/controller/translation/Translation.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ class Translation {
{
engineLocalPath,
engineRemoteRegistry,
modelRegistry
modelRegistry,
isMochitest: this.mediator.isMochitest
}
])
}
Expand Down
13 changes: 11 additions & 2 deletions extension/controller/translation/translationWorker.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
/* eslint-disable no-global-assign */
/* eslint-disable no-native-reassign */
/* eslint-disable max-lines */

/* global engineRegistryRootURL, engineRegistry, loadEmscriptenGlueCode, Queue */
/* global modelRegistryRootURL, modelRegistry,importScripts */
/* global engineRegistryRootURL, engineRegistryRootURLTest, engineRegistry, loadEmscriptenGlueCode, Queue */
/* global modelRegistryRootURL, modelRegistryRootURLTest, modelRegistry,importScripts */

/*
* this class should only be instantiated the web worker
Expand Down Expand Up @@ -550,6 +552,13 @@ onmessage = function(message) {
importScripts(message.data[1].engineLocalPath);
importScripts(message.data[1].engineRemoteRegistry);
importScripts(message.data[1].modelRegistry);
if (message.data[1].isMochitest){
// running tests. let's setup the proper tests endpoints
// eslint-disable-next-line no-global-assign
engineRegistryRootURL = engineRegistryRootURLTest;
// eslint-disable-next-line no-global-assign
modelRegistryRootURL = modelRegistryRootURLTest;
}
break;
case "translate":
translationHelper.requestTranslation(message.data[1]);
Expand Down
5 changes: 5 additions & 0 deletions extension/mediator.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ class Mediator {
browser.runtime.onMessage.addListener(this.bgScriptsMessageListener.bind(this));
this.translationBarDisplayed = false;
this.statsMode = false;
// if we are in the protected mochitest page, we flag it.
if (window.location.href ===
"https://example.com/browser/browser/extensions/translations/test/browser/browser_translation_test.html") {
this.isMochitest = true;
}
}

init() {
Expand Down
3 changes: 2 additions & 1 deletion extension/model/engineRegistry.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-disable no-unused-vars */

const engineRegistryRootURL = "https://github.com/mozilla/bergamot-translator/releases/download/0.3.1%2B793d132/";
let engineRegistryRootURL = "https://github.com/mozilla/bergamot-translator/releases/download/0.3.1%2B793d132/";
const engineRegistryRootURLTest = "https://example.com/browser/browser/extensions/translations/test/browser/";

const engineRegistry = {
bergamotTranslatorWasm: {
Expand Down
3 changes: 2 additions & 1 deletion extension/model/modelRegistry.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/* eslint-disable no-unused-vars */
/* eslint-disable max-lines */

const modelRegistryRootURL = "https://storage.googleapis.com/bergamot-models-sandbox/0.2.10";
let modelRegistryRootURL = "https://storage.googleapis.com/bergamot-models-sandbox/0.2.10";
const modelRegistryRootURLTest = "https://example.com/browser/browser/extensions/translations/test/browser";

const modelRegistry = {
enit: {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"build": "web-ext build -s extension --overwrite-dest --no-config-discovery -n firefox_translations.xpi",
"format": "prettier 'extension/*.{js,css}' --tab-width=2 --arrow-parens=always --trailing-comma=es5 --no-bracket-spacing --write",
"lint:extension": "web-ext lint -s extension",
"once": "web-ext run -s extension --verbose --firefox nightly --no-config-discovery --pref=extensions.experiments.enabled=true --pref=extensions.translations.disabled=true --pref=javascript.options.wasm_simd_wormhole=true",
"once": "web-ext run -s extension --verbose --firefox nightly --no-config-discovery --pref=extensions.experiments.enabled=true --pref=extensions.translations.disabled=false --pref=javascript.options.wasm_simd_wormhole=true",
"package": "npm run build && mv web-ext-artifacts/*.zip addon.xpi",
"setup-webext": "npm install -g web-ext"
},
Expand Down

0 comments on commit afe073d

Please sign in to comment.