Bug 740357 - Import W3C WebStorage tests; r=mayhemer

This commit is contained in:
Ms2ger 2012-05-05 11:00:04 +02:00
parent 68c19b3ac7
commit 8db1c68a9f
55 changed files with 1839 additions and 0 deletions

View File

@ -5,5 +5,59 @@
"webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-11.xml": {
"document.getElementsByClassName(): \"tricky\" compound": true
},
"webapps/WebStorage/tests/submissions/Infraware/test_event_constructor.html": {
"storageeventinit test": true
},
"webapps/WebStorage/tests/submissions/Infraware/test_storage_local_security.html": {
"storage local security test": true
},
"webapps/WebStorage/tests/submissions/Ms2ger/test_event_constructor_js.html": {
"StorageEvent constructor and nulls": true
},
"webapps/WebStorage/tests/submissions/Ms2ger/test_storage_local_getitem_js.html": {
"All 3 items should be added.": true,
"array access should be correct": true,
"getItem should be correct": true
},
"webapps/WebStorage/tests/submissions/Ms2ger/test_storage_local_in_js.html": {
"Web Storage 1": true
},
"webapps/WebStorage/tests/submissions/Ms2ger/test_storage_local_index_js.html": {
"Web Storage 1": true,
"Web Storage 2": true,
"Web Storage 3": true
},
"webapps/WebStorage/tests/submissions/Ms2ger/test_storage_local_removeitem_js.html": {
"Web Storage 2": true,
"Web Storage 3": true
},
"webapps/WebStorage/tests/submissions/Ms2ger/test_storage_session_getitem_js.html": {
"All 3 items should be added.": true,
"array access should be correct": true,
"getItem should be correct": true
},
"webapps/WebStorage/tests/submissions/Ms2ger/test_storage_session_in_js.html": {
"Web Storage 1": true
},
"webapps/WebStorage/tests/submissions/Ms2ger/test_storage_session_index_js.html": {
"Web Storage 1": true,
"Web Storage 2": true,
"Web Storage 3": true
},
"webapps/WebStorage/tests/submissions/Ms2ger/test_storage_session_removeitem_js.html": {
"Web Storage 2": true,
"Web Storage 3": true
}
}

View File

@ -1,3 +1,4 @@
DIRS += \
webapps/DOMCore/tests/submissions/Opera \
webapps/WebStorage/tests/submissions \
$(NULL)

View File

@ -1,2 +1,3 @@
https://dvcs.w3.org/hg/webapps|webapps
DOMCore/tests/submissions/Opera
WebStorage/tests/submissions

View File

@ -0,0 +1,50 @@
# THIS FILE IS AUTOGENERATED BY importTestsuite.py - DO NOT EDIT
DEPTH = ../../../../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
relativesrcdir = dom/imported-tests/webapps/WebStorage/tests/submissions/Infraware
DIRS = \
iframe \
$(NULL)
include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/rules.mk
_TESTS = \
test_event_constructor.html \
test_event_local_key.html \
test_event_local_newvalue.html \
test_event_local_oldvalue.html \
test_event_local_storagearea.html \
test_event_local_storageeventinit.html \
test_event_local_url.html \
test_event_session_key.html \
test_event_session_newvalue.html \
test_event_session_oldvalue.html \
test_event_session_storagearea.html \
test_event_session_storageeventinit.html \
test_event_session_url.html \
test_storage_local_clear.html \
test_storage_local_getitem.html \
test_storage_local_key.html \
test_storage_local_length.html \
test_storage_local_removeitem.html \
test_storage_local_security.html \
test_storage_local_setitem.html \
test_storage_session_clear.html \
test_storage_session_getitem.html \
test_storage_session_key.html \
test_storage_session_length.html \
test_storage_session_removeitem.html \
test_storage_session_setitem.html \
$(NULL)
_TESTS += \
$(NULL)
libs:: $(_TESTS)
$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)

View File

@ -0,0 +1,30 @@
# THIS FILE IS AUTOGENERATED BY importTestsuite.py - DO NOT EDIT
DEPTH = ../../../../../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
relativesrcdir = dom/imported-tests/webapps/WebStorage/tests/submissions/Infraware/iframe
DIRS = \
$(NULL)
include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/rules.mk
_TESTS = \
$(NULL)
_TESTS += \
local_change_item_iframe.html \
local_security_iframe.html \
local_set_item_clear_iframe.html \
local_set_item_iframe.html \
session_change_item_iframe.html \
session_set_item_clear_iframe.html \
session_set_item_iframe.html \
$(NULL)
libs:: $(_TESTS)
$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)

View File

@ -0,0 +1,18 @@
<!DOCTYPE HTML>
<html>
<body>
<script>
if (('localStorage' in window) && window.localStorage !== null){
try {
localStorage.setItem("name", "user1");
localStorage.setItem("name", "user2");
} catch (e) {
parent.fail("setItem method is failed.");
}
localStorage.clear();
} else {
parent.fail("localStorage is not supported.");
}
</script>
</body>
</html>

View File

@ -0,0 +1,16 @@
<!DOCTYPE HTML>
<html>
<body>
<script>
if (('localStorage' in window) && window.localStorage != null){
try {
localStorage.setItem("Security", "false");
parent.localStorage.clear();
} catch (e) {
if(e.code == e['SECURITY_ERR'])
localStorage.setItem("Security", "true");
}
}
</script>
</body>
</html>

View File

