Firefox doesn't allow checking for a permission before adding it (webextensions)

The following code works in Chrome, but not in Firefox:

  document.querySelector('#some-element').addEventListener('click', () => {
      const url = 'https://example.com';
      chrome.permissions.contains(
        { origins: [url] },
        (result) => {
          if (!result) {
            chrome.permissions.request(
              { origins: [url] },
              (granted) => {
                if (granted) {
                  console.log('granted permission');
                  );
                }
              },
            );
          }
        });
   });

Firefox errors with

Unchecked lastError value: Error: May only request permissions from a user input handler

But Chrome adds it just fine. Is this a bug? Is there some info on how to avoid checking for redundant permissions if it is not a bug?

Edit: I should add, the code above is run in the options/settings UI of the addon.

Does the browser even prompt when you request a permission you already have? If not, you can just always request it. The result would be the same.

If Firefox does ask even for permissions already granted, you may be able to do your check on the 'change' event on the input element (or whatever else) where the url comes from and save the result until the submit button is clicked.

The browser does prompt for permissions it already has.

Thanks for the workaround. Right now, I’m just asking the user redundant questions and avoid the check on FF.

I’m curious what the intended behaviour here is, and why FF and Chrome are not in agreement.