summaryrefslogtreecommitdiffstats
path: root/LayoutTests/http/tests/appcache/cyrillic-uri.html
blob: c86a26144bd4504b7f486bd0dfea27305be095b6 (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
<html manifest="resources/cyrillic-uri.manifest">
<head>
<meta charset="koi8-r">
</head>
<body>
<p>Test that non-ASCII URIs work correctly in cache manifests.</p>
<p>Should be a series of PASS messages, followed with DONE.</p>
<div id=result></div>

<script>
if (window.layoutTestController) {
    layoutTestController.dumpAsText();
    layoutTestController.waitUntilDone();
}

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

function load(url)
{
    var req = new XMLHttpRequest;
    req.open("GET", url, false);
    req.send("");
    return req.responseText;
}

function canLoad(url)
{
    try {
        var req = new XMLHttpRequest;
        req.open("GET", url, false);
        req.send("");
        return true;
    } catch (ex) {
        return false;
    }
}

function shouldBeLoadable(url)
{
    log((canLoad(url) ? "PASS: " : "FAIL: ") + url);
}

function test()
{
    // Path is always UTF-8.
    shouldBeLoadable("resources/intercept/cached-ðÒÏ×ÅÒËÁ");
    shouldBeLoadable("resources/intercept/cached-%D0%9F%D1%80%D0%BE%D0%B2%D0%B5%D1%80%D0%BA%D0%B0");
    shouldBeLoadable("resources/intercept/cached2-ðÒÏ×ÅÒËÁ");
    shouldBeLoadable("resources/intercept/cached2-%D0%9F%D1%80%D0%BE%D0%B2%D0%B5%D1%80%D0%BA%D0%B0");
    shouldBeLoadable("resources/intercept/network-ðÒÏ×ÅÒËÁ-PASS");
    shouldBeLoadable("resources/intercept/network-%D0%9F%D1%80%D0%BE%D0%B2%D0%B5%D1%80%D0%BA%D0%B0-PASS");
    shouldBeLoadable("resources/does-not-exist-ðÒÏ×ÅÒËÁ");

    // To test encodings other than UTF-8, we need to simulate form submission (for XHR, Firefox
    // always uses UTF-8, even in query part).
    applicationCache.onnoupdate = null;
    applicationCache.oncached = null;
    window.addEventListener("message", frameDone, false);
    var ifr = document.createElement("iframe");
    ifr.setAttribute("src", "resources/cyrillic-uri-form.html");
    document.body.appendChild(ifr);
}

function frameDone(evt)
{
    log("DONE");
    if (window.layoutTestController)
        layoutTestController.notifyDone();
}

applicationCache.onnoupdate = function() { test() }
applicationCache.oncached = function() { test() }

applicationCache.onupdateready = function() { log("FAIL: received unexpected updateready event") }
applicationCache.onerror = function() { log("FAIL: received unexpected error event") }

</script>
</body>
</html>