2
  • WebExtensions: Promises never resolve when an async function returns undefined

  • BugsDesktopDone

Steps to reproduce:

  1. Unzip and install the attached extension
  2. In a browser window, open a new tab but don't navigate to any pages yet
  3. Show the javascript console
  4. Open any webpage, such as https://kagi.com

Expected behavior:
The page's console should print the following output:

load event
Calling sendMessage()
Received promise1, about to await result...
result:
done
Calling sendMessage again()
Received promise2, about to await result...
result:
null

Actual behavior:
The output never prints anything past "Received promise2, about to await result..."

This extension functions correctly in both Firefox and Chrome.

More notes:
The attached extension is a simple test case demonstrating a bug in Orion where it does not handle promises the same way as Firefox or Chrome. The issue is that handleMessage() in background.js does not return a value for the second message it responds to. As a result, promise2 in content.js never resolves. In both Chrome and Firefox, async functions that return no value (or return undefined) still resolve to either null or undefined.

This discrepancy in behavior is one of the major reasons the KeePassXC-browser extension does not work in Orion. There's a good chance a bunch of other extensions are broken as a result of this as well.

Orion, OS version; hardware type:
Version 0.99.113.2-beta (WebKit 613.1.12)
macOS 10.14.6

test-extension.zip
23kB
    15 days later
    No one is typing