@ -0,0 +1,17 @@
<!DOCTYPE HTML>
<html>
<body>
<script>
if (('localStorage' in window) && window.localStorage !== null){
try {
localStorage.setItem("name", "user1");
} catch (e) {
parent.fail("setItem method is failed.");
}
localStorage.clear();
} else {
parent.fail("localStorage is not supported.");
}
</script>
</body>
</html>

View File

@ -0,0 +1,16 @@
<!DOCTYPE HTML>
<html>
<body>
<script>
if (('localStorage' in window) && window.localStorage !== null){
try {
localStorage.setItem("name", "user1");
} catch (e) {
parent.fail("setItem method is failed.");
}
} else {
parent.fail("localStorage is not supported.");
}
</script>
</body>
</html>

View File

@ -0,0 +1,18 @@
<!DOCTYPE HTML>
<html>
<body>
<script>
if (('sessionStorage' in window) && window.sessionStorage !== null){
try {
sessionStorage.setItem("name", "user1");
sessionStorage.setItem("name", "user2");
} catch (e) {
parent.fail("setItem method is failed.");
}
sessionStorage.clear();
} else {
parent.fail("sessionStorage is not supported.");
}
</script>
</body>
</html>

View File

@ -0,0 +1,17 @@
<!DOCTYPE HTML>
<html>
<body>
<script>
if (('sessionStorage' in window) && window.sessionStorage !== null){
try {
sessionStorage.setItem('name', 'user1');
} catch (e) {
parent.fail('setItem method is failed.');
}
sessionStorage.clear();
} else {
parent.fail('sessionStorage is not supported.');
}
</script>
</body>
</html>

View File

@ -0,0 +1,16 @@
<!DOCTYPE HTML>
<html>
<body>
<script>
if (('sessionStorage' in window) && window.sessionStorage !== null){
try {
sessionStorage.setItem('name', 'user1');
} catch (e) {
parent.fail('setItem method is failed.');
}
} else {
parent.fail('sessionStorage is not supported.');
}
</script>
</body>
</html>

View File

@ -0,0 +1,32 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>event_session_Constructor</h1>
<div id="log"></div>
<script>
test(function() {
var t = async_test("storageeventinit test");
function onStorageEvent(event) {
t.step(function() {
assert_equals(event.type, 'storage');
assert_equals(event.key, null);
assert_equals(event.oldValue, null);
assert_equals(event.newValue, null);
assert_equals(event.url, '');
assert_equals(event.storageArea, null);
});
t.done();
}
window.addEventListener('storage', onStorageEvent, false);
var event = new StorageEvent('storage');
window.dispatchEvent(event);
});
</script>
</body>
</html>

View File

@ -0,0 +1,42 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
function fail(msg) {
t.step(function() {
assert_notreached(msg);
});
t.done();
}
</script>
</head>
<body>
<h1>event_local_key</h1>
<div id="log"></div>
<script>
test(function() {
localStorage.clear();
var t = async_test("key property test of local event");
var expected = ['name', null]
function onStorageEvent(event) {
t.step(function() {
assert_equals(event.key, expected.shift());
});
if (!expected.length) {
t.done();
}
}
window.addEventListener('storage', onStorageEvent, false);
var el = document.createElement("iframe");
el.setAttribute('id', 'ifrm');
el.setAttribute('src', 'iframe/local_set_item_clear_iframe.html');
document.body.appendChild(el);
});
</script>
</body>
</html>

View File

@ -0,0 +1,42 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
function fail(msg) {
t.step(function() {
assert_notreached(msg);
});
t.done();
}
</script>
</head>
<body>
<h1>event_local_newValue</h1>
<div id="log"></div>
<script>
test(function() {
localStorage.clear();
var t = async_test("newValue property test of local event");
var expected = ['user1', 'user2', null]
function onStorageEvent(event) {
t.step(function() {
assert_equals(event.newValue, expected.shift());
});
if (!expected.length) {
t.done();
}
}
window.addEventListener('storage', onStorageEvent, false);
var el = document.createElement("iframe");
el.setAttribute('id', 'ifrm');
el.setAttribute('src', 'iframe/local_change_item_iframe.html');
document.body.appendChild(el);
});
</script>
</body>
</html>

View File

@ -0,0 +1,42 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
function fail(msg) {
t.step(function() {
assert_notreached(msg);
});
t.done();
}
</script>
</head>
<body>
<h1>event_local_oldValue</h1>
<div id="log"></div>
<script>
test(function() {
localStorage.clear();
var t = async_test("oldValue property test of local event");
var expected = [null, 'user1', null]
function onStorageEvent(event) {
t.step(function() {
assert_equals(event.oldValue, expected.shift());
});
if (!expected.length) {
t.done();
}
}
window.addEventListener('storage', onStorageEvent, false);
var el = document.createElement("iframe");
el.setAttribute('id', 'ifrm');
el.setAttribute('src', 'iframe/local_change_item_iframe.html');
document.body.appendChild(el);
});
</script>
</body>
</html>

View File

@ -0,0 +1,43 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
function fail(msg) {
t.step(function() {
assert_notreached(msg);
});
t.done();
}
</script>
</head>
<body>
<h1>event_local_storageArea</h1>
<div id="log"></div>
<script>
test(function() {
localStorage.clear();
var t = async_test("storageArea property test of local event");
function onStorageEvent(event) {
t.step(function() {
assert_equals(event.storageArea.length, 1);
var key = event.storageArea.key(0);
var value = event.storageArea.getItem(key);
assert_equals(key, "name");
assert_equals(value, "user1");
});
t.done();
}
window.addEventListener('storage', onStorageEvent, false);
var el = document.createElement("iframe");
el.setAttribute('id', 'ifrm');
el.setAttribute('src', 'iframe/local_set_item_iframe.html');
document.body.appendChild(el);
});
</script>
</body>
</html>

