summaryrefslogtreecommitdiffstats
path: root/LayoutTests/http/tests/cookies/third-party-cookie-relaxing.html
blob: df9c4b94efd802cb3dae715569ce8d569dc78095 (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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<html>
<head>
<script src="resources/resetCookies.js"></script>
<script>
resetCookies();

if (window.layoutTestController) {
    layoutTestController.dumpAsText();
    layoutTestController.waitUntilDone();
}

window.onmessage = function(evt)
{
    if (evt.data != "done") {
        alert("Unexpected message: " + evt.data);
        return;
    }
    
    runNextTestOrFinish();
}

function allowAllCookies()
{
    alert("Allowing all cookies");
    if (window.layoutTestController)
        layoutTestController.setAlwaysAcceptCookies(true);
    runNextTestOrFinish();
}

function restrictCookies()
{
    alert("Restricting to first party only cookies");
    if (window.layoutTestController)
        layoutTestController.setAlwaysAcceptCookies(false);
    runNextTestOrFinish();
}

function deleteAllCookies()
{
    sendXHR("deleteCookies");
}

function echoCookies()
{
    window.frames[0].postMessage("showCookies", "*");
}

function sendXHR(command)
{
    window.frames[0].postMessage("sendXHR " + command, "*");
}

function setFooCookie()
{
    sendXHR("setFooCookie");
}

function setFooAndBarCookies()
{
    sendXHR("setFooAndBarCookie");
}

function startNewTest()
{
    alert("\n");
    runNextTestOrFinish();
}

var currentFunction = 0;
var functions = new Array(
    startNewTest, allowAllCookies, deleteAllCookies, echoCookies, restrictCookies, setFooCookie, echoCookies,
    startNewTest, allowAllCookies, deleteAllCookies, echoCookies, restrictCookies, setFooAndBarCookies, echoCookies,
    startNewTest, allowAllCookies, deleteAllCookies, echoCookies, setFooCookie, echoCookies, restrictCookies, deleteAllCookies, echoCookies,
    startNewTest, allowAllCookies, deleteAllCookies, echoCookies, setFooCookie, echoCookies, restrictCookies, setFooAndBarCookies, echoCookies
);

function runNextTestOrFinish()
{
    if (currentFunction >= functions.length) {
        if (window.layoutTestController) {
            resetCookies();
            window.frames[0].postMessage("resetCookiesAndNotifyDone", "*");
        }
        return;
    }
    
    var functionToRun = currentFunction++;
    functions[functionToRun]();
}

</script>
</head>
<body onload="runNextTestOrFinish();">
<iframe id='testFrame' src="http://localhost:8000/cookies/resources/third-party-cookie-relaxing-iframe.html"></iframe>
</body>
</html>