gecko/testing/web-platform/tests/webstorage/storage_builtins.js
James Graham 3dfd6c1bac Bug 945222 - Initial import of web-platform-tests testsuite 1/4: test data
--HG--
extra : rebase_source : d635a4f39c587d4d381b486dd63de747865b77a2
2014-09-04 12:48:31 +01:00

16 lines
766 B
JavaScript

function test_storage_builtins(aStorage) {
test(function() {
aStorage.clear();
assert_equals(aStorage.length, 0, "aStorage.length");
var builtins = ["key", "getItem", "setItem", "removeItem", "clear"];
var origBuiltins = builtins.map(function(b) { return Storage.prototype[b]; });
assert_array_equals(builtins.map(function(b) { return aStorage[b]; }), origBuiltins, "a");
builtins.forEach(function(b) { aStorage[b] = b; });
assert_array_equals(builtins.map(function(b) { return aStorage[b]; }), origBuiltins, "b");
assert_array_equals(builtins.map(function(b) { return aStorage.getItem(b); }), builtins, "c");
assert_equals(aStorage.length, builtins.length, "aStorage.length");
});
}