View File

@ -0,0 +1,39 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>event_local_StorageEventInit</h1>
<div id="log"></div>
<script>
test(function() {
var t = async_test("storageeventinit test");
function onStorageEvent(event) {
t.step(function() {
assert_equals(event.key, 'key');
assert_equals(event.oldValue, 'oldValue');
assert_equals(event.newValue, 'newValue');
assert_equals(event.url, window.location.href);
assert_equals(event.storageArea, window.localStorage);
});
t.done();
}
window.addEventListener('storage', onStorageEvent, false);
var event = new StorageEvent('storage', {
key: 'key',
oldValue: 'oldValue',
newValue: 'newValue',
url: window.location.href,
storageArea: window.localStorage
});
window.dispatchEvent(event);
});
</script>
</body>
</html>

View File

@ -0,0 +1,47 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
function fail(msg) {
t.step(function() {
assert_notreached(msg);
});
t.done();
}
</script>
</head>
<body>
<h1>event_local_url</h1>
<div id="log"></div>
<script>
test(function() {
localStorage.clear();
var t = async_test("url property test of local event");
function onStorageEvent(event) {
t.step(function() {
var url = window.location.href;
var pos = url.lastIndexOf("/");
if (pos != -1) {
url = url.substr(0, pos + 1);
url = url + "iframe/local_set_item_iframe.html";
}
assert_equals(event.url, url);
});
t.done();
}
window.addEventListener('storage', onStorageEvent, false);
var el = document.createElement("iframe");
el.setAttribute('id', 'ifrm');
el.setAttribute('src', 'iframe/local_set_item_iframe.html');
document.body.appendChild(el);
});
</script>
</body>
</html>

View File

@ -0,0 +1,42 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
function fail(msg) {
t.step(function() {
assert_notreached(msg);
});
t.done();
}
</script>
</head>
<body>
<h1>event_session_key</h1>
<div id="log"></div>
<script>
test(function() {
sessionStorage.clear();
var t = async_test("key property test of session event");
var expected = ['name', null]
function onStorageEvent(event) {
t.step(function() {
assert_equals(event.key, expected.shift());
});
if (!expected.length) {
t.done();
}
}
window.addEventListener('storage', onStorageEvent, false);
var el = document.createElement("iframe");
el.setAttribute('id', 'ifrm');
el.setAttribute('src', 'iframe/session_set_item_clear_iframe.html');
document.body.appendChild(el);
});
</script>
</body>
</html>

View File

@ -0,0 +1,42 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
function fail(msg) {
t.step(function() {
assert_notreached(msg);
});
t.done();
}
</script>
</head>
<body>
<h1>event_session_newValue</h1>
<div id="log"></div>
<script>
test(function() {
sessionStorage.clear();
var t = async_test("newvalue property test of session event");
var expected = ['user1', 'user2', null]
function onStorageEvent(event) {
t.step(function() {
assert_equals(event.newValue, expected.shift());
});
if (!expected.length) {
t.done();
}
}
window.addEventListener('storage', onStorageEvent, false);
var el = document.createElement("iframe");
el.setAttribute('id', 'ifrm');
el.setAttribute('src', 'iframe/session_change_item_iframe.html');
document.body.appendChild(el);
});
</script>
</body>
</html>

View File

@ -0,0 +1,42 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
function fail(msg) {
t.step(function() {
assert_notreached(msg);
});
t.done();
}
</script>
</head>
<body>
<h1>event_session_oldValue</h1>
<div id="log"></div>
<script>
test(function() {
sessionStorage.clear();
var t = async_test("oldvalue property test of session event");
var expected = [null, 'user1', null]
function onStorageEvent(event) {
t.step(function() {
assert_equals(event.oldValue, expected.shift());
});
if (!expected.length) {
t.done();
}
}
window.addEventListener('storage', onStorageEvent, false);
var el = document.createElement("iframe");
el.setAttribute('id', 'ifrm');
el.setAttribute('src', 'iframe/session_change_item_iframe.html');
document.body.appendChild(el);
});
</script>
</body>
</html>

View File

@ -0,0 +1,43 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
function fail(msg) {
t.step(function() {
assert_notreached(msg);
});
t.done();
}
</script>
</head>
<body>
<h1>event_session_storageArea</h1>
<div id="log"></div>
<script>
test(function() {
var t = async_test("storageArea property test of session event");
function onStorageEvent(event) {
t.step(function() {
assert_equals(event.storageArea.length, 1);
var key = event.storageArea.key(0);
var value = event.storageArea.getItem(key);
assert_equals(key, "name");
assert_equals(value, "user1");
});
t.done();
}
window.addEventListener('storage', onStorageEvent, false);
var el = document.createElement("iframe");
el.setAttribute('id', 'ifrm');
el.setAttribute('src', 'iframe/session_set_item_iframe.html');
document.body.appendChild(el);
});
</script>
</body>
</html>

View File

@ -0,0 +1,39 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>event_session_StorageEventInit</h1>
<div id="log"></div>
<script>
test(function() {
var t = async_test("storageeventinit test");
function onStorageEvent(event) {
t.step(function() {
assert_equals(event.key, 'key');
assert_equals(event.oldValue, 'oldValue');
assert_equals(event.newValue, 'newValue');
assert_equals(event.url, window.location.href);
assert_equals(event.storageArea, window.sessionStorage);
});
t.done();
}
window.addEventListener('storage', onStorageEvent, false);
var event = new StorageEvent('storage', {
key: 'key',
oldValue: 'oldValue',
newValue: 'newValue',
url: window.location.href,
storageArea: window.sessionStorage
});
window.dispatchEvent(event);
});
</script>
</body>
</html>

