Bug 1768839 - Use browser action API for MV3 `action` on Android. r=robwu,agi

I chose to write a minimal test case and defer more test coverage to Bug
1723763 since this bug already existed. The change in `ext-android.json`
is similar to what has been done in D113461.

Differential Revision: https://phabricator.services.mozilla.com/D146061
This commit is contained in:
William Durand 2022-05-11 17:48:43 +00:00
Родитель 1ba7e83a72
Коммит 1056593aa9
4 изменённых файлов: 58 добавлений и 3 удалений

Просмотреть файл

@ -3,8 +3,11 @@
"url": "chrome://geckoview/content/ext-browserAction.js",
"schema": "chrome://extensions/content/schemas/browser_action.json",
"scopes": ["addon_parent"],
"manifest": ["browser_action"],
"paths": [["browserAction"]]
"manifest": ["browser_action", "action"],
"paths": [
["browserAction"],
["action"]
]
},
"browsingData": {
"url": "chrome://extensions/content/parent/ext-browsingData.js",

Просмотреть файл

@ -143,7 +143,7 @@ this.browserAction = class extends ExtensionAPIPersistent {
onClicked: new EventManager({
context,
// module name is "browserAction" because it the name used in the
// ext-browser.json, indipendently from the manifest version.
// ext-browser.json, independently from the manifest version.
module: "browserAction",
event: "onClicked",
// NOTE: Firefox Desktop event has inputHandling set to true here.

Просмотреть файл

@ -75,6 +75,7 @@ prefs =
browser.chrome.guess_favicon=true
[test_check_startupcache.html]
[test_ext_action.html]
[test_ext_activityLog.html]
skip-if =
os == 'android'

Просмотреть файл

@ -0,0 +1,51 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Action with MV3</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/ExtensionTestUtils.js"></script>
<script type="text/javascript" src="head.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css">
</head>
<body>
<script type="text/javascript">
"use strict";
add_task(async function setup() {
await SpecialPowers.pushPrefEnv({
set: [["extensions.manifestV3.enabled", true]],
});
});
add_task(async function test_action_onClicked() {
const extension = ExtensionTestUtils.loadExtension({
manifest: {
manifest_version: 3,
action: {},
},
background() {
browser.action.onClicked.addListener(async () => {
browser.test.notifyPass("action-clicked");
});
browser.test.sendMessage("background-ready");
},
});
await extension.startup();
await extension.awaitMessage("background-ready");
await AppTestDelegate.clickBrowserAction(window, extension);
await extension.awaitFinish("action-clicked");
await AppTestDelegate.closeBrowserAction(window, extension);
await extension.unload();
});
</script>
</body>
</html>