4 <title>Test for Bug 42342 - Font download error for an @font-face rule invalidates other @font-face rules for the same font-family</title>
11 /* Test 0: Download sucess */
14 src: local('Courier');
18 src: url('../../resources/Ahem.otf');
19 unicode-range: u+69; /* 'i' */
22 /* Test 1: Download error */
25 src: local('Courier');
29 src: url('resources/DownLoadErrorAhem.otf');
30 unicode-range: u+69; /* 'i' */
33 /* Test 2: Download error followed by success */
36 src: local('Courier');
40 src: url('resources/DownLoadErrorAhem.otf'), url('../../resources/Ahem.otf');
41 unicode-range: u+69; /* 'i' */
44 /* Test 3: Download error followed by existing local font */
47 src: local('Courier');
51 src: url('resources/DownLoadErrorAhem.otf'), local(Arial);
52 unicode-range: u+69; /* 'i' */
56 <script src="../js/resources/js-test-pre.js"></script>
58 <body onload="runTest()">
59 <div id="description"></div>
60 <div id="tests"></div>
62 <div id="console"></div>
65 if (window.layoutTestController)
66 window.layoutTestController.waitUntilDone();
68 description("If no font resources are available for an @font-face rule due to download errors, the rule must be ignored but others must remain in effect.");
70 var testsElement = document.getElementById("tests");
75 var expectedResults = [
76 // Effective font family for "i" and "j"
78 ["Courier", "Courier"],
83 function createAndAppendSpan(id, subId, fontFamily)
85 var span = document.createElement("span");
87 span.className = "test";
88 span.style.fontFamily = fontFamily;
89 span.innerHTML = testStrings[subId];
90 testsElement.appendChild(span);
91 testsElement.appendChild(document.createTextNode(" " + id));
92 testsElement.appendChild(document.createElement("br"));
95 function testId(mainTestId, subTestId)
97 return "test_" + mainTestId + "_" + subTestId;
100 function refId(mainTestId, subTestId)
102 return "ref_" + mainTestId + "_" + subTestId;
107 for (var mainTestId = 0; mainTestId < expectedResults.length; mainTestId++) {
108 for (var subTestId = 0; subTestId < testStrings.length; subTestId++) {
109 shouldBe("document.getElementById('" + testId(mainTestId, subTestId) + "').offsetWidth", "document.getElementById('" + refId(mainTestId, subTestId) + "').offsetWidth");
112 if (window.layoutTestController)
113 window.layoutTestController.notifyDone();
116 for (var mainTestId = 0; mainTestId < expectedResults.length; mainTestId++) {
117 for (var subTestId = 0; subTestId < testStrings.length; subTestId++) {
118 var testFontFamily = "myfont_" + mainTestId;
119 createAndAppendSpan(testId(mainTestId, subTestId), subTestId, testFontFamily);
120 var refFontFamily = expectedResults[mainTestId][subTestId];
121 createAndAppendSpan(refId(mainTestId, subTestId), subTestId, refFontFamily);
123 testsElement.appendChild(document.createElement("br"));
126 // We need to run tests after the font downloading succeeded or failed.
127 // Using a timer is not ideal, but there seems to be no better options.
130 window.setTimeout(test, 200);
133 <script src="../js/resources/js-test-post.js"></script>