summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/css/fontfaceset-multiple-faces-download-error.html
blob: 1a782b2c3e4778b366af20256528bb82a306f9b3 (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
<html>
<head>
<script src="../js/resources/js-test-pre.js"></script>
<style>
@font-face {
    font-family: TestFont;
    src: url(../../resources/Ahem.ttf);
}

@font-face {
    font-family: TestFont;
    src: url('resources/DownLoadErrorAhem.otf');
    unicode-range: u+61-7a; /* 'a'-'z' */
}
</style>
<script>
description('Test load events for a font family consists of multiple @font-faces, including download error.');

window.jsTestIsAsync = true;

function runTests() {
    document.fonts.addEventListener('loading', onLoading);
    document.fonts.addEventListener('loadingdone', onLoadingDone);
    document.fonts.addEventListener('loadingerror', onLoadingError);
    document.fonts.ready().then(finish);

    document.fonts.load('10px TestFont', 'abc');
}

var event;
var firedEvents = [];

function onLoading(e) {
    firedEvents.push(e.type);
}

function onLoadingDone(e) {
    firedEvents.push(e.type);
    event = e;
    shouldBe("event.fontfaces.length", "1");
    shouldBeEqualToString("event.fontfaces[0].unicodeRange", "U+0-10FFFF");
    shouldBeEqualToString("event.fontfaces[0].status", "loaded");
    loadingdoneFired = true;
}

function onLoadingError(e) {
    firedEvents.push(e.type);
    event = e;
    shouldBe("event.fontfaces.length", "1");
    shouldBeEqualToString("event.fontfaces[0].unicodeRange", "U+61-7A");
    shouldBeEqualToString("event.fontfaces[0].status", "error");
    shouldBeFalse("document.fonts.check('10px TestFont', 'abc')");
}

function finish() {
    shouldBe("firedEvents", "['loading', 'loadingdone', 'loadingerror']");
    finishJSTest();
}

if (document.fonts)
    runTests();
else {
    testFailed('document.fonts does not exist');
    finishJSTest();
}
</script>
</head>
<body>
</body>
</html>