michael@0: /** michael@0: * Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/publicdomain/zero/1.0/ michael@0: */ michael@0: michael@0: const Ci = Components.interfaces; michael@0: const Cu = Components.utils; michael@0: michael@0: Cu.import("resource://gre/modules/Services.jsm"); michael@0: Cu.import("resource://gre/modules/XPCOMUtils.jsm"); michael@0: michael@0: function testForExpectedSymbols(stage, data) { michael@0: const expectedSymbols = [ "IDBKeyRange", "indexedDB" ]; michael@0: for each (var symbol in expectedSymbols) { michael@0: Services.prefs.setBoolPref("indexeddbtest.bootstrap." + stage + "." + michael@0: symbol, symbol in this); michael@0: } michael@0: } michael@0: michael@0: function GlobalObjectsComponent() { michael@0: this.wrappedJSObject = this; michael@0: } michael@0: michael@0: GlobalObjectsComponent.prototype = michael@0: { michael@0: QueryInterface: XPCOMUtils.generateQI([Ci.nsISupports]), michael@0: michael@0: runTest: function() { michael@0: const name = "Splendid Test"; michael@0: michael@0: let ok = this.ok; michael@0: let finishTest = this.finishTest; michael@0: michael@0: let keyRange = IDBKeyRange.only(42); michael@0: ok(keyRange, "Got keyRange"); michael@0: michael@0: let request = indexedDB.open(name, 1); michael@0: request.onerror = function(event) { michael@0: ok(false, "indexedDB error, '" + event.target.error.name + "'"); michael@0: finishTest(); michael@0: } michael@0: request.onsuccess = function(event) { michael@0: let db = event.target.result; michael@0: ok(db, "Got database"); michael@0: finishTest(); michael@0: } michael@0: } michael@0: }; michael@0: michael@0: var gFactory = { michael@0: register: function() { michael@0: var registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar); michael@0: michael@0: var classID = Components.ID("{d6f85dcb-537d-447e-b783-75d4b405622d}"); michael@0: var description = "IndexedDBTest"; michael@0: var contractID = "@mozilla.org/dom/indexeddb/GlobalObjectsComponent;1"; michael@0: var factory = XPCOMUtils._getFactory(GlobalObjectsComponent); michael@0: michael@0: registrar.registerFactory(classID, description, contractID, factory); michael@0: michael@0: this.unregister = function() { michael@0: registrar.unregisterFactory(classID, factory); michael@0: delete this.unregister; michael@0: }; michael@0: } michael@0: }; michael@0: michael@0: function install(data, reason) { michael@0: testForExpectedSymbols("install"); michael@0: } michael@0: michael@0: function startup(data, reason) { michael@0: testForExpectedSymbols("startup"); michael@0: gFactory.register(); michael@0: } michael@0: michael@0: function shutdown(data, reason) { michael@0: testForExpectedSymbols("shutdown"); michael@0: gFactory.unregister(); michael@0: } michael@0: michael@0: function uninstall(data, reason) { michael@0: testForExpectedSymbols("uninstall"); michael@0: }