From 8f8a9991825cfc46f0a61b8ae6cb66d5a08674f5 Mon Sep 17 00:00:00 2001 From: Jan Varga Date: Tue, 19 Nov 2013 08:36:12 +0100 Subject: [PATCH] Bug 921478 - Remove BackstagePass IDB constructor resolve hook and use Cu.importGlobalProperties. r=bholley,bent --HG-- rename : dom/indexedDB/test/test_globalObjects.xul => dom/indexedDB/test/test_globalObjects_chrome.xul rename : dom/indexedDB/test/test_globalObjects.html => dom/indexedDB/test/test_globalObjects_content.html rename : dom/indexedDB/test/unit/test_globalObjects.js => dom/indexedDB/test/unit/test_globalObjects_xpc.js --- dom/base/IndexedDBHelper.jsm | 1 + dom/contacts/fallback/ContactDB.jsm | 1 + dom/contacts/tests/test_contacts_upgrade.html | 1 + dom/indexedDB/IndexedDatabaseManager.cpp | 183 +++--------------- dom/indexedDB/IndexedDatabaseManager.h | 12 +- dom/indexedDB/test/chrome.ini | 3 +- dom/indexedDB/test/chromeHelpers.js | 12 +- dom/indexedDB/test/mochitest.ini | 2 +- .../test/test_globalObjects_chrome.xul | 43 ++++ ...s.html => test_globalObjects_content.html} | 0 ...jects.xul => test_globalObjects_other.xul} | 20 +- dom/indexedDB/test/unit/GlobalObjectsChild.js | 2 + .../test/unit/GlobalObjectsComponent.js | 5 +- .../test/unit/GlobalObjectsModule.jsm | 2 + dom/indexedDB/test/unit/head.js | 18 +- dom/indexedDB/test/unit/mochitest.ini | 3 +- ...Objects.js => test_globalObjects_other.js} | 21 +- .../test/unit/test_globalObjects_xpc.js | 26 +++ dom/indexedDB/test/unit/xpcshell.ini | 5 +- .../src/gonk/MobileMessageDatabaseService.js | 1 + dom/network/src/NetworkStatsDB.jsm | 1 + dom/push/src/PushService.jsm | 1 + js/xpconnect/src/Sandbox.cpp | 3 +- js/xpconnect/src/XPCRuntimeService.cpp | 10 - js/xpconnect/src/nsXPConnect.cpp | 7 - testing/mochitest/b2g-desktop.json | 2 +- 26 files changed, 153 insertions(+), 232 deletions(-) create mode 100644 dom/indexedDB/test/test_globalObjects_chrome.xul rename dom/indexedDB/test/{test_globalObjects.html => test_globalObjects_content.html} (100%) rename dom/indexedDB/test/{test_globalObjects.xul => test_globalObjects_other.xul} (82%) rename dom/indexedDB/test/unit/{test_globalObjects.js => test_globalObjects_other.js} (81%) create mode 100644 dom/indexedDB/test/unit/test_globalObjects_xpc.js diff --git a/dom/base/IndexedDBHelper.jsm b/dom/base/IndexedDBHelper.jsm index 818921ff50af..1a4302996cfc 100644 --- a/dom/base/IndexedDBHelper.jsm +++ b/dom/base/IndexedDBHelper.jsm @@ -20,6 +20,7 @@ this.EXPORTED_SYMBOLS = ["IndexedDBHelper"]; Cu.import("resource://gre/modules/XPCOMUtils.jsm"); Cu.import("resource://gre/modules/Services.jsm"); +Cu.importGlobalProperties(["indexedDB"]); this.IndexedDBHelper = function IndexedDBHelper() {} diff --git a/dom/contacts/fallback/ContactDB.jsm b/dom/contacts/fallback/ContactDB.jsm index c0db32c36fe4..52ec9f3118c0 100644 --- a/dom/contacts/fallback/ContactDB.jsm +++ b/dom/contacts/fallback/ContactDB.jsm @@ -18,6 +18,7 @@ const Ci = Components.interfaces; Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://gre/modules/IndexedDBHelper.jsm"); Cu.import("resource://gre/modules/PhoneNumberUtils.jsm"); +Cu.importGlobalProperties(["indexedDB"]); const DB_NAME = "contacts"; const DB_VERSION = 18; diff --git a/dom/contacts/tests/test_contacts_upgrade.html b/dom/contacts/tests/test_contacts_upgrade.html index b4438292aaa2..b271fe655199 100644 --- a/dom/contacts/tests/test_contacts_upgrade.html +++ b/dom/contacts/tests/test_contacts_upgrade.html @@ -148,6 +148,7 @@ function makeFailure(reason) { const {Cc, Ci, Cu} = SpecialPowers; Cu.import("resource://gre/modules/ContactDB.jsm", window); +Cu.importGlobalProperties(["indexedDB"]); let cdb = new ContactDB(); cdb.init(); diff --git a/dom/indexedDB/IndexedDatabaseManager.cpp b/dom/indexedDB/IndexedDatabaseManager.cpp index 67fb0b19cbc2..aefb62cccf4d 100644 --- a/dom/indexedDB/IndexedDatabaseManager.cpp +++ b/dom/indexedDB/IndexedDatabaseManager.cpp @@ -111,35 +111,6 @@ mozilla::StaticRefPtr gInstance; mozilla::Atomic gInitialized(0); mozilla::Atomic gClosed(0); -// See ResolveConstructors below. -struct ConstructorInfo { - const char* const name; - JS::Handle (* const resolve)(JSContext*, JS::Handle, - bool); - jsid id; -}; - -ConstructorInfo gConstructorInfo[] = { - -#define BINDING_ENTRY(_name) \ - { #_name, _name##Binding::GetConstructorObject, JSID_VOID }, - - BINDING_ENTRY(IDBCursor) - BINDING_ENTRY(IDBCursorWithValue) - BINDING_ENTRY(IDBDatabase) - BINDING_ENTRY(IDBFactory) - BINDING_ENTRY(IDBFileHandle) - BINDING_ENTRY(IDBIndex) - BINDING_ENTRY(IDBKeyRange) - BINDING_ENTRY(IDBObjectStore) - BINDING_ENTRY(IDBOpenDBRequest) - BINDING_ENTRY(IDBRequest) - BINDING_ENTRY(IDBTransaction) - BINDING_ENTRY(IDBVersionChangeEvent) - -#undef BINDING_ENTRY -}; - class AsyncDeleteFileRunnable MOZ_FINAL : public nsIRunnable { public: @@ -207,53 +178,6 @@ struct MOZ_STACK_CLASS InvalidateInfo const nsACString& pattern; }; -bool -GetIndexedDB(JSContext* aCx, JS::Handle aGlobal, - JS::MutableHandle aResult) -{ - MOZ_ASSERT(nsContentUtils::IsCallerChrome(), "Only for chrome!"); - MOZ_ASSERT(js::GetObjectClass(aGlobal)->flags & JSCLASS_DOM_GLOBAL, - "Not a global object!"); - - nsRefPtr factory; - if (NS_FAILED(IDBFactory::Create(aCx, aGlobal, nullptr, - getter_AddRefs(factory)))) { - return false; - } - - MOZ_ASSERT(factory, "This should never fail for chrome!"); - - return !!WrapNewBindingObject(aCx, aGlobal, factory, aResult); -} - -bool -IndexedDBLazyGetter(JSContext* aCx, JS::Handle aGlobal, - JS::Handle aId, JS::MutableHandle aVp) -{ - MOZ_ASSERT(nsContentUtils::IsCallerChrome(), "Only for chrome!"); - MOZ_ASSERT(JSID_IS_STRING(aId), "Bad id!"); - MOZ_ASSERT(JS_FlatStringEqualsAscii(JSID_TO_FLAT_STRING(aId), IDB_STR), - "Bad id!"); - - JS::Rooted global(aCx, CheckedUnwrap(aGlobal, - /* stopAtOuter = */ false)); - NS_ENSURE_TRUE(global, false); - NS_ENSURE_TRUE(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL, false); - - JS::Rooted indexedDB(aCx); - if (!GetIndexedDB(aCx, global, &indexedDB)) { - return false; - } - - if (!JS_DefinePropertyById(aCx, global, aId, indexedDB, nullptr, nullptr, - JSPROP_ENUMERATE)) { - return false; - } - - aVp.set(indexedDB); - return true; -} - } // anonymous namespace IndexedDatabaseManager::IndexedDatabaseManager() @@ -482,32 +406,39 @@ IndexedDatabaseManager::TabContextMayAccessOrigin(const TabContext& aContext, // static bool -IndexedDatabaseManager::DefineConstructors(JSContext* aCx, - JS::Handle aGlobal) -{ - MOZ_ASSERT(NS_IsMainThread()); - - for (uint32_t i = 0; i < mozilla::ArrayLength(gConstructorInfo); i++) { - if (!gConstructorInfo[i].resolve(aCx, aGlobal, true)) { - return false; - } - } - - return true; -} - -// static -bool -IndexedDatabaseManager::DefineIndexedDBGetter(JSContext* aCx, - JS::Handle aGlobal) +IndexedDatabaseManager::DefineIndexedDB(JSContext* aCx, + JS::Handle aGlobal) { MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(nsContentUtils::IsCallerChrome(), "Only for chrome!"); MOZ_ASSERT(js::GetObjectClass(aGlobal)->flags & JSCLASS_DOM_GLOBAL, "Passed object is not a global object!"); + if (!IDBCursorBinding::GetConstructorObject(aCx, aGlobal) || + !IDBCursorWithValueBinding::GetConstructorObject(aCx, aGlobal) || + !IDBDatabaseBinding::GetConstructorObject(aCx, aGlobal) || + !IDBFactoryBinding::GetConstructorObject(aCx, aGlobal) || + !IDBFileHandleBinding::GetConstructorObject(aCx, aGlobal) || + !IDBIndexBinding::GetConstructorObject(aCx, aGlobal) || + !IDBKeyRangeBinding::GetConstructorObject(aCx, aGlobal) || + !IDBObjectStoreBinding::GetConstructorObject(aCx, aGlobal) || + !IDBOpenDBRequestBinding::GetConstructorObject(aCx, aGlobal) || + !IDBRequestBinding::GetConstructorObject(aCx, aGlobal) || + !IDBTransactionBinding::GetConstructorObject(aCx, aGlobal) || + !IDBVersionChangeEventBinding::GetConstructorObject(aCx, aGlobal)) { + return false; + } + + nsRefPtr factory; + if (NS_FAILED(IDBFactory::Create(aCx, aGlobal, nullptr, + getter_AddRefs(factory)))) { + return false; + } + + MOZ_ASSERT(factory, "This should never fail for chrome!"); + JS::Rooted indexedDB(aCx); - if (!GetIndexedDB(aCx, aGlobal, &indexedDB)) { + if (!WrapNewBindingObject(aCx, aGlobal, factory, &indexedDB)) { return false; } @@ -515,20 +446,6 @@ IndexedDatabaseManager::DefineIndexedDBGetter(JSContext* aCx, JSPROP_ENUMERATE); } -// static -bool -IndexedDatabaseManager::DefineIndexedDBLazyGetter(JSContext* aCx, - JS::Handle aGlobal) -{ - MOZ_ASSERT(NS_IsMainThread()); - MOZ_ASSERT(nsContentUtils::IsCallerChrome(), "Only for chrome!"); - MOZ_ASSERT(js::GetObjectClass(aGlobal)->flags & JSCLASS_DOM_GLOBAL, - "Passed object is not a global object!"); - - return JS_DefineProperty(aCx, aGlobal, IDB_STR, JSVAL_VOID, - IndexedDBLazyGetter, nullptr, 0); -} - // static bool IndexedDatabaseManager::IsClosed() @@ -749,7 +666,7 @@ IndexedDatabaseManager::InitWindowless(const jsval& aGlobal, JSContext* aCx) return NS_ERROR_FAILURE; } - if (!DefineConstructors(aCx, global) || !DefineIndexedDBGetter(aCx, global)) { + if (!DefineIndexedDB(aCx, global)) { return NS_ERROR_FAILURE; } @@ -1001,49 +918,3 @@ GetFileReferencesHelper::Run() return NS_OK; } - -BEGIN_INDEXEDDB_NAMESPACE - -bool -ResolveConstructors(JSContext* aCx, JS::Handle aObj, - JS::Handle aId, JS::MutableHandle aObjp) -{ - MOZ_ASSERT(NS_IsMainThread()); - - // The first time this function is called we need to intern all the strings we - // care about. - if (JSID_IS_VOID(gConstructorInfo[0].id)) { - for (uint32_t i = 0; i < mozilla::ArrayLength(gConstructorInfo); i++) { - JS::Rooted str(aCx, - JS_InternString(aCx, gConstructorInfo[i].name)); - if (!str) { - NS_WARNING("Failed to intern string!"); - while (i) { - gConstructorInfo[--i].id = JSID_VOID; - } - return false; - } - gConstructorInfo[i].id = INTERNED_STRING_TO_JSID(aCx, str); - } - } - - // Now resolve. - for (uint32_t i = 0; i < mozilla::ArrayLength(gConstructorInfo); i++) { - if (gConstructorInfo[i].id == aId) { - JS::Rooted constructor(aCx, - gConstructorInfo[i].resolve(aCx, aObj, true)); - if (!constructor) { - return false; - } - - aObjp.set(aObj); - return true; - } - } - - // Not resolved. - aObjp.set(nullptr); - return true; -} - -END_INDEXEDDB_NAMESPACE diff --git a/dom/indexedDB/IndexedDatabaseManager.h b/dom/indexedDB/IndexedDatabaseManager.h index e81236fbc7bb..c3ec871fa07d 100644 --- a/dom/indexedDB/IndexedDatabaseManager.h +++ b/dom/indexedDB/IndexedDatabaseManager.h @@ -140,13 +140,7 @@ public: const nsACString& aOrigin); static bool - DefineConstructors(JSContext* aCx, JS::Handle aGlobal); - - static bool - DefineIndexedDBGetter(JSContext* aCx, JS::Handle aGlobal); - - static bool - DefineIndexedDBLazyGetter(JSContext* aCx, JS::Handle aGlobal); + DefineIndexedDB(JSContext* aCx, JS::Handle aGlobal); private: IndexedDatabaseManager(); @@ -176,10 +170,6 @@ private: static mozilla::Atomic sLowDiskSpaceMode; }; -bool -ResolveConstructors(JSContext* aCx, JS::Handle aObj, - JS::Handle aId, JS::MutableHandle aObjp); - END_INDEXEDDB_NAMESPACE #endif /* mozilla_dom_indexeddb_indexeddatabasemanager_h__ */ diff --git a/dom/indexedDB/test/chrome.ini b/dom/indexedDB/test/chrome.ini index 636a72c429dd..a809b45b5d1f 100644 --- a/dom/indexedDB/test/chrome.ini +++ b/dom/indexedDB/test/chrome.ini @@ -1,4 +1,5 @@ [DEFAULT] support-files = chromeHelpers.js -[test_globalObjects.xul] +[test_globalObjects_chrome.xul] +[test_globalObjects_other.xul] diff --git a/dom/indexedDB/test/chromeHelpers.js b/dom/indexedDB/test/chromeHelpers.js index 1233661060bb..cb86f2747ec6 100644 --- a/dom/indexedDB/test/chromeHelpers.js +++ b/dom/indexedDB/test/chromeHelpers.js @@ -7,11 +7,15 @@ const { 'classes': Cc, 'interfaces': Ci, 'utils': Cu } = Components; let testGenerator = testSteps(); -function runTest() -{ - SimpleTest.waitForExplicitFinish(); +if (!window.runTest) { + window.runTest = function() + { + Cu.importGlobalProperties(["indexedDB"]); - testGenerator.next(); + SimpleTest.waitForExplicitFinish(); + + testGenerator.next(); + } } function finishTest() diff --git a/dom/indexedDB/test/mochitest.ini b/dom/indexedDB/test/mochitest.ini index 54783fece01c..4f9e4b9eae3c 100644 --- a/dom/indexedDB/test/mochitest.ini +++ b/dom/indexedDB/test/mochitest.ini @@ -58,7 +58,7 @@ support-files = [test_filehandle_store_snapshot.html] [test_getAll.html] [test_get_filehandle.html] -[test_globalObjects.html] +[test_globalObjects_content.html] [test_global_data.html] [test_index_empty_keyPath.html] [test_index_getAll.html] diff --git a/dom/indexedDB/test/test_globalObjects_chrome.xul b/dom/indexedDB/test/test_globalObjects_chrome.xul new file mode 100644 index 000000000000..47e967d9692e --- /dev/null +++ b/dom/indexedDB/test/test_globalObjects_chrome.xul @@ -0,0 +1,43 @@ + + + + + + + + + + + Mozilla Bug 832883 + + diff --git a/dom/indexedDB/test/test_globalObjects.html b/dom/indexedDB/test/test_globalObjects_content.html similarity index 100% rename from dom/indexedDB/test/test_globalObjects.html rename to dom/indexedDB/test/test_globalObjects_content.html diff --git a/dom/indexedDB/test/test_globalObjects.xul b/dom/indexedDB/test/test_globalObjects_other.xul similarity index 82% rename from dom/indexedDB/test/test_globalObjects.xul rename to dom/indexedDB/test/test_globalObjects_other.xul index c3d2520a2c70..cfab5deace9d 100644 --- a/dom/indexedDB/test/test_globalObjects.xul +++ b/dom/indexedDB/test/test_globalObjects_other.xul @@ -14,20 +14,6 @@ diff --git a/dom/indexedDB/test/unit/GlobalObjectsChild.js b/dom/indexedDB/test/unit/GlobalObjectsChild.js index 586d27f7b4f4..5351ff2f1a9a 100644 --- a/dom/indexedDB/test/unit/GlobalObjectsChild.js +++ b/dom/indexedDB/test/unit/GlobalObjectsChild.js @@ -18,6 +18,8 @@ function finishTest() function run_test() { const name = "Splendid Test"; + Cu.importGlobalProperties(["indexedDB"]); + do_test_pending(); let keyRange = IDBKeyRange.only(42); diff --git a/dom/indexedDB/test/unit/GlobalObjectsComponent.js b/dom/indexedDB/test/unit/GlobalObjectsComponent.js index 01c3e23dafc8..44bc1afe9b69 100644 --- a/dom/indexedDB/test/unit/GlobalObjectsComponent.js +++ b/dom/indexedDB/test/unit/GlobalObjectsComponent.js @@ -3,7 +3,10 @@ * http://creativecommons.org/publicdomain/zero/1.0/ */ -Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); +const Cu = Components.utils; + +Cu.import("resource://gre/modules/XPCOMUtils.jsm"); +Cu.importGlobalProperties(["indexedDB"]); function GlobalObjectsComponent() { this.wrappedJSObject = this; diff --git a/dom/indexedDB/test/unit/GlobalObjectsModule.jsm b/dom/indexedDB/test/unit/GlobalObjectsModule.jsm index cb085b6f3355..fe214f722e72 100644 --- a/dom/indexedDB/test/unit/GlobalObjectsModule.jsm +++ b/dom/indexedDB/test/unit/GlobalObjectsModule.jsm @@ -3,6 +3,8 @@ * http://creativecommons.org/publicdomain/zero/1.0/ */ +Components.utils.importGlobalProperties(["indexedDB"]); + this.EXPORTED_SYMBOLS = [ "GlobalObjectsModule" ]; diff --git a/dom/indexedDB/test/unit/head.js b/dom/indexedDB/test/unit/head.js index b3757ec25bb3..1ec20b3463e0 100644 --- a/dom/indexedDB/test/unit/head.js +++ b/dom/indexedDB/test/unit/head.js @@ -38,15 +38,19 @@ function run_test() { runTest(); }; -function runTest() -{ - // XPCShell does not get a profile by default. - do_get_profile(); +if (!this.runTest) { + this.runTest = function() + { + // XPCShell does not get a profile by default. + do_get_profile(); - enableExperimental(); + enableExperimental(); - do_test_pending(); - testGenerator.next(); + Cu.importGlobalProperties(["indexedDB"]); + + do_test_pending(); + testGenerator.next(); + } } function finishTest() diff --git a/dom/indexedDB/test/unit/mochitest.ini b/dom/indexedDB/test/unit/mochitest.ini index e2823e9587f4..e0fcdf40d12a 100644 --- a/dom/indexedDB/test/unit/mochitest.ini +++ b/dom/indexedDB/test/unit/mochitest.ini @@ -18,8 +18,9 @@ [test_deleteDatabase_interactions.js] [test_event_source.js] [test_getAll.js] -[test_globalObjects.js] [test_globalObjects_ipc.js] +[test_globalObjects_other.js] +[test_globalObjects_xpc.js] [test_global_data.js] [test_index_empty_keyPath.js] [test_index_getAll.js] diff --git a/dom/indexedDB/test/unit/test_globalObjects.js b/dom/indexedDB/test/unit/test_globalObjects_other.js similarity index 81% rename from dom/indexedDB/test/unit/test_globalObjects.js rename to dom/indexedDB/test/unit/test_globalObjects_other.js index 40ae45fcd0f1..a1338459c83b 100644 --- a/dom/indexedDB/test/unit/test_globalObjects.js +++ b/dom/indexedDB/test/unit/test_globalObjects_other.js @@ -7,8 +7,6 @@ var testGenerator = testSteps(); function testSteps() { - const name = "Splendid Test"; - let ioService = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService); @@ -18,18 +16,6 @@ function testSteps() return uri.spec; } - // Test for IDBKeyRange and indexedDB availability in xpcshell. - let keyRange = IDBKeyRange.only(42); - ok(keyRange, "Got keyRange"); - - let request = indexedDB.open(name, 1); - request.onerror = errorHandler; - request.onsuccess = grabEventAndContinueHandler; - let event = yield undefined; - - let db = event.target.result; - ok(db, "Got database"); - // Test for IDBKeyRange and indexedDB availability in JS modules. Cu.import(getSpec("GlobalObjectsModule.jsm")); let test = new GlobalObjectsModule(); @@ -65,3 +51,10 @@ function testSteps() finishTest(); yield undefined; } + +this.runTest = function() { + do_get_profile(); + + do_test_pending(); + testGenerator.next(); +} diff --git a/dom/indexedDB/test/unit/test_globalObjects_xpc.js b/dom/indexedDB/test/unit/test_globalObjects_xpc.js new file mode 100644 index 000000000000..57611d046900 --- /dev/null +++ b/dom/indexedDB/test/unit/test_globalObjects_xpc.js @@ -0,0 +1,26 @@ +/** + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ + */ + +var testGenerator = testSteps(); + +function testSteps() +{ + const name = "Splendid Test"; + + // Test for IDBKeyRange and indexedDB availability in xpcshell. + let keyRange = IDBKeyRange.only(42); + ok(keyRange, "Got keyRange"); + + let request = indexedDB.open(name, 1); + request.onerror = errorHandler; + request.onsuccess = grabEventAndContinueHandler; + let event = yield undefined; + + let db = event.target.result; + ok(db, "Got database"); + + finishTest(); + yield undefined; +} diff --git a/dom/indexedDB/test/unit/xpcshell.ini b/dom/indexedDB/test/unit/xpcshell.ini index fdfedcedb64e..d3e19e5e52cf 100644 --- a/dom/indexedDB/test/unit/xpcshell.ini +++ b/dom/indexedDB/test/unit/xpcshell.ini @@ -28,10 +28,11 @@ support-files = [test_deleteDatabase_interactions.js] [test_event_source.js] [test_getAll.js] -[test_globalObjects.js] [test_globalObjects_ipc.js] # FIXME/bug 575918: out-of-process xpcshell is broken on OS X -skip-if = os == "mac" || os == "android" +#skip-if = os == "mac" || os == "android" +[test_globalObjects_other.js] +[test_globalObjects_xpc.js] [test_global_data.js] [test_index_empty_keyPath.js] [test_index_getAll.js] diff --git a/dom/mobilemessage/src/gonk/MobileMessageDatabaseService.js b/dom/mobilemessage/src/gonk/MobileMessageDatabaseService.js index e17a37c63f27..918a8d1f853a 100644 --- a/dom/mobilemessage/src/gonk/MobileMessageDatabaseService.js +++ b/dom/mobilemessage/src/gonk/MobileMessageDatabaseService.js @@ -9,6 +9,7 @@ const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components; Cu.import("resource://gre/modules/XPCOMUtils.jsm"); Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://gre/modules/PhoneNumberUtils.jsm"); +Cu.importGlobalProperties(["indexedDB"]); const RIL_MOBILEMESSAGEDATABASESERVICE_CONTRACTID = "@mozilla.org/mobilemessage/rilmobilemessagedatabaseservice;1"; diff --git a/dom/network/src/NetworkStatsDB.jsm b/dom/network/src/NetworkStatsDB.jsm index 3d22ef9ca139..c8e64347cbf1 100644 --- a/dom/network/src/NetworkStatsDB.jsm +++ b/dom/network/src/NetworkStatsDB.jsm @@ -13,6 +13,7 @@ const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components; Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://gre/modules/IndexedDBHelper.jsm"); +Cu.importGlobalProperties(["indexedDB"]); const DB_NAME = "net_stats"; const DB_VERSION = 3; diff --git a/dom/push/src/PushService.jsm b/dom/push/src/PushService.jsm index 92295580a36c..ae22aabf6fb1 100644 --- a/dom/push/src/PushService.jsm +++ b/dom/push/src/PushService.jsm @@ -23,6 +23,7 @@ Cu.import("resource://gre/modules/IndexedDBHelper.jsm"); Cu.import("resource://gre/modules/Timer.jsm"); Cu.import("resource://gre/modules/Preferences.jsm"); Cu.import("resource://gre/modules/commonjs/sdk/core/promise.js"); +Cu.importGlobalProperties(["indexedDB"]); XPCOMUtils.defineLazyModuleGetter(this, "AlarmService", "resource://gre/modules/AlarmService.jsm"); diff --git a/js/xpconnect/src/Sandbox.cpp b/js/xpconnect/src/Sandbox.cpp index fbe0c506b67a..aaeacde6ea70 100644 --- a/js/xpconnect/src/Sandbox.cpp +++ b/js/xpconnect/src/Sandbox.cpp @@ -948,8 +948,7 @@ bool xpc::GlobalProperties::Define(JSContext *cx, JS::HandleObject obj) { if (indexedDB && AccessCheck::isChrome(obj) && - (!IndexedDatabaseManager::DefineConstructors(cx, obj) || - !IndexedDatabaseManager::DefineIndexedDBGetter(cx, obj))) + !IndexedDatabaseManager::DefineIndexedDB(cx, obj)) return false; if (XMLHttpRequest && diff --git a/js/xpconnect/src/XPCRuntimeService.cpp b/js/xpconnect/src/XPCRuntimeService.cpp index 188a15c98aad..5499df49cac7 100644 --- a/js/xpconnect/src/XPCRuntimeService.cpp +++ b/js/xpconnect/src/XPCRuntimeService.cpp @@ -10,11 +10,9 @@ #include "nsDOMClassInfo.h" #include "nsIPrincipal.h" -#include "mozilla/dom/indexedDB/IndexedDatabaseManager.h" #include "mozilla/dom/workers/Workers.h" using mozilla::dom::workers::ResolveWorkerClasses; -namespace indexedDB = mozilla::dom::indexedDB; NS_INTERFACE_MAP_BEGIN(BackstagePass) NS_INTERFACE_MAP_ENTRY(nsIGlobalObject) @@ -75,14 +73,6 @@ BackstagePass::NewResolve(nsIXPConnectWrappedNative *wrapper, return NS_OK; } - *_retval = indexedDB::ResolveConstructors(cx, obj, id, &objp); - NS_ENSURE_TRUE(*_retval, NS_ERROR_FAILURE); - - if (objp) { - *objpArg = objp; - return NS_OK; - } - return NS_OK; } diff --git a/js/xpconnect/src/nsXPConnect.cpp b/js/xpconnect/src/nsXPConnect.cpp index ba6235a08c0b..f730f7e2fea0 100644 --- a/js/xpconnect/src/nsXPConnect.cpp +++ b/js/xpconnect/src/nsXPConnect.cpp @@ -515,7 +515,6 @@ nsXPConnect::InitClassesWithNewWrappedGlobal(JSContext * aJSContext, MOZ_ASSERT(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL); // Init WebIDL binding constructors wanted on all XPConnect globals. - // Additional bindings may be created lazily, see BackstagePass::NewResolve. // // XXX Please do not add any additional classes here without the approval of // the XPConnect module owner. @@ -525,12 +524,6 @@ nsXPConnect::InitClassesWithNewWrappedGlobal(JSContext * aJSContext, return UnexpectedFailure(NS_ERROR_FAILURE); } - if (nsContentUtils::IsSystemPrincipal(aPrincipal) && - !IndexedDatabaseManager::DefineIndexedDBLazyGetter(aJSContext, - global)) { - return UnexpectedFailure(NS_ERROR_FAILURE); - } - wrappedGlobal.forget(_retval); return NS_OK; } diff --git a/testing/mochitest/b2g-desktop.json b/testing/mochitest/b2g-desktop.json index e35b43faa6de..e5c102931487 100644 --- a/testing/mochitest/b2g-desktop.json +++ b/testing/mochitest/b2g-desktop.json @@ -537,7 +537,7 @@ "dom/indexedDB/test/test_filehandle_store_snapshot.html": "Bug 931116, b2g desktop specific, initial triage", "dom/indexedDB/test/test_getAll.html": "Bug 931116, b2g desktop specific, initial triage", "dom/indexedDB/test/test_get_filehandle.html": "Bug 931116, b2g desktop specific, initial triage", - "dom/indexedDB/test/test_globalObjects.html": "Bug 931116, b2g desktop specific, initial triage", + "dom/indexedDB/test/test_globalObjects_content.html": "Bug 931116, b2g desktop specific, initial triage", "dom/indexedDB/test/test_global_data.html": "Bug 931116, b2g desktop specific, initial triage", "dom/indexedDB/test/test_index_empty_keyPath.html": "Bug 931116, b2g desktop specific, initial triage", "dom/indexedDB/test/test_index_getAll.html": "Bug 931116, b2g desktop specific, initial triage",