"An unexpected error occurred" when requesting optional permission (origin)

RESOLVED DUPLICATE of bug 1382953

Status

()

Toolkit
WebExtensions: Untriaged
RESOLVED DUPLICATE of bug 1382953
27 days ago
13 days ago

People

(Reporter: Serhii, Unassigned)

Tracking

57 Branch
Points:
---

Firefox Tracking Flags

(firefox57 wontfix)

Details

Attachments

(1 attachment)

(Reporter)

Description

27 days ago
Created attachment 8922226 [details]
attachement.zip - contains screenshot and extension source code

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36

Steps to reproduce:

Prerequirements:
- Firefox Developer Edition 57.0b11 (64-bit) (see screenshot)
- Have An extension with options page with the script (see attachement youtube-downloader-firefox/data/options.js)
- Go to settings and click save.


Actual results:

- see error in console "Error: An unexpected error occurred"
- permissions.origins has not changed


Expected results:

- There should be no error
- "<all_urls>" should be added as one of origins
(Reporter)

Comment 1

27 days ago
Basically the code that is falling (not to download all source):
```

const permissionsToRequest = {
    origins: ["<all_urls>"]
}

function requestPermissions() {

    function onResponse(response) {
        if (response) {
            console.log("Permission was granted");
        } else {
            console.log("Permission was refused");
        }
        return browser.permissions.getAll();
    }

    browser.permissions.request(permissionsToRequest)
        .then(onResponse)
        .then((currentPermissions) => {
            console.log(`Current permissions:`, currentPermissions);
        });
}

function saveOptions(e) {
    requestPermissions();
    e.preventDefault();
}

document.addEventListener("DOMContentLoaded", initOptionEvents);

```
(Reporter)

Comment 2

27 days ago
Forget to add a single line of code, should look like this:
```
const permissionsToRequest = {
    origins: ["<all_urls>"]
}

function requestPermissions() {

    function onResponse(response) {
        if (response) {
            console.log("Permission was granted");
        } else {
            console.log("Permission was refused");
        }
        return browser.permissions.getAll();
    }

    browser.permissions.request(permissionsToRequest)
        .then(onResponse)
        .then((currentPermissions) => {
            console.log(`Current permissions:`, currentPermissions);
        });
}

function saveOptions(e) {
    requestPermissions();
    e.preventDefault();
}

document.querySelector("#settings").addEventListener("submit", saveOptions);
```

(In reply to Serhii from comment #1)
> Basically the code that is falling (not to download all source):
> ```
> 
> const permissionsToRequest = {
>     origins: ["<all_urls>"]
> }
> 
> function requestPermissions() {
> 
>     function onResponse(response) {
>         if (response) {
>             console.log("Permission was granted");
>         } else {
>             console.log("Permission was refused");
>         }
>         return browser.permissions.getAll();
>     }
> 
>     browser.permissions.request(permissionsToRequest)
>         .then(onResponse)
>         .then((currentPermissions) => {
>             console.log(`Current permissions:`, currentPermissions);
>         });
> }
> 
> function saveOptions(e) {
>     requestPermissions();
>     e.preventDefault();
> }
> 
> document.addEventListener("DOMContentLoaded", initOptionEvents);
> 
> ```
Component: Untriaged → WebExtensions: Untriaged
Product: Firefox → Toolkit

Updated

27 days ago
status-firefox57: --- → wontfix

Updated

20 days ago
Flags: needinfo?(aswan)
Summary: WebExtension "An unexpected error occurred" when requesting optional permission (origin) → "An unexpected error occurred" when requesting optional permission (origin)
Status: UNCONFIRMED → RESOLVED
Last Resolved: 13 days ago
Flags: needinfo?(aswan)
Resolution: --- → DUPLICATE
Duplicate of bug: 1382953
You need to log in before you can comment on or make changes to this bug.