Firefox extension sqlite extension

using the Builder interactive tool https://builder.addons.mozilla.org/ to build and test my extension now that I want to store data locally, I follow this guide https://developer.mozilla.org/en/Storage but fragments the code doesn't work for me Should I develop it locally using the classic SDK or is there a way to add SQLite support to the add-in constructor?

+4
source share
2 answers

The Add-on SDK is isolated by default and does not provide direct access to XPCOM. To use XPCOM objects, you need to exit the sandbox :

var {Cc, Ci, Cu} = require("chrome"); var {Services} = Cu.import("resource://gre/modules/Services.jsm"); var {FileUtils} = Cu.import("resource://gre/modules/FileUtils.jsm"); var file = FileUtils.getFile("ProfD", ["my_db_file_name.sqlite"]); var mDBConn = Services.storage.openDatabase(file); 

Note that Components remains undefined - use Cc instead of Components.classes , Ci instead of Components.interfaces and Cu instead of Components.utils .

+3
source
+1
source

Source: https://habr.com/ru/post/1379444/


All Articles