Closed Bug 1397658 Opened 7 years ago Closed 7 years ago

permissions.request may only be called from a user input handler

Categories

(WebExtensions :: General, defect)

57 Branch
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 1392624

People

(Reporter: extensions, Unassigned)

Details

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36

Steps to reproduce:

i'm migrating an existing addon to webextensions api, making it work cross-browser (firefox, google chrome).

the high-level flow of calls looks like this:

 1. user opens popup by clicking browser action button
 2. user enters email credentials and submits data
 3. popup button click handler takes credentials and sends it to the background page for validation and performing the login

a little background: the extension's manifest declares optional_permissions: ["<all-urls>"] in order to lazily fetch permissions to particular servers – extracted from the email domain entered by the user. this causes calls like 

    chrome.permissions.request({ origins: ["https://x.y.tld"] });

on the background page during the actual login.

since having the browser action popup and the permission requestor dialog opened simultaneously is not possible, zooming into step 3. reveals:

 1. popup.js: chrome.runtime.sendMessage(credentials)
 2. background.js: onMessage listener figures out whether permissions have been granted for particular email domain.
 3. background.js: chrome.permissions.request() as shown above


Actual results:

while google chrome seems to interpret the entire flow as triggered by a user action, firefox seems to decide differently; console log:

Unchecked lastError value: Error: permissions.request may only be called from a user input handler  ExtensionCommon.jsm:304


Expected results:

personally, i think that firefox should behave like chrome in this respect, because

 - the action actually _has_ been trigger by a user input handler - data submission!
 - popup and permissions requestor can/should not be visible in parallel. that said, the current behavior seems to be a severe limitation of the usefulness of popup dialogs with more than simplest logic
Version: 55 Branch → 57 Branch
Component: Untriaged → Permission Manager
Product: Firefox → Core
Component: Permission Manager → WebExtensions: General
Product: Core → Toolkit
Status: UNCONFIRMED → RESOLVED
Closed: 7 years ago
Resolution: --- → DUPLICATE
Duplicate of bug 1392624 which is P5, not tracking for 57.
Product: Toolkit → WebExtensions
You need to log in before you can comment on or make changes to this bug.