Skip to content

Instantly share code, notes, and snippets.

@anoopelias
Last active August 12, 2019 04:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anoopelias/34a8fd5ac8d032bacb84e3e500c318f0 to your computer and use it in GitHub Desktop.
Save anoopelias/34a8fd5ac8d032bacb84e3e500c318f0 to your computer and use it in GitHub Desktop.
Firefox WebExtensions API `search.get()` throws an error when invoked from Ubuntu distribution

Prerequisites

Firefox 68.0.1 (64bit) installed from Ubuntu distribution,

Steps to reproduce

  1. Copy the files manifest.json and background.js in to a folder
  2. Run $ web-ext run
  3. In address bar type about:debugging. Temporary extensions 'Test Extension' will be loaded.
  4. Click 'Debug'

It gives an error, Error: "An unexpected error occurred"

console.log("Loading background script");
function retrieved(results) {
console.log(`There were: ${results.length} search engines retrieved.`);
for (let searchEngine of results) {
console.log(JSON.stringify(searchEngine.name));
}
}
browser.search.get().then(retrieved).catch(function(err) {
console.log("Error", err);
});
{
"manifest_version": 2,
"name": "Test Extension",
"version": "0.0.1",
"background": {
"scripts": [
"background.js"
]
},
"permissions": [
"search"
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment