Wed, 31 Dec 2014 13:27:57 +0100
Ignore runtime configuration files generated during quality assurance.
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <!-- |
michael@0 | 4 | --> |
michael@0 | 5 | <head> |
michael@0 | 6 | <title>Test handling of garbage at the end of CSS declarations</title> |
michael@0 | 7 | <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 8 | <script type="text/javascript" src="property_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 | |
michael@0 | 15 | <div id="testnode"></div> |
michael@0 | 16 | |
michael@0 | 17 | </div> |
michael@0 | 18 | <pre id="test"> |
michael@0 | 19 | <script class="testbody" type="text/javascript"> |
michael@0 | 20 | |
michael@0 | 21 | /** Test for correct ExpectEndProperty calls in CSS parser **/ |
michael@0 | 22 | |
michael@0 | 23 | /* |
michael@0 | 24 | * Inspired by review comments on bug 378217. |
michael@0 | 25 | * |
michael@0 | 26 | * The original idea was to test that ExpectEndProperty calls are made |
michael@0 | 27 | * in the correct places in the CSS parser so that we don't accept |
michael@0 | 28 | * garbage at the end of property values. |
michael@0 | 29 | * |
michael@0 | 30 | * However, there's actually other code (in ParseDeclaration) that |
michael@0 | 31 | * ensures that we don't accept garbage. |
michael@0 | 32 | * |
michael@0 | 33 | * Despite that, I'm checking it in anyway, since it caught an infinite |
michael@0 | 34 | * loop in the patch for bug 435441. |
michael@0 | 35 | */ |
michael@0 | 36 | |
michael@0 | 37 | var gElement = document.getElementById("testnode"); |
michael@0 | 38 | var gDeclaration = gElement.style; |
michael@0 | 39 | |
michael@0 | 40 | /* |
michael@0 | 41 | * This lists properties where garbage identifiers are allowed at the |
michael@0 | 42 | * end, with values in property_database.js that are exceptions that |
michael@0 | 43 | * should be tested anyway. "inherit", "initial" and "unset" are always |
michael@0 | 44 | * tested. |
michael@0 | 45 | */ |
michael@0 | 46 | var gAllowsExtra = { |
michael@0 | 47 | "counter-increment": { "none": true }, |
michael@0 | 48 | "counter-reset": { "none": true }, |
michael@0 | 49 | "font-family": {}, |
michael@0 | 50 | "font": { "caption": true, "icon": true, "menu": true, "message-box": true, |
michael@0 | 51 | "small-caption": true, "status-bar": true }, |
michael@0 | 52 | "voice-family": {}, |
michael@0 | 53 | }; |
michael@0 | 54 | |
michael@0 | 55 | /* These are the reverse of the above list; they're the unusual values |
michael@0 | 56 | that do allow extra keywords afterwards */ |
michael@0 | 57 | var gAllowsExtraUnusual = { |
michael@0 | 58 | "transition": { "all": true, "0s": true, "0s 0s": true, "ease": true, |
michael@0 | 59 | "1s 2s linear": true, "1s linear 2s": true, |
michael@0 | 60 | "linear 1s 2s": true, "linear 1s": true, |
michael@0 | 61 | "1s linear": true, "1s 2s": true, "2s 1s": true, |
michael@0 | 62 | "linear": true, "1s": true, "2s": true, |
michael@0 | 63 | "ease-in-out": true, "2s ease-in": true, |
michael@0 | 64 | "ease-out 2s": true, "1s width, 2s": true }, |
michael@0 | 65 | "animation": { "none": true, "0s": true, "ease": true, |
michael@0 | 66 | "normal": true, "running": true, "1.0": true, |
michael@0 | 67 | "1s 2s linear": true, "1s linear 2s": true, |
michael@0 | 68 | "linear 1s 2s": true, "linear 1s": true, |
michael@0 | 69 | "1s linear": true, "1s 2s": true, "2s 1s": true, |
michael@0 | 70 | "linear": true, "1s": true, "2s": true, |
michael@0 | 71 | "ease-in-out": true, "2s ease-in": true, |
michael@0 | 72 | "ease-out 2s": true, "1s bounce, 2s": true, |
michael@0 | 73 | "1s bounce, 2s none": true }, |
michael@0 | 74 | "font-family": { "inherit": true, "initial": true, "unset": true } |
michael@0 | 75 | }; |
michael@0 | 76 | |
michael@0 | 77 | gAllowsExtraUnusual["-moz-transition"] = gAllowsExtraUnusual["transition"]; |
michael@0 | 78 | gAllowsExtraUnusual["-moz-animation"] = gAllowsExtraUnusual["animation"]; |
michael@0 | 79 | |
michael@0 | 80 | function test_property(property) |
michael@0 | 81 | { |
michael@0 | 82 | var info = gCSSProperties[property]; |
michael@0 | 83 | |
michael@0 | 84 | function test_value(value) { |
michael@0 | 85 | if (property in gAllowsExtra && |
michael@0 | 86 | value != "inherit" && value != "initial" && value != "unset" && |
michael@0 | 87 | !(value in gAllowsExtra[property])) { |
michael@0 | 88 | return; |
michael@0 | 89 | } |
michael@0 | 90 | if (property in gAllowsExtraUnusual && |
michael@0 | 91 | value in gAllowsExtraUnusual[property]) { |
michael@0 | 92 | return; |
michael@0 | 93 | } |
michael@0 | 94 | |
michael@0 | 95 | // Include non-identifier characters in the garbage |
michael@0 | 96 | // in case |value| would also be valid with a <custom-ident> added. |
michael@0 | 97 | gElement.setAttribute("style", property + ": " + value + " +blah/"); |
michael@0 | 98 | if ("subproperties" in info) { |
michael@0 | 99 | for (idx in info.subproperties) { |
michael@0 | 100 | var subprop = info.subproperties[idx]; |
michael@0 | 101 | is(gDeclaration.getPropertyValue(subprop), "", |
michael@0 | 102 | ["expected garbage ignored after '", property, ": ", value, |
michael@0 | 103 | "' when looking at subproperty '", subprop, "'"].join("")); |
michael@0 | 104 | } |
michael@0 | 105 | } else { |
michael@0 | 106 | is(gDeclaration.getPropertyValue(property), "", |
michael@0 | 107 | ["expected garbage ignored after '", property, ": ", value, |
michael@0 | 108 | "'"].join("")); |
michael@0 | 109 | } |
michael@0 | 110 | } |
michael@0 | 111 | |
michael@0 | 112 | var idx; |
michael@0 | 113 | test_value("inherit"); |
michael@0 | 114 | test_value("initial"); |
michael@0 | 115 | if (SpecialPowers.getBoolPref("layout.css.unset-value.enabled")) |
michael@0 | 116 | test_value("unset"); |
michael@0 | 117 | for (idx in info.initial_values) |
michael@0 | 118 | test_value(info.initial_values[idx]); |
michael@0 | 119 | for (idx in info.other_values) |
michael@0 | 120 | test_value(info.other_values[idx]); |
michael@0 | 121 | } |
michael@0 | 122 | |
michael@0 | 123 | // To avoid triggering the slow script dialog, we have to test one |
michael@0 | 124 | // property at a time. |
michael@0 | 125 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 126 | var props = []; |
michael@0 | 127 | for (var prop in gCSSProperties) |
michael@0 | 128 | props.push(prop); |
michael@0 | 129 | props = props.reverse(); |
michael@0 | 130 | function do_one() { |
michael@0 | 131 | if (props.length == 0) { |
michael@0 | 132 | SimpleTest.finish(); |
michael@0 | 133 | return; |
michael@0 | 134 | } |
michael@0 | 135 | test_property(props.pop()); |
michael@0 | 136 | SimpleTest.executeSoon(do_one); |
michael@0 | 137 | } |
michael@0 | 138 | SimpleTest.executeSoon(do_one); |
michael@0 | 139 | |
michael@0 | 140 | </script> |
michael@0 | 141 | </pre> |
michael@0 | 142 | </body> |
michael@0 | 143 | </html> |