Bug 453649, globalStorage should be static, r+sr=jst

This commit is contained in:
Neil Deakin 2008-12-05 11:37:30 -05:00
parent f91cee129b
commit 5c889f92e4
3 changed files with 15 additions and 11 deletions

View File

@ -208,6 +208,7 @@ static PRLogModuleInfo* gDOMLeakPRLog;
#endif
nsIFactory *nsGlobalWindow::sComputedDOMStyleFactory = nsnull;
nsIDOMStorageList *nsGlobalWindow::sGlobalStorageList = nsnull;
static nsIEntropyCollector *gEntropyCollector = nsnull;
static PRInt32 gRefCnt = 0;
@ -780,6 +781,7 @@ void
nsGlobalWindow::ShutDown()
{
NS_IF_RELEASE(sComputedDOMStyleFactory);
NS_IF_RELEASE(sGlobalStorageList);
}
// static
@ -1003,8 +1005,6 @@ 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,8 +1036,6 @@ 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])
}
@ -6700,12 +6698,12 @@ nsGlobalWindow::GetGlobalStorage(nsIDOMStorageList ** aGlobalStorage)
NS_ENSURE_ARG_POINTER(aGlobalStorage);
#ifdef MOZ_STORAGE
if (!gGlobalStorageList) {
nsresult rv = NS_NewDOMStorageList(getter_AddRefs(gGlobalStorageList));
if (!sGlobalStorageList) {
nsresult rv = NS_NewDOMStorageList(&sGlobalStorageList);
NS_ENSURE_SUCCESS(rv, rv);
}
*aGlobalStorage = gGlobalStorageList;
*aGlobalStorage = sGlobalStorageList;
NS_IF_ADDREF(*aGlobalStorage);
return NS_OK;

View File

@ -699,9 +699,6 @@ protected:
nsCOMPtr<nsIDOMCrypto> mCrypto;
nsCOMPtr<nsIDOMPkcs11> mPkcs11;
nsCOMPtr<nsIDOMStorageList> gGlobalStorageList;
nsCOMPtr<nsISupports> mInnerWindowHolders[NS_STID_ARRAY_UBOUND];
nsCOMPtr<nsIPrincipal> mOpenerScriptPrincipal; // strong; used to determine
// whether to clear scope
@ -740,6 +737,7 @@ protected:
friend class nsDOMWindowUtils;
friend class PostMessageEvent;
static nsIFactory *sComputedDOMStyleFactory;
static nsIDOMStorageList* sGlobalStorageList;
};
/*

View File

@ -1,3 +1,6 @@
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";
@ -157,4 +160,9 @@ 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);
}