diff --git a/dom/base/nsDOMClassInfo.cpp b/dom/base/nsDOMClassInfo.cpp index d42fbb9966c..6a4ca73ee7c 100644 --- a/dom/base/nsDOMClassInfo.cpp +++ b/dom/base/nsDOMClassInfo.cpp @@ -10516,15 +10516,15 @@ nsStorage2SH::GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx, JSAutoRequest ar(cx); if (DOMStringIsNull(val)) { - *vp = JSVAL_NULL; - } - else { - JSString *str = - ::JS_NewUCStringCopyN(cx, reinterpret_cast(val.get()), - val.Length()); - NS_ENSURE_TRUE(str, NS_ERROR_OUT_OF_MEMORY); + // No such key. + *vp = JSVAL_VOID; + } else { + JSString* str = + JS_NewUCStringCopyN(cx, static_cast(val.get()), + val.Length()); + NS_ENSURE_TRUE(str, NS_ERROR_OUT_OF_MEMORY); - *vp = STRING_TO_JSVAL(str); + *vp = STRING_TO_JSVAL(str); } return NS_SUCCESS_I_DID_SOMETHING; diff --git a/dom/tests/mochitest/localstorage/test_localStorageBase.html b/dom/tests/mochitest/localstorage/test_localStorageBase.html index f9d0d231cc5..ed8ffc57a00 100644 --- a/dom/tests/mochitest/localstorage/test_localStorageBase.html +++ b/dom/tests/mochitest/localstorage/test_localStorageBase.html @@ -17,16 +17,16 @@ function startTest() is(localStorage.key(-1), null, "key() should return null for out-of-bounds access"); is(localStorage.key(1), null, "key() should return null for out-of-bounds access"); is(localStorage.getItem("nonexisting"), null, "Nonexisting item is null (getItem())"); - is(localStorage["nonexisting"], null, "Nonexisting item is null (array access)"); - is(localStorage.nonexisting, null, "Nonexisting item is null (property access)"); + is(localStorage["nonexisting"], undefined, "Nonexisting item is undefined (array access)"); + is(localStorage.nonexisting, undefined, "Nonexisting item is undefined (property access)"); localStorage.removeItem("nonexisting"); // Just check there is no exception is(typeof localStorage.getItem("nonexisting"), "object", "getItem('nonexisting') is object"); - is(typeof localStorage["nonexisting"], "object", "['nonexisting'] is object"); - is(typeof localStorage.nonexisting, "object", "nonexisting is object"); + is(typeof localStorage["nonexisting"], "undefined", "['nonexisting'] is undefined"); + is(typeof localStorage.nonexisting, "undefined", "nonexisting is undefined"); is(typeof localStorage.getItem("nonexisting2"), "object", "getItem('nonexisting2') is object"); - is(typeof localStorage["nonexisting2"], "object", "['nonexisting2'] is object"); - is(typeof localStorage.nonexisting2, "object", "nonexisting2 is object"); + is(typeof localStorage["nonexisting2"], "undefined", "['nonexisting2'] is undefined"); + is(typeof localStorage.nonexisting2, "undefined", "nonexisting2 is undefined"); var mozStorageChangedReceived = 0; var localStorageCopy = localStorage; @@ -50,11 +50,11 @@ function startTest() localStorage.removeItem("empty"); is(localStorage.length, 0, "The storage has no keys"); is(localStorage.getItem("empty"), null, "empty item is null (getItem())"); - is(localStorage["empty"], null, "empty item is null (array access)"); - is(localStorage.empty, null, "empty item is null (property access)"); + is(localStorage["empty"], undefined, "empty item is undefined (array access)"); + is(localStorage.empty, undefined, "empty item is undefined (property access)"); is(typeof localStorage.getItem("empty"), "object", "getItem('empty') is object"); - is(typeof localStorage["empty"], "object", "['empty'] is object"); - is(typeof localStorage.empty, "object", "empty is object"); + is(typeof localStorage["empty"], "undefined", "['empty'] is undefined"); + is(typeof localStorage.empty, "undefined", "empty is undefined"); // add one key, check it is there localStorage.setItem("key1", "value1"); @@ -80,8 +80,8 @@ function startTest() is(localStorage.getItem("key1"), null, "\'key1\' removed"); is(typeof localStorage.getItem("key1"), "object", "getItem('key1') is object"); - is(typeof localStorage["key1"], "object", "['key1'] is object"); - is(typeof localStorage.key1, "object", "key1 is object"); + is(typeof localStorage["key1"], "undefined", "['key1'] is object"); + is(typeof localStorage.key1, "undefined", "key1 is object"); // add one key, check it is there localStorage.setItem("key1", "value1"); diff --git a/dom/tests/mochitest/localstorage/test_localStorageBasePrivateBrowsing.html b/dom/tests/mochitest/localstorage/test_localStorageBasePrivateBrowsing.html index 3afaabd76ff..42e7bc5cafd 100644 --- a/dom/tests/mochitest/localstorage/test_localStorageBasePrivateBrowsing.html +++ b/dom/tests/mochitest/localstorage/test_localStorageBasePrivateBrowsing.html @@ -34,16 +34,16 @@ function doTest() is(localStorage.key(-1), null, "key() should return null for out-of-bounds access"); is(localStorage.key(1), null, "key() should return null for out-of-bounds access"); is(localStorage.getItem("nonexisting"), null, "Nonexisting item is null (getItem())"); - is(localStorage["nonexisting"], null, "Nonexisting item is null (array access)"); - is(localStorage.nonexisting, null, "Nonexisting item is null (property access)"); + is(localStorage["nonexisting"], undefined, "Nonexisting item is null (array access)"); + is(localStorage.nonexisting, undefined, "Nonexisting item is null (property access)"); localStorage.removeItem("nonexisting"); // Just check there is no exception is(typeof localStorage.getItem("nonexisting"), "object", "getItem('nonexisting') is object"); - is(typeof localStorage["nonexisting"], "object", "['nonexisting'] is object"); - is(typeof localStorage.nonexisting, "object", "nonexisting is object"); + is(typeof localStorage["nonexisting"], "undefined", "['nonexisting'] is undefined"); + is(typeof localStorage.nonexisting, "undefined", "nonexisting is undefined"); is(typeof localStorage.getItem("nonexisting2"), "object", "getItem('nonexisting2') is object"); - is(typeof localStorage["nonexisting2"], "object", "['nonexisting2'] is object"); - is(typeof localStorage.nonexisting2, "object", "nonexisting2 is object"); + is(typeof localStorage["nonexisting2"], "undefined", "['nonexisting2'] is undefined"); + is(typeof localStorage.nonexisting2, "undefined", "nonexisting2 is undefined"); // add an empty-value key localStorage.setItem("empty", ""); @@ -56,11 +56,11 @@ function doTest() localStorage.removeItem("empty"); is(localStorage.length, 0, "The storage has no keys"); is(localStorage.getItem("empty"), null, "empty item is null (getItem())"); - is(localStorage["empty"], null, "empty item is null (array access)"); - is(localStorage.empty, null, "empty item is null (property access)"); + is(localStorage["empty"], null, "empty item is undefined (array access)"); + is(localStorage.empty, null, "empty item is undefined (property access)"); is(typeof localStorage.getItem("empty"), "object", "getItem('empty') is object"); - is(typeof localStorage["empty"], "object", "['empty'] is object"); - is(typeof localStorage.empty, "object", "empty is object"); + is(typeof localStorage["empty"], "undefined", "['empty'] is undefined"); + is(typeof localStorage.empty, "undefined", "empty is undefined"); // add one key, check it is there localStorage.setItem("key1", "value1"); @@ -86,8 +86,8 @@ function doTest() is(localStorage.getItem("key1"), null, "\'key1\' removed"); is(typeof localStorage.getItem("key1"), "object", "getItem('key1') is object"); - is(typeof localStorage["key1"], "object", "['key1'] is object"); - is(typeof localStorage.key1, "object", "key1 is object"); + is(typeof localStorage["key1"], "undefined", "['key1'] is undefined"); + is(typeof localStorage.key1, "undefined", "key1 is undefined"); // add one key, check it is there localStorage.setItem("key1", "value1"); diff --git a/dom/tests/mochitest/localstorage/test_localStorageBaseSessionOnly.html b/dom/tests/mochitest/localstorage/test_localStorageBaseSessionOnly.html index 44a2937a9b6..f3c803e6052 100644 --- a/dom/tests/mochitest/localstorage/test_localStorageBaseSessionOnly.html +++ b/dom/tests/mochitest/localstorage/test_localStorageBaseSessionOnly.html @@ -25,16 +25,16 @@ function startTest() is(localStorage.key(-1), null, "key() should return null for out-of-bounds access"); is(localStorage.key(1), null, "key() should return null for out-of-bounds access"); is(localStorage.getItem("nonexisting"), null, "Nonexisting item is null (getItem())"); - is(localStorage["nonexisting"], null, "Nonexisting item is null (array access)"); - is(localStorage.nonexisting, null, "Nonexisting item is null (property access)"); + is(localStorage["nonexisting"], undefined, "Nonexisting item is undefined (array access)"); + is(localStorage.nonexisting, undefined, "Nonexisting item is undefined (property access)"); localStorage.removeItem("nonexisting"); // Just check there is no exception is(typeof localStorage.getItem("nonexisting"), "object", "getItem('nonexisting') is object"); - is(typeof localStorage["nonexisting"], "object", "['nonexisting'] is object"); - is(typeof localStorage.nonexisting, "object", "nonexisting is object"); + is(typeof localStorage["nonexisting"], "undefined", "['nonexisting'] is undefined"); + is(typeof localStorage.nonexisting, "undefined", "nonexisting is undefined"); is(typeof localStorage.getItem("nonexisting2"), "object", "getItem('nonexisting2') is object"); - is(typeof localStorage["nonexisting2"], "object", "['nonexisting2'] is object"); - is(typeof localStorage.nonexisting2, "object", "nonexisting2 is object"); + is(typeof localStorage["nonexisting2"], "undefined", "['nonexisting2'] is undefined"); + is(typeof localStorage.nonexisting2, "undefined", "nonexisting2 is undefined"); // add an empty-value key localStorage.setItem("empty", ""); @@ -47,11 +47,11 @@ function startTest() localStorage.removeItem("empty"); is(localStorage.length, 0, "The storage has no keys"); is(localStorage.getItem("empty"), null, "empty item is null (getItem())"); - is(localStorage["empty"], null, "empty item is null (array access)"); - is(localStorage.empty, null, "empty item is null (property access)"); + is(localStorage["empty"], undefined, "empty item is undefined (array access)"); + is(localStorage.empty, undefined, "empty item is undefined (property access)"); is(typeof localStorage.getItem("empty"), "object", "getItem('empty') is object"); - is(typeof localStorage["empty"], "object", "['empty'] is object"); - is(typeof localStorage.empty, "object", "empty is object"); + is(typeof localStorage["empty"], "undefined", "['empty'] is undefined"); + is(typeof localStorage.empty, "undefined", "empty is undefined"); // add one key, check it is there localStorage.setItem("key1", "value1"); @@ -77,8 +77,8 @@ function startTest() is(localStorage.getItem("key1"), null, "\'key1\' removed"); is(typeof localStorage.getItem("key1"), "object", "getItem('key1') is object"); - is(typeof localStorage["key1"], "object", "['key1'] is object"); - is(typeof localStorage.key1, "object", "key1 is object"); + is(typeof localStorage["key1"], "undefined", "['key1'] is undefined"); + is(typeof localStorage.key1, "undefined", "key1 is undefined"); // add one key, check it is there localStorage.setItem("key1", "value1"); diff --git a/dom/tests/mochitest/sessionstorage/test_sessionStorageBase.html b/dom/tests/mochitest/sessionstorage/test_sessionStorageBase.html index 8fd29e269f2..e23aba011e9 100644 --- a/dom/tests/mochitest/sessionstorage/test_sessionStorageBase.html +++ b/dom/tests/mochitest/sessionstorage/test_sessionStorageBase.html @@ -22,16 +22,16 @@ function startTest() is(sessionStorage.key(-1), null, "key() should return null for out-of-bounds access"); is(sessionStorage.key(1), null, "key() should return null for out-of-bounds access"); is(sessionStorage.getItem("nonexisting"), null, "Nonexisting item is null (getItem())"); - is(sessionStorage["nonexisting"], null, "Nonexisting item is null (array access)"); - is(sessionStorage.nonexisting, null, "Nonexisting item is null (property access)"); + is(sessionStorage["nonexisting"], undefined, "Nonexisting item is undefined (array access)"); + is(sessionStorage.nonexisting, undefined, "Nonexisting item is undefined (property access)"); sessionStorage.removeItem("nonexisting"); // Just check there is no exception is(typeof sessionStorage.getItem("nonexisting"), "object", "getItem('nonexisting') is object"); - is(typeof sessionStorage["nonexisting"], "object", "['nonexisting'] is object"); - is(typeof sessionStorage.nonexisting, "object", "nonexisting is object"); + is(typeof sessionStorage["nonexisting"], "undefined", "['nonexisting'] is undefined"); + is(typeof sessionStorage.nonexisting, "undefined", "nonexisting is undefined"); is(typeof sessionStorage.getItem("nonexisting2"), "object", "getItem('nonexisting2') is object"); - is(typeof sessionStorage["nonexisting2"], "object", "['nonexisting2'] is object"); - is(typeof sessionStorage.nonexisting2, "object", "nonexisting2 is object"); + is(typeof sessionStorage["nonexisting2"], "undefined", "['nonexisting2'] is undefined"); + is(typeof sessionStorage.nonexisting2, "undefined", "nonexisting2 is undefined"); var mozStorageChangedReceived = 0; var sessionStorageCopy = sessionStorage; @@ -55,11 +55,11 @@ function startTest() sessionStorage.removeItem("empty"); is(sessionStorage.length, 0, "The storage has no keys"); is(sessionStorage.getItem("empty"), null, "empty item is null (getItem())"); - is(sessionStorage["empty"], null, "empty item is null (array access)"); - is(sessionStorage.empty, null, "empty item is null (property access)"); + is(sessionStorage["empty"], undefined, "empty item is undefined (array access)"); + is(sessionStorage.empty, undefined, "empty item is undefined (property access)"); is(typeof sessionStorage.getItem("empty"), "object", "getItem('empty') is object"); - is(typeof sessionStorage["empty"], "object", "['empty'] is object"); - is(typeof sessionStorage.empty, "object", "empty is object"); + is(typeof sessionStorage["empty"], "undefined", "['empty'] is undefined"); + is(typeof sessionStorage.empty, "undefined", "empty is undefined"); // add one key, check it is there sessionStorage.setItem("key1", "value1"); @@ -85,8 +85,8 @@ function startTest() is(sessionStorage.getItem("key1"), null, "\'key1\' removed"); is(typeof sessionStorage.getItem("key1"), "object", "getItem('key1') is object"); - is(typeof sessionStorage["key1"], "object", "['key1'] is object"); - is(typeof sessionStorage.key1, "object", "key1 is object"); + is(typeof sessionStorage["key1"], "undefined", "['key1'] is undefined"); + is(typeof sessionStorage.key1, "undefined", "key1 is undefined"); // add one key, check it is there sessionStorage.setItem("key1", "value1");