View File

@ -0,0 +1,47 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
function fail(msg) {
t.step(function() {
assert_notreached(msg);
});
t.done();
}
</script>
</head>
<body>
<h1>event_session_url</h1>
<div id="log"></div>
<script>
test(function() {
sessionStorage.clear();
var t = async_test("url property test of session event");
function onStorageEvent(event) {
t.step(function() {
var url = window.location.href;
var pos = url.lastIndexOf("/");
if (pos != -1) {
url = url.substr(0, pos + 1);
url = url + "iframe/session_set_item_iframe.html";
}
assert_equals(event.url, url);
});
t.done();
}
window.addEventListener('storage', onStorageEvent, false);
var el = document.createElement("iframe");
el.setAttribute('id', 'ifrm');
el.setAttribute('src', 'iframe/session_set_item_iframe.html');
document.body.appendChild(el);
});
</script>
</body>
</html>

View File

@ -0,0 +1,25 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>storage_local_clear</h1>
<div id="log"></div>
<script>
test(function() {
localStorage.clear();
localStorage.setItem("name", "user1");
assert_not_equals(localStorage.getItem("name"), null);
assert_equals(localStorage.length, 1);
localStorage.clear();
assert_equals(localStorage.getItem("name"), null, "localStorage.getItem('name')")
assert_equals(localStorage.length, 0, "localStorage.length")
});
</script>
</body>
</html>

View File

@ -0,0 +1,23 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>storage_local_getItem</h1>
<div id="log"></div>
<script>
test(function() {
localStorage.clear();
localStorage.setItem("name", "user1");
localStorage.setItem("age", "20");
test(function() {
assert_equals(localStorage.getItem("name"), "user1", "localStorage.getItem('name')")
assert_equals(localStorage.getItem("unknown"), null, "localStorage.getItem('unknown')")
}, "getItem method test")
});
</script>
</body>
</html>

View File

@ -0,0 +1,40 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>storage_local_key</h1>
<div id="log"></div>
<script>
test(function() {
localStorage.clear();
localStorage.setItem("name", "user1");
localStorage.setItem("age", "20");
localStorage.setItem("a", "1");
localStorage.setItem("b", "2");
var keys = ["name", "age", "a", "b"];
function doTest(index) {
test(function() {
var key = localStorage.key(index);
assert_not_equals(key, null);
assert_true(keys.indexOf(key) >= 0,
"Unexpected key " + key + " found.");
}, "key(" + index + ") should return the right thing.");
}
for (var i = 0; i < keys.length; ++i) {
doTest(i);
doTest(i + 0x100000000);
}
test(function() {
assert_equals(localStorage.key(-1), null, "localStorage.key(-1)");
assert_equals(localStorage.key(4), null, "localStorage.key(4)");
}, "key() should return null for out-of-range arguments.");
});
</script>
</body>
</html>

View File

@ -0,0 +1,23 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>storage_local_length</h1>
<div id="log"></div>
<script>
test(function() {
localStorage.clear();
assert_equals(localStorage.length, 0, "localStorage.length")
localStorage.setItem("name", "user1");
localStorage.setItem("age", "20");
assert_equals(localStorage.length, 2, "localStorage.length")
});
</script>
</body>
</html>

View File

@ -0,0 +1,23 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>storage_local_removeItem</h1>
<div id="log"></div>
<script>
test(function() {
localStorage.clear();
localStorage.setItem("name", "user1");
assert_equals(localStorage.getItem("name"), "user1");
localStorage.removeItem("name");
localStorage.removeItem("unknown");
assert_equals(localStorage.getItem("name"), null, "localStorage.getItem('name')")
});
</script>
</body>
</html>

View File

@ -0,0 +1,32 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>storage_local_security</h1>
<iframe id="frame" src="iframe/local_security_iframe.html" style="width: 0px; height: 0px;"></iframe>
<div id="log"></div>
<script>
var t1 = async_test('storage local security test');
iframeWindow = document.getElementById('frame').contentWindow;
setTimeout(function(){
try {
var errFlag =iframeWindow.localStorage.getItem("Security");
t1.step(function() {
assert_equals(errFlag, "true", 'SECURITY_ERR error is not raised.')
});
} catch (e) {
t1.step(function() {
assert_unreached('Error is raised.');
});
}
t1.done();
}, 500);
</script>
</body>
</html>

View File

@ -0,0 +1,19 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>storage_local_setItem</h1>
<div id="log"></div>
<script>
test(function() {
localStorage.clear();
localStorage.setItem("name", "user1");
assert_equals(localStorage.length, 1, "localStorage.setItem")
});
</script>
</body>
</html>

View File

@ -0,0 +1,25 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>storage_session_clear</h1>
<div id="log"></div>
<script>
test(function() {
sessionStorage.clear();
sessionStorage.setItem("name", "user1");
assert_not_equals(sessionStorage.getItem("name"), null);
assert_equals(sessionStorage.length, 1);
sessionStorage.clear();
assert_equals(sessionStorage.getItem("name"), null, "sessionStorage.getItem('name')")
assert_equals(sessionStorage.length, 0, "sessionStorage.length")
});
</script>
</body>
</html>

View File

