diff --git a/dom/src/base/nsGlobalWindow.cpp b/dom/src/base/nsGlobalWindow.cpp index 9364446d61f..e8971bac51e 100644 --- a/dom/src/base/nsGlobalWindow.cpp +++ b/dom/src/base/nsGlobalWindow.cpp @@ -208,7 +208,6 @@ static PRLogModuleInfo* gDOMLeakPRLog; #endif nsIFactory *nsGlobalWindow::sComputedDOMStyleFactory = nsnull; -nsIDOMStorageList *nsGlobalWindow::sGlobalStorageList = nsnull; static nsIEntropyCollector *gEntropyCollector = nsnull; static PRInt32 gRefCnt = 0; @@ -781,7 +780,6 @@ void nsGlobalWindow::ShutDown() { NS_IF_RELEASE(sComputedDOMStyleFactory); - NS_IF_RELEASE(sGlobalStorageList); } // static @@ -1005,6 +1003,8 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsGlobalWindow) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mScriptContexts[i]) } + NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(gGlobalStorageList) + for (PRUint32 i = 0; i < NS_STID_ARRAY_UBOUND; ++i) { NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mInnerWindowHolders[i]) } @@ -1036,6 +1036,8 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsGlobalWindow) NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mScriptContexts[i]) } + NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(gGlobalStorageList) + for (PRUint32 i = 0; i < NS_STID_ARRAY_UBOUND; ++i) { NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mInnerWindowHolders[i]) } @@ -6698,12 +6700,12 @@ nsGlobalWindow::GetGlobalStorage(nsIDOMStorageList ** aGlobalStorage) NS_ENSURE_ARG_POINTER(aGlobalStorage); #ifdef MOZ_STORAGE - if (!sGlobalStorageList) { - nsresult rv = NS_NewDOMStorageList(&sGlobalStorageList); + if (!gGlobalStorageList) { + nsresult rv = NS_NewDOMStorageList(getter_AddRefs(gGlobalStorageList)); NS_ENSURE_SUCCESS(rv, rv); } - *aGlobalStorage = sGlobalStorageList; + *aGlobalStorage = gGlobalStorageList; NS_IF_ADDREF(*aGlobalStorage); return NS_OK; diff --git a/dom/src/base/nsGlobalWindow.h b/dom/src/base/nsGlobalWindow.h index 8e8d6137a9d..95fd573d96b 100644 --- a/dom/src/base/nsGlobalWindow.h +++ b/dom/src/base/nsGlobalWindow.h @@ -699,6 +699,9 @@ protected: nsCOMPtr mCrypto; nsCOMPtr mPkcs11; + + nsCOMPtr gGlobalStorageList; + nsCOMPtr mInnerWindowHolders[NS_STID_ARRAY_UBOUND]; nsCOMPtr mOpenerScriptPrincipal; // strong; used to determine // whether to clear scope @@ -737,7 +740,6 @@ protected: friend class nsDOMWindowUtils; friend class PostMessageEvent; static nsIFactory *sComputedDOMStyleFactory; - static nsIDOMStorageList* sGlobalStorageList; }; /* diff --git a/dom/tests/mochitest/chrome/domstorage_global.js b/dom/tests/mochitest/chrome/domstorage_global.js index eb741f38907..b0d3458d46a 100644 --- a/dom/tests/mochitest/chrome/domstorage_global.js +++ b/dom/tests/mochitest/chrome/domstorage_global.js @@ -1,6 +1,3 @@ -ok(globalStorage === this["globalStorage"], "globalStorage is global check 1") -ok(globalStorage === window["globalStorage"], "globalStorage is global check 2") - function test_DOMStorage_global() { var currentDomain = "mozilla.com"; @@ -160,9 +157,4 @@ function test_DOMStorage_global_Item(storage, key, expectedvalue, expectedlength function is(left, right, str) { window.opener.wrappedJSObject.SimpleTest.is(left, right, str); -} - -function ok(val, str) -{ - window.opener.wrappedJSObject.SimpleTest.ok(val, str); -} +} \ No newline at end of file