summaryrefslogtreecommitdiffstats
path: root/LayoutTests/storage/domstorage/script-tests/remove-item.js
blob: 62731f1a04a0f83ef6efc65809430c6a2860b183 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
description("Test .removeItem within DOM Storage.");

function test(storageString)
{
    storage = eval(storageString);
    if (!storage) {
        testFailed(storageString + " DOES NOT exist");
        return;
    }

    debug("Testing " + storageString);

    evalAndLog("storage.clear()");
    shouldBe("storage.length", "0");

    debug("");
    shouldBeUndefined("storage.foo1");
    evalAndLog("storage.foo1 = 'bar'");
    shouldBeEqualToString("storage.foo1", "bar");
    evalAndLog("storage.removeItem('foo1')");
    shouldBeUndefined("storage.foo1");
    evalAndLog("storage.removeItem('foo1')");
    shouldBeUndefined("storage.foo1");

    debug("");
    shouldBeUndefined("storage['foo2']");
    evalAndLog("storage['foo2'] = 'bar'");
    shouldBeEqualToString("storage['foo2']", "bar");
    evalAndLog("storage.removeItem('foo2')");
    shouldBeUndefined("storage['foo2']");
    evalAndLog("storage.removeItem('foo2')");
    shouldBeUndefined("storage['foo2']");

    debug("");
    shouldBeNull("storage.getItem('foo3')");
    evalAndLog("storage.setItem('foo3', 'bar')");
    shouldBeEqualToString("storage.getItem('foo3')", "bar");
    evalAndLog("storage.removeItem('foo3')");
    shouldBeNull("storage.getItem('foo3')");
    evalAndLog("storage.removeItem('foo3')");
    shouldBeNull("storage.getItem('foo3')");
}

test("sessionStorage");
debug("");
debug("");
test("localStorage");

window.successfullyParsed = true;
isSuccessfullyParsed();