From d8bbc7858622b6d9c278469aab701ca0b609cddf Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 15 May 2024 05:35:49 +0200 Subject: Merging upstream version 126.0. Signed-off-by: Daniel Baumann --- mobile/android/components/extensions/ext-android.js | 8 ++++---- mobile/android/components/extensions/ext-tabs.js | 8 +++++++- mobile/android/components/extensions/schemas/tabs.json | 4 ++-- .../test/xpcshell/test_ext_native_messaging_permissions.js | 4 ++-- 4 files changed, 15 insertions(+), 9 deletions(-) (limited to 'mobile/android/components/extensions') diff --git a/mobile/android/components/extensions/ext-android.js b/mobile/android/components/extensions/ext-android.js index 2576a42ba5..4524c4529b 100644 --- a/mobile/android/components/extensions/ext-android.js +++ b/mobile/android/components/extensions/ext-android.js @@ -610,15 +610,15 @@ extensions.on("page-shutdown", (type, context) => { /* eslint-enable mozilla/balanced-listeners */ global.openOptionsPage = async extension => { - const { options_ui } = extension.manifest; + const { optionsPageProperties } = extension; const extensionId = extension.id; - if (options_ui.open_in_tab) { + if (optionsPageProperties.open_in_tab) { // Delegate new tab creation and open the options page in the new tab. const tab = await GeckoViewTabBridge.createNewTab({ extensionId, createProperties: { - url: options_ui.page, + url: optionsPageProperties.page, active: true, }, }); @@ -626,7 +626,7 @@ global.openOptionsPage = async extension => { const { browser } = tab; const flags = Ci.nsIWebNavigation.LOAD_FLAGS_NONE; - browser.fixupAndLoadURIString(options_ui.page, { + browser.fixupAndLoadURIString(optionsPageProperties.page, { flags, triggeringPrincipal: extension.principal, }); diff --git a/mobile/android/components/extensions/ext-tabs.js b/mobile/android/components/extensions/ext-tabs.js index 66c7417379..c4d8010e79 100644 --- a/mobile/android/components/extensions/ext-tabs.js +++ b/mobile/android/components/extensions/ext-tabs.js @@ -541,7 +541,13 @@ this.tabs = class extends ExtensionAPIPersistent { ? windowTracker.topWindow : windowTracker.getWindow(windowId, context); - const tab = tabManager.wrapTab(window.tab); + const tab = tabManager.getWrapper(window.tab); + if ( + !extension.hasPermission("") && + !tab.hasActiveTabPermission + ) { + throw new ExtensionError("Missing activeTab permission"); + } await tabListener.awaitTabReady(tab.nativeTab); const zoom = window.browsingContext.fullZoom; diff --git a/mobile/android/components/extensions/schemas/tabs.json b/mobile/android/components/extensions/schemas/tabs.json index 2c6a8f5651..513909d5a3 100644 --- a/mobile/android/components/extensions/schemas/tabs.json +++ b/mobile/android/components/extensions/schemas/tabs.json @@ -895,8 +895,8 @@ { "name": "captureVisibleTab", "type": "function", - "description": "Captures an area of the currently active tab in the specified window. You must have $(topic:declare_permissions)[<all_urls>] permission to use this method.", - "permissions": [""], + "description": "Captures an area of the currently active tab in the specified window. You must have <all_urls> or activeTab permission to use this method.", + "permissions": ["", "activeTab"], "async": "callback", "parameters": [ { diff --git a/mobile/android/components/extensions/test/xpcshell/test_ext_native_messaging_permissions.js b/mobile/android/components/extensions/test/xpcshell/test_ext_native_messaging_permissions.js index 63f64b487e..88fdda9bf3 100644 --- a/mobile/android/components/extensions/test/xpcshell/test_ext_native_messaging_permissions.js +++ b/mobile/android/components/extensions/test/xpcshell/test_ext_native_messaging_permissions.js @@ -97,7 +97,7 @@ add_task(async function test_geckoViewAddons_missing() { const ERROR_NATIVE_MESSAGE_FROM_BACKGROUND = "Native manifests are not supported on android"; const ERROR_NATIVE_MESSAGE_FROM_CONTENT = - /^Native messaging not allowed: \{.*"envType":"content_child","url":"http:\/\/example\.com\/dummy"\}$/; + /^Native messaging not allowed: \{.*"envType":"content_child","url":"http:\/\/example\.com\/dummy"\,"origin":"http:\/\/example\.com"}$/; async function testBackground() { await browser.test.assertRejects( @@ -136,7 +136,7 @@ add_task(async function test_geckoViewAddons_missing() { // without the nativeMessagingFromContent permission. add_task(async function test_nativeMessagingFromContent_missing() { const ERROR_NATIVE_MESSAGE_FROM_CONTENT_NO_PERM = - /^Unexpected messaging sender: \{.*"envType":"content_child","url":"http:\/\/example\.com\/dummy"\}$/; + /^Unexpected messaging sender: \{.*"envType":"content_child","url":"http:\/\/example\.com\/dummy"\,"origin":"http:\/\/example\.com"}$/; function testBackground() { // sendNativeMessage / connectNative are expected to succeed, but we // are not testing that here because XpcshellTestRunnerService does not -- cgit v1.2.3