summaryrefslogtreecommitdiffstats
path: root/LayoutTests/storage/domstorage/script-tests/clear.js
blob: bf6e5f39ad60f1d67707cec59a6ea195f6fac1e4 (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
description("Test basic dom storage .clear() functionality.");

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

    debug("Testing " + storageString);

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

    evalAndLog("storage['FOO'] = 'MyFOO'");
    evalAndLog("storage['BAR'] = 'MyBar'");
    shouldBe("storage.length", "2");
    shouldBeEqualToString("storage['FOO']", "MyFOO");
    shouldBeEqualToString("storage['BAR']", "MyBar");

    evalAndLog("storage.clear()");
    shouldBe("storage.length", "0");
    shouldBe("storage['FOO']", "undefined");  // FIXME: Wait...shouldn't this be null?
    shouldBe("storage['BAR']", "undefined");  // ditto
}

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

window.successfullyParsed = true;
isSuccessfullyParsed();