summaryrefslogtreecommitdiffstats
path: root/LayoutTests/storage/domstorage/events/resources/eventTestHarness.js
blob: 8f15c31d06fe9c48e157f9d9588b6fb3e566dd5a (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
51
if (window.layoutTestController) {
    layoutTestController.dumpAsText();
    layoutTestController.waitUntilDone();
}

iframe = document.createElement("IFRAME");
iframe.src = "about:blank";
document.body.appendChild(iframe);
iframe.contentWindow.document.body.innerText = "Nothing to see here.";

storageEventList = new Array();
iframe.contentWindow.onstorage = function (e) {
    window.parent.storageEventList.push(e);
}

function runAfterStorageEvents(callback) {
    var currentCount = storageEventList.length;
    function onTimeout() {
        if (currentCount != storageEventList.length)
            runAfterStorageEvents(callback);
        else
            callback();
    }
    setTimeout(onTimeout, 0);
}

function testStorages(testCallback)
{
    // When we're done testing LocalStorage, this is run.
    function allDone()
    {
        debug("");
        debug("");
        window.successfullyParsed = true;
        isSuccessfullyParsed();
        debug("");
        if (window.layoutTestController)
            layoutTestController.notifyDone()
    }

    // When we're done testing with SessionStorage, this is run.
    function runLocalStorage()
    {
        debug("");
        debug("");
        testCallback("localStorage", allDone);
    }

    // First run the test with SessionStorage.
    testCallback("sessionStorage", runLocalStorage);
}