HTML5 tests - storage

Spec Apple documentation

The note() function writes the returned value to the <div> below.

This page tests localStorage and sessionStorage.

To test the storage event, open the second test page in another frame or window and change a value in this page. The event should fire in the other page.

Set the name and value for your storage test:

Test scripts

setItem()

localStorage.setItem($('name').value,$('value').value);
sessionStorage.setItem($('name').value,$('value').value);

getItem()

note(localStorage.getItem($('name').value));
note(sessionStorage.getItem($('name').value));

key()

This test throws an error when there are no keys.

note(localStorage.key(0));
note(sessionStorage.key(0));

removeItem()

localStorage.removeItem($('name').value);
sessionStorage.removeItem($('name').value);

clear()

localStorage.clear();
sessionStorage.clear();

length

note(localStorage.length);
note(sessionStorage.length);