Thu, 15 Jan 2015 21:03:48 +0100
Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <!-- |
michael@0 | 4 | --> |
michael@0 | 5 | <head> |
michael@0 | 6 | <title>Test for parsing, storage, and serialization of CSS @font-face descriptor values</title> |
michael@0 | 7 | <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 8 | <script type="text/javascript" src="descriptor_database.js"></script> |
michael@0 | 9 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
michael@0 | 10 | </head> |
michael@0 | 11 | <body> |
michael@0 | 12 | <p id="display"></p> |
michael@0 | 13 | <div id="content" style="display: none"> |
michael@0 | 14 | </div> |
michael@0 | 15 | <pre id="test"> |
michael@0 | 16 | <script class="testbody" type="text/javascript"> |
michael@0 | 17 | |
michael@0 | 18 | /** Test for parsing, storage, and serialization of CSS @font-face descriptor values **/ |
michael@0 | 19 | |
michael@0 | 20 | /* |
michael@0 | 21 | * For explanation of some of the more interesting tests here, see the comment |
michael@0 | 22 | * in test_value_storage.html . |
michael@0 | 23 | */ |
michael@0 | 24 | |
michael@0 | 25 | var gStyleElement = document.createElement("style"); |
michael@0 | 26 | gStyleElement.setAttribute("type", "text/css"); |
michael@0 | 27 | document.getElementsByTagName("head")[0].appendChild(gStyleElement); |
michael@0 | 28 | var gSheet = gStyleElement.sheet; |
michael@0 | 29 | gSheet.insertRule("@font-face { }", 0); |
michael@0 | 30 | var gRule = gSheet.cssRules[0]; |
michael@0 | 31 | var gDeclaration = gRule.style; |
michael@0 | 32 | |
michael@0 | 33 | function fake_set_property(descriptor, value) { |
michael@0 | 34 | gSheet.deleteRule(0); |
michael@0 | 35 | gSheet.insertRule("@font-face { " + descriptor + ": " + value + "}", 0); |
michael@0 | 36 | gRule = gSheet.cssRules[0]; |
michael@0 | 37 | gDeclaration = gRule.style; |
michael@0 | 38 | } |
michael@0 | 39 | |
michael@0 | 40 | function xfail_parse(descriptor, value) { |
michael@0 | 41 | switch (descriptor) { |
michael@0 | 42 | case "src": |
michael@0 | 43 | // not clear whether this is an error or not, so mark todo for now |
michael@0 | 44 | return value == "local(serif)"; |
michael@0 | 45 | } |
michael@0 | 46 | return false; |
michael@0 | 47 | } |
michael@0 | 48 | |
michael@0 | 49 | function test_descriptor(descriptor) |
michael@0 | 50 | { |
michael@0 | 51 | var info = gCSSFontFaceDescriptors[descriptor]; |
michael@0 | 52 | |
michael@0 | 53 | function test_value(value) { |
michael@0 | 54 | // // We don't implement SetProperty yet (bug 443978). |
michael@0 | 55 | // gDeclaration.setProperty(descriptor, value, ""); |
michael@0 | 56 | fake_set_property(descriptor, value); |
michael@0 | 57 | |
michael@0 | 58 | var idx; |
michael@0 | 59 | |
michael@0 | 60 | var step1val = gDeclaration.getPropertyValue(descriptor); |
michael@0 | 61 | var step1ser = gDeclaration.cssText; |
michael@0 | 62 | |
michael@0 | 63 | var func = xfail_parse(descriptor, value) ? todo_isnot : isnot; |
michael@0 | 64 | func(step1val, "", "setting '" + value + "' on '" + descriptor + "'"); |
michael@0 | 65 | |
michael@0 | 66 | // We don't care particularly about the whitespace or the placement of |
michael@0 | 67 | // semicolons, but for simplicity we'll test the current behavior. |
michael@0 | 68 | var expected_serialization = ""; |
michael@0 | 69 | if (step1val != "") |
michael@0 | 70 | expected_serialization = " " + descriptor + ": " + step1val + ";\n"; |
michael@0 | 71 | is(step1ser, expected_serialization, |
michael@0 | 72 | "serialization should match descriptor value"); |
michael@0 | 73 | |
michael@0 | 74 | gDeclaration.removeProperty(descriptor); |
michael@0 | 75 | // // We don't implement SetProperty yet (bug 443978). |
michael@0 | 76 | // gDeclaration.setProperty(descriptor, step1val, ""); |
michael@0 | 77 | fake_set_property(descriptor, step1val); |
michael@0 | 78 | |
michael@0 | 79 | is(gDeclaration.getPropertyValue(descriptor), step1val, |
michael@0 | 80 | "parse+serialize should be idempotent for '" + |
michael@0 | 81 | descriptor + ": " + value + "'"); |
michael@0 | 82 | |
michael@0 | 83 | gDeclaration.removeProperty(descriptor); |
michael@0 | 84 | } |
michael@0 | 85 | |
michael@0 | 86 | var idx; |
michael@0 | 87 | for (idx in info.values) |
michael@0 | 88 | test_value(info.values[idx]); |
michael@0 | 89 | } |
michael@0 | 90 | |
michael@0 | 91 | // To avoid triggering the slow script dialog, we have to test one |
michael@0 | 92 | // descriptor at a time. |
michael@0 | 93 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 94 | var descs = []; |
michael@0 | 95 | for (var desc in gCSSFontFaceDescriptors) |
michael@0 | 96 | descs.push(desc); |
michael@0 | 97 | descs = descs.reverse(); |
michael@0 | 98 | function do_one() { |
michael@0 | 99 | if (descs.length == 0) { |
michael@0 | 100 | SimpleTest.finish(); |
michael@0 | 101 | return; |
michael@0 | 102 | } |
michael@0 | 103 | test_descriptor(descs.pop()); |
michael@0 | 104 | SimpleTest.executeSoon(do_one); |
michael@0 | 105 | } |
michael@0 | 106 | SimpleTest.executeSoon(do_one); |
michael@0 | 107 | |
michael@0 | 108 | </script> |
michael@0 | 109 | </pre> |
michael@0 | 110 | </body> |
michael@0 | 111 | </html> |