diff options
Diffstat (limited to 'mobile/android/modules/geckoview')
20 files changed, 75 insertions, 50 deletions
diff --git a/mobile/android/modules/geckoview/ChildCrashHandler.sys.mjs b/mobile/android/modules/geckoview/ChildCrashHandler.sys.mjs index 52a929511a..5c6418091a 100644 --- a/mobile/android/modules/geckoview/ChildCrashHandler.sys.mjs +++ b/mobile/android/modules/geckoview/ChildCrashHandler.sys.mjs @@ -30,7 +30,7 @@ export var ChildCrashHandler = { // Map a child ID to a remote type. childMap: new Map(), - // The event listener for this is hooked up in GeckoViewStartup.jsm + // The event listener for this is hooked up in GeckoViewStartup.sys.mjs observe(aSubject, aTopic, aData) { const childID = aData; diff --git a/mobile/android/modules/geckoview/GeckoViewContent.sys.mjs b/mobile/android/modules/geckoview/GeckoViewContent.sys.mjs index b593a6f8e4..240aea0cbe 100644 --- a/mobile/android/modules/geckoview/GeckoViewContent.sys.mjs +++ b/mobile/android/modules/geckoview/GeckoViewContent.sys.mjs @@ -345,7 +345,7 @@ export class GeckoViewContent extends GeckoViewModule { } // nsIObserver event handler - observe(aSubject, aTopic, aData) { + observe(aSubject, aTopic) { debug`observe: ${aTopic}`; this._contentCrashed = false; const browser = aSubject.ownerElement; diff --git a/mobile/android/modules/geckoview/GeckoViewMediaControl.sys.mjs b/mobile/android/modules/geckoview/GeckoViewMediaControl.sys.mjs index 1b39125fce..ebe529e313 100644 --- a/mobile/android/modules/geckoview/GeckoViewMediaControl.sys.mjs +++ b/mobile/android/modules/geckoview/GeckoViewMediaControl.sys.mjs @@ -67,7 +67,7 @@ export class GeckoViewMediaControl extends GeckoViewModule { return this.browser.browsingContext.mediaController; } - onEvent(aEvent, aData, aCallback) { + onEvent(aEvent, aData) { debug`onEvent: event=${aEvent}, data=${aData}`; switch (aEvent) { diff --git a/mobile/android/modules/geckoview/GeckoViewModule.sys.mjs b/mobile/android/modules/geckoview/GeckoViewModule.sys.mjs index 87ad35d817..b05244612a 100644 --- a/mobile/android/modules/geckoview/GeckoViewModule.sys.mjs +++ b/mobile/android/modules/geckoview/GeckoViewModule.sys.mjs @@ -132,7 +132,7 @@ class EventProxy { } } - onEvent(aEvent, aData, aCallback) { + onEvent(aEvent, aData) { if (this._enableQueuing) { debug`queue ${aEvent}, data=${aData}`; this._eventQueue.unshift(arguments); @@ -146,7 +146,7 @@ class EventProxy { this._enableQueuing = aEnable; } - _dispatch(aEvent, aData, aCallback) { + _dispatch(aEvent, aData) { debug`dispatch ${aEvent}, data=${aData}`; if (this.listener.onEvent) { this.listener.onEvent(...arguments); diff --git a/mobile/android/modules/geckoview/GeckoViewNavigation.sys.mjs b/mobile/android/modules/geckoview/GeckoViewNavigation.sys.mjs index 287a605dff..bc098f0413 100644 --- a/mobile/android/modules/geckoview/GeckoViewNavigation.sys.mjs +++ b/mobile/android/modules/geckoview/GeckoViewNavigation.sys.mjs @@ -155,7 +155,7 @@ export class GeckoViewNavigation extends GeckoViewModule { } // Bundle event handler. - async onEvent(aEvent, aData, aCallback) { + async onEvent(aEvent, aData) { debug`onEvent: event=${aEvent}, data=${aData}`; switch (aEvent) { @@ -291,7 +291,7 @@ export class GeckoViewNavigation extends GeckoViewModule { return new Promise(resolve => { const handler = { - observe(aSubject, aTopic, aData) { + observe(aSubject, aTopic) { if ( aTopic === "geckoview-window-created" && aSubject.name === aSessionId @@ -371,7 +371,7 @@ export class GeckoViewNavigation extends GeckoViewModule { // Wait indefinitely for app to respond with a browser or null Services.tm.spinEventLoopUntil( - "GeckoViewNavigation.jsm:handleNewSession", + "GeckoViewNavigation.sys.mjs:handleNewSession", () => this.window.closed || browser !== undefined ); return browser || null; @@ -383,8 +383,7 @@ export class GeckoViewNavigation extends GeckoViewModule { aOpenWindowInfo, aWhere, aFlags, - aTriggeringPrincipal, - aCsp + aTriggeringPrincipal ) { debug`createContentWindow: uri=${aUri && aUri.spec} where=${aWhere} flags=${aFlags}`; @@ -585,7 +584,7 @@ export class GeckoViewNavigation extends GeckoViewModule { } // WebProgress event handler. - onLocationChange(aWebProgress, aRequest, aLocationURI, aFlags) { + onLocationChange(aWebProgress, aRequest, aLocationURI) { debug`onLocationChange`; let fixedURI = aLocationURI; @@ -648,6 +647,8 @@ export class GeckoViewNavigation extends GeckoViewModule { canGoForward: this.browser.canGoForward, isTopLevel: aWebProgress.isTopLevel, permissions, + hasUserGesture: + this.window.document.hasValidTransientUserGestureActivation, }; lazy.TranslationsParent.onLocationChange(this.browser); this.eventDispatcher.sendRequest(message); diff --git a/mobile/android/modules/geckoview/GeckoViewProcessHangMonitor.sys.mjs b/mobile/android/modules/geckoview/GeckoViewProcessHangMonitor.sys.mjs index 7f6f14a29e..387fda4421 100644 --- a/mobile/android/modules/geckoview/GeckoViewProcessHangMonitor.sys.mjs +++ b/mobile/android/modules/geckoview/GeckoViewProcessHangMonitor.sys.mjs @@ -65,7 +65,7 @@ export class GeckoViewProcessHangMonitor extends GeckoViewModule { } // Bundle event handler. - onEvent(aEvent, aData, aCallback) { + onEvent(aEvent, aData) { debug`onEvent: event=${aEvent}, data=${aData}`; if (this._reportIndex.has(aData.hangId)) { @@ -84,7 +84,7 @@ export class GeckoViewProcessHangMonitor extends GeckoViewModule { } // nsIObserver event handler - observe(aSubject, aTopic, aData) { + observe(aSubject, aTopic) { debug`observe(aTopic=${aTopic})`; aSubject.QueryInterface(Ci.nsIHangReport); if (!aSubject.isReportForBrowserOrChildren(this.browser.frameLoader)) { diff --git a/mobile/android/modules/geckoview/GeckoViewProgress.sys.mjs b/mobile/android/modules/geckoview/GeckoViewProgress.sys.mjs index 66aceb974c..3cad6e977a 100644 --- a/mobile/android/modules/geckoview/GeckoViewProgress.sys.mjs +++ b/mobile/android/modules/geckoview/GeckoViewProgress.sys.mjs @@ -557,7 +557,7 @@ export class GeckoViewProgress extends GeckoViewModule { } } - onEvent(aEvent, aData, aCallback) { + onEvent(aEvent, aData) { debug`onEvent: event=${aEvent}, data=${aData}`; switch (aEvent) { @@ -608,6 +608,7 @@ export class GeckoViewProgress extends GeckoViewModule { canGoBack: false, canGoForward: false, isTopLevel: true, + hasUserGesture: false, }); this.eventDispatcher.sendRequest({ type: "GeckoView:PageStop", @@ -616,7 +617,7 @@ export class GeckoViewProgress extends GeckoViewModule { } // nsIObserver event handler - observe(aSubject, aTopic, aData) { + observe(aSubject, aTopic) { debug`observe: topic=${aTopic}`; switch (aTopic) { diff --git a/mobile/android/modules/geckoview/GeckoViewPushController.sys.mjs b/mobile/android/modules/geckoview/GeckoViewPushController.sys.mjs index da2d7d04e9..07ad8cd514 100644 --- a/mobile/android/modules/geckoview/GeckoViewPushController.sys.mjs +++ b/mobile/android/modules/geckoview/GeckoViewPushController.sys.mjs @@ -27,7 +27,7 @@ function createScopeAndPrincipal(scopeAndAttrs) { } export const GeckoViewPushController = { - onEvent(aEvent, aData, aCallback) { + onEvent(aEvent, aData) { debug`onEvent ${aEvent} ${aData}`; switch (aEvent) { diff --git a/mobile/android/modules/geckoview/GeckoViewSelectionAction.sys.mjs b/mobile/android/modules/geckoview/GeckoViewSelectionAction.sys.mjs index 07498e4b00..cc3b153716 100644 --- a/mobile/android/modules/geckoview/GeckoViewSelectionAction.sys.mjs +++ b/mobile/android/modules/geckoview/GeckoViewSelectionAction.sys.mjs @@ -20,7 +20,7 @@ export class GeckoViewSelectionAction extends GeckoViewModule { } // Bundle event handler. - onEvent(aEvent, aData, aCallback) { + onEvent(aEvent, aData) { debug`onEvent: ${aEvent}`; switch (aEvent) { diff --git a/mobile/android/modules/geckoview/GeckoViewSessionStore.sys.mjs b/mobile/android/modules/geckoview/GeckoViewSessionStore.sys.mjs index 584429295e..faa5c5f280 100644 --- a/mobile/android/modules/geckoview/GeckoViewSessionStore.sys.mjs +++ b/mobile/android/modules/geckoview/GeckoViewSessionStore.sys.mjs @@ -112,7 +112,7 @@ export var GeckoViewSessionStore = { // For each <browser> element, records the SHistoryListener. _browserSHistoryListener: new WeakMap(), - observe(aSubject, aTopic, aData) { + observe(aSubject, aTopic) { debug`observe ${aTopic}`; switch (aTopic) { diff --git a/mobile/android/modules/geckoview/GeckoViewStorageController.sys.mjs b/mobile/android/modules/geckoview/GeckoViewStorageController.sys.mjs index e69ad3b973..0f4e692ba9 100644 --- a/mobile/android/modules/geckoview/GeckoViewStorageController.sys.mjs +++ b/mobile/android/modules/geckoview/GeckoViewStorageController.sys.mjs @@ -308,7 +308,7 @@ export const GeckoViewStorageController = { new Promise(resolve => { Services.clearData.deleteData(flags, resolve); - }).then(resultFlags => { + }).then(() => { aCallback.onSuccess(); }); }, @@ -321,7 +321,7 @@ export const GeckoViewStorageController = { convertFlags(aFlags), resolve ); - }).then(resultFlags => { + }).then(() => { aCallback.onSuccess(); }); }, @@ -334,7 +334,7 @@ export const GeckoViewStorageController = { convertFlags(aFlags), resolve ); - }).then(resultFlags => { + }).then(() => { aCallback.onSuccess(); }); }, diff --git a/mobile/android/modules/geckoview/GeckoViewTab.sys.mjs b/mobile/android/modules/geckoview/GeckoViewTab.sys.mjs index 53f43f153c..fe984934ec 100644 --- a/mobile/android/modules/geckoview/GeckoViewTab.sys.mjs +++ b/mobile/android/modules/geckoview/GeckoViewTab.sys.mjs @@ -116,7 +116,7 @@ export const GeckoViewTabBridge = { // need to start waiting before we send the message. const windowPromise = new Promise(resolve => { const handler = { - observe(aSubject, aTopic, aData) { + observe(aSubject, aTopic) { if ( aTopic === "geckoview-window-created" && aSubject.name === newSessionId @@ -203,7 +203,7 @@ export class GeckoViewTab extends GeckoViewModule { this.registerListener(["GeckoView:WebExtension:SetTabActive"]); } - onEvent(aEvent, aData, aCallback) { + onEvent(aEvent, aData) { debug`onEvent: event=${aEvent}, data=${aData}`; switch (aEvent) { diff --git a/mobile/android/modules/geckoview/GeckoViewTelemetry.sys.mjs b/mobile/android/modules/geckoview/GeckoViewTelemetry.sys.mjs index bb7074ced8..c5738e672c 100644 --- a/mobile/android/modules/geckoview/GeckoViewTelemetry.sys.mjs +++ b/mobile/android/modules/geckoview/GeckoViewTelemetry.sys.mjs @@ -33,12 +33,16 @@ export class GleanStopwatch { } finish() { - this._metric.stopAndAccumulate(this._timerId); - this._timerId = null; + if (this.isRunning()) { + this._metric.stopAndAccumulate(this._timerId); + this._timerId = null; + } } cancel() { - this._metric.cancel(this._timerId); - this._timerId = null; + if (this.isRunning()) { + this._metric.cancel(this._timerId); + this._timerId = null; + } } } diff --git a/mobile/android/modules/geckoview/GeckoViewTestUtils.sys.mjs b/mobile/android/modules/geckoview/GeckoViewTestUtils.sys.mjs index 6c5113cdc2..a2ca252cdd 100644 --- a/mobile/android/modules/geckoview/GeckoViewTestUtils.sys.mjs +++ b/mobile/android/modules/geckoview/GeckoViewTestUtils.sys.mjs @@ -20,7 +20,7 @@ export const GeckoViewTabUtil = { async createNewTab(url = "about:blank") { let sessionId = ""; const windowPromise = new Promise(resolve => { - const openingObserver = (subject, topic, data) => { + const openingObserver = subject => { if (subject.name === sessionId) { Services.obs.removeObserver( openingObserver, diff --git a/mobile/android/modules/geckoview/GeckoViewTranslations.sys.mjs b/mobile/android/modules/geckoview/GeckoViewTranslations.sys.mjs index 3db694a64a..7e74e7bf30 100644 --- a/mobile/android/modules/geckoview/GeckoViewTranslations.sys.mjs +++ b/mobile/android/modules/geckoview/GeckoViewTranslations.sys.mjs @@ -182,7 +182,7 @@ export const GeckoViewTranslationsSettings = { if (operation === "delete") { if (operationLevel === "all") { lazy.TranslationsParent.deleteAllLanguageFiles().then( - function (value) { + function () { aCallback.onSuccess(); }, function (error) { @@ -201,7 +201,7 @@ export const GeckoViewTranslationsSettings = { return; } lazy.TranslationsParent.deleteLanguageFiles(language).then( - function (value) { + function () { aCallback.onSuccess(); }, function (error) { @@ -216,7 +216,7 @@ export const GeckoViewTranslationsSettings = { if (operation === "download") { if (operationLevel === "all") { lazy.TranslationsParent.downloadAllFiles().then( - function (value) { + function () { aCallback.onSuccess(); }, function (error) { @@ -235,7 +235,7 @@ export const GeckoViewTranslationsSettings = { return; } lazy.TranslationsParent.downloadLanguageFiles(language).then( - function (value) { + function () { aCallback.onSuccess(); }, function (error) { diff --git a/mobile/android/modules/geckoview/GeckoViewUtils.sys.mjs b/mobile/android/modules/geckoview/GeckoViewUtils.sys.mjs index ddfb40c1a1..3fe8309b6b 100644 --- a/mobile/android/modules/geckoview/GeckoViewUtils.sys.mjs +++ b/mobile/android/modules/geckoview/GeckoViewUtils.sys.mjs @@ -25,7 +25,7 @@ class AndroidFormatter extends Log.BasicFormatter { /* * AndroidAppender - * Logs to Android logcat using AndroidLog.jsm + * Logs to Android logcat using AndroidLog.sys.mjs */ class AndroidAppender extends Log.Appender { constructor(aFormatter) { @@ -49,7 +49,7 @@ class AndroidAppender extends Log.Appender { return; } - // AndroidLog.jsm always prepends "Gecko" to the tag, so we strip any + // AndroidLog.sys.mjs always prepends "Gecko" to the tag, so we strip any // leading "Gecko" here. Also strip dots to save space. const tag = aMessage.loggerName.replace(/^Gecko|\./g, ""); const msg = this._formatter.format(aMessage); @@ -257,9 +257,7 @@ export var GeckoViewUtils = { (handlers, observer, args) => { if (!once) { Services.prefs.removeObserver(args[2], observer); - handlers.forEach(handler => - Services.prefs.addObserver(args[2], observer) - ); + handlers.forEach(() => Services.prefs.addObserver(args[2], observer)); } handlers.forEach(handler => handler.observe(...args)); } @@ -386,7 +384,7 @@ export var GeckoViewUtils = { * do_something(bar); // No log. * do_something(debug.foo = bar); // Output "foo = 42" to the log. * - * @param aTag Name of the Log.jsm logger to forward logs to. + * @param aTag Name of the Log.sys.mjs logger to forward logs to. * @param aScope Scope to add the logging functions to. */ initLogging(aTag, aScope) { diff --git a/mobile/android/modules/geckoview/GeckoViewWebExtension.sys.mjs b/mobile/android/modules/geckoview/GeckoViewWebExtension.sys.mjs index ae821a3656..97538fd6bb 100644 --- a/mobile/android/modules/geckoview/GeckoViewWebExtension.sys.mjs +++ b/mobile/android/modules/geckoview/GeckoViewWebExtension.sys.mjs @@ -158,7 +158,7 @@ class EmbedderPort { data: holder.deserialize({}), }); } - onEvent(aEvent, aData, aCallback) { + onEvent(aEvent, aData) { debug`onEvent ${aEvent} ${aData}`; switch (aEvent) { @@ -360,6 +360,23 @@ async function exportExtension(aAddon, aPermissions, aSourceURI) { updateDate = null; } + const normalizePermissions = perms => { + if (perms?.permissions) { + perms = { ...perms }; + perms.permissions = perms.permissions.filter( + perm => !perm.startsWith("internal:") + ); + } + return perms; + }; + + const optionalPermissions = aAddon.optionalPermissions?.permissions ?? []; + const optionalOrigins = aAddon.optionalPermissions?.origins ?? []; + const grantedPermissions = + normalizePermissions(await lazy.ExtensionPermissions.get(id)) ?? []; + const grantedOptionalPermissions = grantedPermissions?.permissions ?? []; + const grantedOptionalOrigins = grantedPermissions?.origins ?? []; + return { webExtensionId: id, locationURI: aSourceURI != null ? aSourceURI.spec : "", @@ -393,6 +410,10 @@ async function exportExtension(aAddon, aPermissions, aSourceURI) { temporary: temporarilyInstalled, updateDate, version, + optionalPermissions, + optionalOrigins, + grantedOptionalPermissions, + grantedOptionalOrigins, }, }; } @@ -528,7 +549,7 @@ class ExtensionPromptObserver { resolve(response.allow); } - observe(aSubject, aTopic, aData) { + observe(aSubject, aTopic) { debug`observe ${aTopic}`; switch (aTopic) { @@ -572,7 +593,7 @@ class AddonInstallObserver { }); } - observe(aSubject, aTopic, aData) { + observe(aSubject, aTopic) { debug`observe ${aTopic}`; switch (aTopic) { case "addon-install-failed": { @@ -758,7 +779,7 @@ class ExtensionProcessListener { ]); } - async onEvent(aEvent, aData, aCallback) { + async onEvent(aEvent, aData) { debug`onEvent ${aEvent} ${aData}`; switch (aEvent) { @@ -872,7 +893,7 @@ async function updatePromptHandler(aInfo) { } export var GeckoViewWebExtension = { - observe(aSubject, aTopic, aData) { + observe(aSubject, aTopic) { debug`observe ${aTopic}`; switch (aTopic) { diff --git a/mobile/android/modules/geckoview/LoadURIDelegate.sys.mjs b/mobile/android/modules/geckoview/LoadURIDelegate.sys.mjs index 5769fcafe8..fa65b8a2e2 100644 --- a/mobile/android/modules/geckoview/LoadURIDelegate.sys.mjs +++ b/mobile/android/modules/geckoview/LoadURIDelegate.sys.mjs @@ -40,7 +40,7 @@ export const LoadURIDelegate = { } ); Services.tm.spinEventLoopUntil( - "LoadURIDelegate.jsm:load", + "LoadURIDelegate.sys.mjs:load", () => aWindow.closed || handled !== undefined ); @@ -75,13 +75,13 @@ export const LoadURIDelegate = { Components.returnCode = Cr.NS_ERROR_ABORT; } }, - e => { + () => { errorPageURI = null; Components.returnCode = Cr.NS_ERROR_ABORT; } ); Services.tm.spinEventLoopUntil( - "LoadURIDelegate.jsm:handleLoadError", + "LoadURIDelegate.sys.mjs:handleLoadError", () => aWindow.closed || errorPageURI !== undefined ); diff --git a/mobile/android/modules/geckoview/Messaging.sys.mjs b/mobile/android/modules/geckoview/Messaging.sys.mjs index e67161fede..fff0b4311c 100644 --- a/mobile/android/modules/geckoview/Messaging.sys.mjs +++ b/mobile/android/modules/geckoview/Messaging.sys.mjs @@ -11,10 +11,10 @@ class ChildActorDispatcher { } // TODO: Bug 1658980 - registerListener(aListener, aEvents) { + registerListener() { throw new Error("Cannot registerListener in child actor"); } - unregisterListener(aListener, aEvents) { + unregisterListener() { throw new Error("Cannot registerListener in child actor"); } diff --git a/mobile/android/modules/geckoview/test/xpcshell/test_ChildCrashHandler.js b/mobile/android/modules/geckoview/test/xpcshell/test_ChildCrashHandler.js index 0e07937ed3..ee03e2ba4a 100644 --- a/mobile/android/modules/geckoview/test/xpcshell/test_ChildCrashHandler.js +++ b/mobile/android/modules/geckoview/test/xpcshell/test_ChildCrashHandler.js @@ -41,7 +41,7 @@ add_task(async function test_remoteType() { let listener; const crashReportPromise = new Promise(resolve => { listener = { - onEvent(aEvent, aData, aCallback) { + onEvent(aEvent, aData) { resolve([aEvent, aData]); }, }; @@ -79,7 +79,7 @@ add_task(async function test_extensions_process_crash() { let listener; const crashReportPromise = new Promise(resolve => { listener = { - onEvent(aEvent, aData, aCallback) { + onEvent(aEvent, aData) { resolve([aEvent, aData]); }, }; |