зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1387506 - Apply activeTab permission for _execute_browser_action r=kmag
And add tests to confirm that activeTab works for both _execute_browser_action and _execute_page_action. MozReview-Commit-ID: HDTDZXCvukc --HG-- extra : rebase_source : 1a59270afa7b87979329d0fed197238e6655a647
This commit is contained in:
Родитель
a4d28780d7
Коммит
1ed7253b50
|
@ -267,6 +267,7 @@ this.browserAction = class extends ExtensionAPI {
|
|||
let event = new window.CustomEvent("command", {bubbles: true, cancelable: true});
|
||||
widget.node.dispatchEvent(event);
|
||||
} else {
|
||||
this.tabManager.addActiveTabPermission(tab);
|
||||
this.emit("click");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -113,6 +113,57 @@ add_task(async function testBadPermissions() {
|
|||
},
|
||||
});
|
||||
|
||||
info("Test no special permissions, _execute_browser_action command");
|
||||
await testHasNoPermission({
|
||||
manifest: {
|
||||
"permissions": ["http://example.com/"],
|
||||
"browser_action": {},
|
||||
"commands": {
|
||||
"_execute_browser_action": {
|
||||
"suggested_key": {
|
||||
"default": "Alt+Shift+K",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
contentSetup: function() {
|
||||
browser.browserAction.onClicked.addListener(() => {
|
||||
browser.test.sendMessage("tabs-command-key-pressed");
|
||||
});
|
||||
return Promise.resolve();
|
||||
},
|
||||
setup: async function(extension) {
|
||||
await EventUtils.synthesizeKey("k", {altKey: true, shiftKey: true});
|
||||
await extension.awaitMessage("tabs-command-key-pressed");
|
||||
},
|
||||
});
|
||||
|
||||
info("Test no special permissions, _execute_page_action command");
|
||||
await testHasNoPermission({
|
||||
manifest: {
|
||||
"permissions": ["http://example.com/"],
|
||||
"page_action": {},
|
||||
"commands": {
|
||||
"_execute_page_action": {
|
||||
"suggested_key": {
|
||||
"default": "Alt+Shift+K",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
contentSetup: async function() {
|
||||
browser.pageAction.onClicked.addListener(() => {
|
||||
browser.test.sendMessage("tabs-command-key-pressed");
|
||||
});
|
||||
let [tab] = await browser.tabs.query({active: true, currentWindow: true});
|
||||
await browser.pageAction.show(tab.id);
|
||||
},
|
||||
setup: async function(extension) {
|
||||
await EventUtils.synthesizeKey("k", {altKey: true, shiftKey: true});
|
||||
await extension.awaitMessage("tabs-command-key-pressed");
|
||||
},
|
||||
});
|
||||
|
||||
info("Test active tab, commands, no key press");
|
||||
await testHasNoPermission({
|
||||
manifest: {
|
||||
|
|
|
@ -100,6 +100,57 @@ add_task(async function testGoodPermissions() {
|
|||
},
|
||||
});
|
||||
|
||||
info("Test activeTab permission with _execute_browser_action command");
|
||||
await testHasPermission({
|
||||
manifest: {
|
||||
"permissions": ["activeTab"],
|
||||
"browser_action": {},
|
||||
"commands": {
|
||||
"_execute_browser_action": {
|
||||
"suggested_key": {
|
||||
"default": "Alt+Shift+K",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
contentSetup: function() {
|
||||
browser.browserAction.onClicked.addListener(() => {
|
||||
browser.test.sendMessage("tabs-command-key-pressed");
|
||||
});
|
||||
return Promise.resolve();
|
||||
},
|
||||
setup: async function(extension) {
|
||||
await EventUtils.synthesizeKey("k", {altKey: true, shiftKey: true});
|
||||
await extension.awaitMessage("tabs-command-key-pressed");
|
||||
},
|
||||
});
|
||||
|
||||
info("Test activeTab permission with _execute_page_action command");
|
||||
await testHasPermission({
|
||||
manifest: {
|
||||
"permissions": ["activeTab"],
|
||||
"page_action": {},
|
||||
"commands": {
|
||||
"_execute_page_action": {
|
||||
"suggested_key": {
|
||||
"default": "Alt+Shift+K",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
contentSetup: async function() {
|
||||
browser.pageAction.onClicked.addListener(() => {
|
||||
browser.test.sendMessage("tabs-command-key-pressed");
|
||||
});
|
||||
let [tab] = await browser.tabs.query({active: true, currentWindow: true});
|
||||
await browser.pageAction.show(tab.id);
|
||||
},
|
||||
setup: async function(extension) {
|
||||
await EventUtils.synthesizeKey("k", {altKey: true, shiftKey: true});
|
||||
await extension.awaitMessage("tabs-command-key-pressed");
|
||||
},
|
||||
});
|
||||
|
||||
info("Test activeTab permission with a browser action click");
|
||||
await testHasPermission({
|
||||
manifest: {
|
||||
|
|
Загрузка…
Ссылка в новой задаче