@ -0,0 +1,23 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>storage_session_getItem</h1>
<div id="log"></div>
<script>
test(function() {
sessionStorage.clear();
sessionStorage.setItem("name", "user1");
sessionStorage.setItem("age", "20");
test(function() {
assert_equals(sessionStorage.getItem("name"), "user1", "sessionStorage.getItem('name')")
assert_equals(sessionStorage.getItem("unknown"), null, "sessionStorage.getItem('unknown')")
}, "getItem method test")
});
</script>
</body>
</html>

View File

@ -0,0 +1,40 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>storage_session_key</h1>
<div id="log"></div>
<script>
test(function() {
sessionStorage.clear();
sessionStorage.setItem("name", "user1");
sessionStorage.setItem("age", "20");
sessionStorage.setItem("a", "1");
sessionStorage.setItem("b", "2");
var keys = ["name", "age", "a", "b"];
function doTest(index) {
test(function() {
var key = sessionStorage.key(index);
assert_not_equals(key, null);
assert_true(keys.indexOf(key) >= 0,
"Unexpected key " + key + " found.");
}, "key(" + index + ") should return the right thing.");
}
for (var i = 0; i < keys.length; ++i) {
doTest(i);
doTest(i + 0x100000000);
}
test(function() {
assert_equals(sessionStorage.key(-1), null, "sessionStorage.key(-1)");
assert_equals(sessionStorage.key(4), null, "sessionStorage.key(4)");
}, "key() should return null for out-of-range arguments.");
});
</script>
</body>
</html>

View File

@ -0,0 +1,23 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>storage_session_length</h1>
<div id="log"></div>
<script>
test(function() {
sessionStorage.clear();
assert_equals(sessionStorage.length, 0, "sessionStorage.length")
sessionStorage.setItem("name", "user1");
sessionStorage.setItem("age", "20");
assert_equals(sessionStorage.length, 2, "sessionStorage.length")
});
</script>
</body>
</html>

View File

@ -0,0 +1,23 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>storage_session_removeItem</h1>
<div id="log"></div>
<script>
test(function() {
sessionStorage.clear();
sessionStorage.setItem("name", "user1");
assert_equals(sessionStorage.getItem("name"), "user1");
sessionStorage.removeItem("name");
sessionStorage.removeItem("unknown");
assert_equals(sessionStorage.getItem("name"), null, "sessionStorage.getItem('name')")
});
</script>
</body>
</html>

View File

@ -0,0 +1,19 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>storage_session_setItem</h1>
<div id="log"></div>
<script>
test(function() {
sessionStorage.clear();
sessionStorage.setItem("name", "user1");
assert_equals(sessionStorage.length, 1, "localStorage.setItem")
});
</script>
</body>
</html>

View File

@ -0,0 +1,16 @@
# THIS FILE IS AUTOGENERATED BY importTestsuite.py - DO NOT EDIT
DEPTH = ../../../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
relativesrcdir = dom/imported-tests/webapps/WebStorage/tests/submissions
DIRS = \
Infraware \
Ms2ger \
$(NULL)
include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/rules.mk

View File

@ -0,0 +1,38 @@
# THIS FILE IS AUTOGENERATED BY importTestsuite.py - DO NOT EDIT
DEPTH = ../../../../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
relativesrcdir = dom/imported-tests/webapps/WebStorage/tests/submissions/Ms2ger
DIRS = \
$(NULL)
include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/rules.mk
_TESTS = \
test_event_constructor_js.html \
test_storage_local_clear_js.html \
test_storage_local_getitem_js.html \
test_storage_local_index_js.html \
test_storage_local_in_js.html \
test_storage_local_length_js.html \
test_storage_local_removeitem_js.html \
test_storage_local_setitem_js.html \
test_storage_session_clear_js.html \
test_storage_session_getitem_js.html \
test_storage_session_index_js.html \
test_storage_session_in_js.html \
test_storage_session_length_js.html \
test_storage_session_removeitem_js.html \
test_storage_session_setitem_js.html \
$(NULL)
_TESTS += \
$(NULL)
libs:: $(_TESTS)
$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)

View File

@ -0,0 +1,37 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>event_Constructor</h1>
<div id="log"></div>
<script>
test(function() {
var t = async_test("StorageEvent constructor and nulls");
function onStorageEvent(event) {
t.step(function() {
assert_equals(event.type, 'storage', 'type');
assert_equals(event.key, null, 'key');
assert_equals(event.oldValue, null, 'oldValue');
assert_equals(event.newValue, null, 'newValue');
assert_equals(event.url, 'null', 'url');
assert_equals(event.storageArea, null, 'storageArea');
});
t.done();
}
window.addEventListener('storage', onStorageEvent, false);
var event = new StorageEvent('storage', {
key: null,
oldValue: null,
newValue: null,
url: null
});
window.dispatchEvent(event);
});
</script>
</body>
</html>

View File

@ -0,0 +1,25 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>storage_local_clear</h1>
<div id="log"></div>
<script>
test(function() {
localStorage.clear();
localStorage.setItem("name", "user1");
assert_not_equals(localStorage.name, undefined);
assert_equals(localStorage.length, 1);
localStorage.clear();
assert_equals(localStorage.name, undefined, "localStorage.name")
assert_equals(localStorage.length, 0, "localStorage.length")
});
</script>
</body>
</html>

View File

