Closed Bug 1721428 Opened 5 years ago Closed 5 years ago

Unreliable permission request from commands

Categories

(WebExtensions :: General, defect)

Firefox 90
defect

Tracking

(firefox90 affected, firefox91 affected, firefox92 affected)

RESOLVED DUPLICATE of bug 1493396
Tracking Status
firefox90 --- affected
firefox91 --- affected
firefox92 --- affected

People

(Reporter: manikulin, Unassigned)

Details

Attachments

(3 files)

User Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:90.0) Gecko/20100101 Firefox/90.0

Steps to reproduce:

Request for an optional permission does not work from onCommand listener at least just after loading of an extension.

Try the following extension that defines commands and keyboard shortcuts for actions to request and to revoke a permission

file manifest.json

{
	"manifest_version": 2,
	"name": "Bug: Permission for command",
	"version": "0.1",
	"commands": {
		"_execute_browser_action": {
			"description": "Request Permission",
			"suggested_key": { "default": "Ctrl+Shift+L" }
		},
		"PERM_REQUEST": {
			"description": "Request Permission",
			"suggested_key": { "default": "Ctrl+Shift+S" }
		},
		"PERM_REVOKE": {
			"description": "Revoke Permission",
			"suggested_key": { "default": "Ctrl+Shift+U" }
		}
	},
	"browser_action": { "default_title": "Bug: Permission for command" },
	"background": { "scripts": [ "background.js" ] },
	"optional_permissions": [ "tabs" ]
}

file background.js

"use strict";

function bugDemoCommandListener(command) {
	const permissions = browser.runtime.getManifest().optional_permissions;
	console.log("bugDemoCommandListener: %o", command);
	switch (command) {
		case "PERM_REQUEST":
			browser.permissions.request({permissions}).then(console.log, console.error);
			break;
		case "PERM_REVOKE":
			browser.permissions.remove({permissions}).then(console.log, console.error);
			break;
		default:
			throw new Error(`Unsupported command ${command}`);
	}
}
browser.commands.onCommand.addListener(bugDemoCommandListener);
browser.browserAction.onClicked.addListener(function browserActionListener() {
	bugDemoCommandListener("PERM_REQUEST");
});

1 Load it as a temporary extension
2 Try [Ctrl+Shift+S] shortcut for a command that requests a permission

Actual results:

  • Popup for permission request does not appear
  • An error logged to extension console
    bugDemoCommandListener:  PERM_REQUEST background.js:5:10
    Error: An unexpected error occurred
    
  • Errors are logged to browser console
    window.PopupNotifications is undefined ExtensionsUI.jsm:458
      promise resource:///modules/ExtensionsUI.jsm:458
      showPermissionsPrompt resource:///modules/ExtensionsUI.jsm:374
      observe resource:///modules/ExtensionsUI.jsm:314
      allow chrome://extensions/content/parent/ext-permissions.js:81
      request chrome://extensions/content/parent/ext-permissions.js:71
      request self-hosted:1175
      result resource://gre/modules/ExtensionParent.jsm:935
      withPendingBrowser resource://gre/modules/ExtensionParent.jsm:491
      result resource://gre/modules/ExtensionParent.jsm:935
      callAndLog resource://gre/modules/ExtensionParent.jsm:897
      recvAPICall resource://gre/modules/ExtensionParent.jsm:934
      InterpretGeneratorResume self-hosted:1482
      AsyncFunctionNext self-hosted:692
    TypeError: window.PopupNotifications is undefined
    ExtensionsUI.jsm:458:7
    

Expected results:

Doorhanger for additional permission is requested.

Notice that the command for revoking permission works as expected ([Ctrl+Shift+U]), command for browser action (that requests permissions) works ([Ctrl+Shift+L]). After a shortcut for browser action, the command for [Ctrl+Shift+S] starts working (popup appears for it)

I noticed this problem while I was preparing example extension for Bug #1721393, earlier command for browser action were enough and it works.

Hello,

I managed to reproduce the issue on the latest Nightly (92.0a1/20210721212617), Beta (91.0b5/20210720190304) nor Release (90.0.1/20210716144314) under Windows 10 x64 and Ubuntu 16.04 LTS.

I had to remove a duplicate shortcut from the built in Firefox Screenshots which used the same shortcut (CTRL+SHIFT+S) as the test add-on.

Nonetheless, pressing CTRL+SHIFT+S will not bring up the permissions doorhanger and the mentioned errors are logged in both the add-on console and browser console (see screenshots).

As mentioned, after pressing CTRL+SHIFT+L for the browser action, the CTRL+SHIFT+S command starts working and the doorhanger is displayed. See the attached video.

Status: UNCONFIRMED → NEW
Ever confirmed: true
Attached image 2021-07-22_11h17_02.png
Attached image 2021-07-22_11h17_31.png
Attached video 2021-07-22_11h30_29.mp4

Rob says this looks weird.

Flags: needinfo?(rob)

window is the Hidden XUL window. Duplicate of bug 1493396

Status: NEW → RESOLVED
Closed: 5 years ago
Flags: needinfo?(rob)
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: