summaryrefslogtreecommitdiffstats
path: root/LayoutTests/http/tests/appcache/origin-quota.html
blob: a7322fd934e33adfb670619f81bd0364dc3f7d96 (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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<html>
<head>
<script>

// Helpers.

function log(message) {
    document.getElementById("console").innerHTML += message + "<br>";
}

// Start and end.

function startTest() {
    if (window.layoutTestController) {
        layoutTestController.clearAllApplicationCaches();
        layoutTestController.dumpApplicationCacheDelegateCallbacks();
        layoutTestController.setApplicationCacheOriginQuota(20*1024);
        layoutTestController.dumpAsText();
        layoutTestController.waitUntilDone();
    }

    addFirstIFrame();
}

function finishTest() {
    if (window.layoutTestController)
        layoutTestController.notifyDone();
}

// Stages.

function addIFrameWithContinuation(src, continuation) {
    window.onmessage = continuation;
    var iframe = document.createElement("iframe");
    iframe.src = src;
    document.body.appendChild(iframe);
}

function addFirstIFrame() {
    // Expected to succeed.
    addIFrameWithContinuation("resources/quota-origin-iframe-1.html", function(event) {
        log(event.data);
        addSecondIFrame();
    });
}

function addSecondIFrame() {
    // Expected to fail, then increase the quota.
    // NOTE: When this fails, the exceed callback will automatically increase it back to the default quota size.
    addIFrameWithContinuation("resources/quota-origin-iframe-2.html", function(event) {
        log(event.data);
        addThirdIFrame();
    });
}

function addThirdIFrame() {
    // Expected to succeed.
    addIFrameWithContinuation("resources/quota-origin-iframe-3.html", function(event) {
        log(event.data);
        finishTest();
    });
}

</script>
</head>
<body onload="startTest()">
<p>This test checks that per-origin application cache quotas are enforced.</p>
<p>
    This test sets the quota for the origin to 20kb, and attempts to fill
    it up with 2 iframes that are 13kb each. The application cache download
    process should fail on the 2nd iframe and the UI Delegate should be
    informed of the exceeded quota. Increasing the size to 40kb. A 3rd
    iframe is added, which should succeed.
</p>
<pre id="console"></pre>
</body>
</html>