@ -0,0 +1,38 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>storage_local_getItem</h1>
<div id="log"></div>
<script>
test(function() {
localStorage.clear();
localStorage.setItem("undefined", "foo");
localStorage.setItem("null", "bar");
localStorage.setItem("", "baz");
test(function() {
assert_equals(localStorage.length, 3);
}, "All 3 items should be added.");
test(function() {
assert_equals(localStorage["unknown"], undefined, "localStorage['unknown']")
assert_equals(localStorage["undefined"], "foo", "localStorage['undefined']")
assert_equals(localStorage["null"], "bar", "localStorage['null']")
assert_equals(localStorage[undefined], "foo", "localStorage[undefined]")
assert_equals(localStorage[null], "bar", "localStorage[null]")
assert_equals(localStorage[""], "baz", "localStorage['']")
}, "array access should be correct");
test(function() {
assert_equals(localStorage.getItem("undefined"), "foo", "localStorage.getItem('undefined')")
assert_equals(localStorage.getItem("null"), "bar", "localStorage.getItem('null')")
assert_equals(localStorage.getItem(undefined), "foo", "localStorage.getItem(undefined)")
assert_equals(localStorage.getItem(null), "bar", "localStorage.getItem(null)")
assert_equals(localStorage.getItem(""), "baz", "localStorage.getItem('')")
}, "getItem should be correct")
});
</script>
</body>
</html>

View File

@ -0,0 +1,29 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>storage_local_in</h1>
<div id="log"></div>
<script>
test(function() {
localStorage.clear();
assert_false("name" in localStorage);
localStorage["name"] = "user1";
assert_true("name" in localStorage);
});
test(function() {
localStorage.clear();
assert_false("name" in localStorage);
localStorage.setItem("name", "user1");
assert_true("name" in localStorage);
assert_equals(localStorage.name, "user1");
localStorage.removeItem("name");
assert_false("name" in localStorage);
});
</script>
</body>
</html>

View File

@ -0,0 +1,36 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>storage_local_index</h1>
<div id="log"></div>
<script>
test(function() {
localStorage.clear();
localStorage["name"] = "user1";
localStorage["age"] = "42";
test(function() {
assert_equals(localStorage[-1], undefined);
assert_equals(localStorage[0], undefined);
assert_equals(localStorage[1], undefined);
assert_equals(localStorage[2], undefined);
})
test(function() {
assert_equals(localStorage["-1"], undefined);
assert_equals(localStorage["0"], undefined);
assert_equals(localStorage["1"], undefined);
assert_equals(localStorage["2"], undefined);
})
localStorage.setItem(1, "number");
test(function() {
assert_equals(localStorage[1], "number");
assert_equals(localStorage["1"], "number");
})
});
</script>
</body>
</html>

View File

@ -0,0 +1,23 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>storage_local_length</h1>
<div id="log"></div>
<script>
test(function() {
localStorage.clear();
assert_equals(localStorage.length, 0, "localStorage.length")
localStorage["name"] = "user1";
localStorage["age"] = "20";
assert_equals(localStorage.length, 2, "localStorage.length")
});
</script>
</body>
</html>

View File

@ -0,0 +1,37 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>storage_local_removeItem</h1>
<div id="log"></div>
<script>
test(function() {
localStorage.clear();
localStorage.setItem("name", "user1");
assert_equals(localStorage.getItem("name"), "user1");
test(function() {
delete localStorage["name"];
delete localStorage["unknown"];
assert_equals(localStorage.getItem("name"), null, "localStorage.getItem('name')")
});
test(function() {
localStorage.setItem("null", "test");
assert_true("null" in localStorage);
localStorage.removeItem(null, "test");
assert_false("null" in localStorage);
});
test(function() {
localStorage.setItem("undefined", "test");
assert_true("undefined" in localStorage);
localStorage.removeItem(undefined, "test");
assert_false("undefined" in localStorage);
});
});
</script>
</body>
</html>

View File

@ -0,0 +1,119 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>storage_local_setItem</h1>
<div id="log"></div>
<script>
var test_error = { name: "test" };
test(function() {
localStorage.clear();
test(function() {
assert_false("name" in localStorage);
assert_false("age" in localStorage);
});
test(function() {
localStorage["name"] = "user1";
assert_true("name" in localStorage);
assert_equals(localStorage.length, 1, "localStorage.length")
assert_equals(localStorage.getItem("name"), "user1");
assert_equals(localStorage["name"], "user1");
});
test(function() {
localStorage["name"] = "user2";
assert_true("name" in localStorage);
assert_equals(localStorage.length, 1, "localStorage.length")
assert_equals(localStorage.getItem("name"), "user2");
assert_equals(localStorage["name"], "user2");
});
test(function() {
localStorage.setItem("name", "user3");
assert_true("name" in localStorage);
assert_equals(localStorage.length, 1, "localStorage.length")
assert_equals(localStorage.getItem("name"), "user3");
assert_equals(localStorage["name"], "user3");
});
test(function() {
localStorage.setItem("age", null);
assert_true("age" in localStorage);
assert_equals(localStorage.length, 2, "localStorage.length")
assert_equals(localStorage.getItem("age"), "null");
assert_equals(localStorage["age"], "null");
});
test(function() {
localStorage["age"] = null;
assert_true("age" in localStorage);
assert_equals(localStorage.length, 2, "localStorage.length")
assert_equals(localStorage.getItem("age"), "null");
assert_equals(localStorage["age"], "null");
});
test(function() {
localStorage.setItem("age", undefined);
assert_true("age" in localStorage);
assert_equals(localStorage.length, 2, "localStorage.length")
assert_equals(localStorage.getItem("age"), "undefined");
assert_equals(localStorage["age"], "undefined");
});
test(function() {
localStorage["age"] = undefined;
assert_true("age" in localStorage);
assert_equals(localStorage.length, 2, "localStorage.length")
assert_equals(localStorage.getItem("age"), "undefined");
assert_equals(localStorage["age"], "undefined");
});
test(function() {
assert_throws(test_error, function() {
localStorage.setItem("age",
{ toString: function() { throw test_error; } });
});
assert_true("age" in localStorage);
assert_equals(localStorage.length, 2, "localStorage.length")
assert_equals(localStorage.getItem("age"), "undefined");
assert_equals(localStorage["age"], "undefined");
});
test(function() {
assert_throws(test_error, function() {
localStorage["age"] =
{ toString: function() { throw test_error; } };
});
assert_true("age" in localStorage);
assert_equals(localStorage.length, 2, "localStorage.length")
assert_equals(localStorage.getItem("age"), "undefined");
assert_equals(localStorage["age"], "undefined");
});
test(function() {
localStorage.setItem(undefined, "test");
assert_true("undefined" in localStorage);
assert_equals(localStorage.length, 3, "localStorage.length")
assert_equals(localStorage.getItem("undefined"), "test");
assert_equals(localStorage["undefined"], "test");
});
test(function() {
localStorage[undefined] = "test2";
assert_true("undefined" in localStorage);
assert_equals(localStorage.length, 3, "localStorage.length")
assert_equals(localStorage.getItem("undefined"), "test2");
assert_equals(localStorage["undefined"], "test2");
});
test(function() {
localStorage.setItem(null, "test");
assert_true("null" in localStorage);
assert_equals(localStorage.length, 4, "localStorage.length")
assert_equals(localStorage.getItem("null"), "test");
assert_equals(localStorage["null"], "test");
});
test(function() {
localStorage[null] = "test2";
assert_true("null" in localStorage);
assert_equals(localStorage.length, 4, "localStorage.length")
assert_equals(localStorage.getItem("null"), "test2");
assert_equals(localStorage["null"], "test2");
});
});
</script>
</body>
</html>

View File

@ -0,0 +1,25 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>storage_session_clear</h1>
<div id="log"></div>
<script>
test(function() {
sessionStorage.clear();
sessionStorage.setItem("name", "user1");
assert_not_equals(sessionStorage.name, undefined);
assert_equals(sessionStorage.length, 1);
sessionStorage.clear();
assert_equals(sessionStorage.name, undefined, "sessionStorage.name")
assert_equals(sessionStorage.length, 0, "sessionStorage.length")
});
</script>
</body>
</html>

View File

@ -0,0 +1,38 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>storage_session_getItem</h1>
<div id="log"></div>
<script>
test(function() {
sessionStorage.clear();
sessionStorage.setItem("undefined", "foo");
sessionStorage.setItem("null", "bar");
sessionStorage.setItem("", "baz");
test(function() {
assert_equals(sessionStorage.length, 3);
}, "All 3 items should be added.");
test(function() {
assert_equals(sessionStorage["unknown"], undefined, "sessionStorage['unknown']")
assert_equals(sessionStorage["undefined"], "foo", "sessionStorage['undefined']")
assert_equals(sessionStorage["null"], "bar", "sessionStorage['null']")
assert_equals(sessionStorage[undefined], "foo", "sessionStorage[undefined]")
assert_equals(sessionStorage[null], "bar", "sessionStorage[null]")
assert_equals(sessionStorage[""], "baz", "sessionStorage['']")
}, "array access should be correct");
test(function() {
assert_equals(sessionStorage.getItem("undefined"), "foo", "sessionStorage.getItem('undefined')")
assert_equals(sessionStorage.getItem("null"), "bar", "sessionStorage.getItem('null')")
assert_equals(sessionStorage.getItem(undefined), "foo", "sessionStorage.getItem(undefined)")
assert_equals(sessionStorage.getItem(null), "bar", "sessionStorage.getItem(null)")
assert_equals(sessionStorage.getItem(""), "baz", "sessionStorage.getItem('')")
}, "getItem should be correct")
});
</script>
</body>
</html>

View File

@ -0,0 +1,29 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>storage_session_in</h1>
<div id="log"></div>
<script>
test(function() {
sessionStorage.clear();
assert_false("name" in sessionStorage);
sessionStorage["name"] = "user1";
assert_true("name" in sessionStorage);
});
test(function() {
sessionStorage.clear();
assert_false("name" in sessionStorage);
sessionStorage.setItem("name", "user1");
assert_true("name" in sessionStorage);
assert_equals(sessionStorage.name, "user1");
sessionStorage.removeItem("name");
assert_false("name" in sessionStorage);
});
</script>
</body>
</html>

View File

@ -0,0 +1,36 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>storage_session_index</h1>
<div id="log"></div>
<script>
test(function() {
sessionStorage.clear();
sessionStorage["name"] = "user1";
sessionStorage["age"] = "42";
test(function() {
assert_equals(sessionStorage[-1], undefined);
assert_equals(sessionStorage[0], undefined);
assert_equals(sessionStorage[1], undefined);
assert_equals(sessionStorage[2], undefined);
})
test(function() {
assert_equals(sessionStorage["-1"], undefined);
assert_equals(sessionStorage["0"], undefined);
assert_equals(sessionStorage["1"], undefined);
assert_equals(sessionStorage["2"], undefined);
})
sessionStorage.setItem(1, "number");
test(function() {
assert_equals(sessionStorage[1], "number");
assert_equals(sessionStorage["1"], "number");
})
});
</script>
</body>
</html>

View File

@ -0,0 +1,23 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>storage_session_length</h1>
<div id="log"></div>
<script>
test(function() {
sessionStorage.clear();
assert_equals(sessionStorage.length, 0, "sessionStorage.length")
sessionStorage["name"] = "user1";
sessionStorage["age"] = "20";
assert_equals(sessionStorage.length, 2, "sessionStorage.length")
});
</script>
</body>
</html>

View File

@ -0,0 +1,37 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>storage_session_removeItem</h1>
<div id="log"></div>
<script>
test(function() {
sessionStorage.clear();
sessionStorage.setItem("name", "user1");
assert_equals(sessionStorage.getItem("name"), "user1");
test(function() {
delete sessionStorage["name"];
delete sessionStorage["unknown"];
assert_equals(sessionStorage.getItem("name"), null, "sessionStorage.getItem('name')")
});
test(function() {
sessionStorage.setItem("null", "test");
assert_true("null" in sessionStorage);
sessionStorage.removeItem(null, "test");
assert_false("null" in sessionStorage);
});
test(function() {
sessionStorage.setItem("undefined", "test");
assert_true("undefined" in sessionStorage);
sessionStorage.removeItem(undefined, "test");
assert_false("undefined" in sessionStorage);
});
});
</script>
</body>
</html>

View File

@ -0,0 +1,119 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Web Storage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>storage_session_setItem</h1>
<div id="log"></div>
<script>
var test_error = { name: "test" };
test(function() {
sessionStorage.clear();
test(function() {
assert_false("name" in sessionStorage);
assert_false("age" in sessionStorage);
});
test(function() {
sessionStorage["name"] = "user1";
assert_true("name" in sessionStorage);
assert_equals(sessionStorage.length, 1, "sessionStorage.length")
assert_equals(sessionStorage.getItem("name"), "user1");
assert_equals(sessionStorage["name"], "user1");
});
test(function() {
sessionStorage["name"] = "user2";
assert_true("name" in sessionStorage);
assert_equals(sessionStorage.length, 1, "sessionStorage.length")
assert_equals(sessionStorage.getItem("name"), "user2");
assert_equals(sessionStorage["name"], "user2");
});
test(function() {
sessionStorage.setItem("name", "user3");
assert_true("name" in sessionStorage);
assert_equals(sessionStorage.length, 1, "sessionStorage.length")
assert_equals(sessionStorage.getItem("name"), "user3");
assert_equals(sessionStorage["name"], "user3");
});
test(function() {
sessionStorage.setItem("age", null);
assert_true("age" in sessionStorage);
assert_equals(sessionStorage.length, 2, "sessionStorage.length")
assert_equals(sessionStorage.getItem("age"), "null");
assert_equals(sessionStorage["age"], "null");
});
test(function() {
sessionStorage["age"] = null;
assert_true("age" in sessionStorage);
assert_equals(sessionStorage.length, 2, "sessionStorage.length")
assert_equals(sessionStorage.getItem("age"), "null");
assert_equals(sessionStorage["age"], "null");
});
test(function() {
sessionStorage.setItem("age", undefined);
assert_true("age" in sessionStorage);
assert_equals(sessionStorage.length, 2, "sessionStorage.length")
assert_equals(sessionStorage.getItem("age"), "undefined");
assert_equals(sessionStorage["age"], "undefined");
});
test(function() {
sessionStorage["age"] = undefined;
assert_true("age" in sessionStorage);
assert_equals(sessionStorage.length, 2, "sessionStorage.length")
assert_equals(sessionStorage.getItem("age"), "undefined");
assert_equals(sessionStorage["age"], "undefined");
});
test(function() {
assert_throws(test_error, function() {
sessionStorage.setItem("age",
{ toString: function() { throw test_error; } });
});
assert_true("age" in sessionStorage);
assert_equals(sessionStorage.length, 2, "sessionStorage.length")
assert_equals(sessionStorage.getItem("age"), "undefined");
assert_equals(sessionStorage["age"], "undefined");
});
test(function() {
assert_throws(test_error, function() {
sessionStorage["age"] =
{ toString: function() { throw test_error; } };
});
assert_true("age" in sessionStorage);
assert_equals(sessionStorage.length, 2, "sessionStorage.length")
assert_equals(sessionStorage.getItem("age"), "undefined");
assert_equals(sessionStorage["age"], "undefined");
});
test(function() {
sessionStorage.setItem(undefined, "test");
assert_true("undefined" in sessionStorage);
assert_equals(sessionStorage.length, 3, "sessionStorage.length")
assert_equals(sessionStorage.getItem("undefined"), "test");
assert_equals(sessionStorage["undefined"], "test");
});
test(function() {
sessionStorage[undefined] = "test2";
assert_true("undefined" in sessionStorage);
assert_equals(sessionStorage.length, 3, "sessionStorage.length")
assert_equals(sessionStorage.getItem("undefined"), "test2");
assert_equals(sessionStorage["undefined"], "test2");
});
test(function() {
sessionStorage.setItem(null, "test");
assert_true("null" in sessionStorage);
assert_equals(sessionStorage.length, 4, "sessionStorage.length")
assert_equals(sessionStorage.getItem("null"), "test");
assert_equals(sessionStorage["null"], "test");
});
test(function() {
sessionStorage[null] = "test2";
assert_true("null" in sessionStorage);
assert_equals(sessionStorage.length, 4, "sessionStorage.length")
assert_equals(sessionStorage.getItem("null"), "test2");
assert_equals(sessionStorage["null"], "test2");
});
});
</script>
</body>
</html>