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 that we reject syntax errors listed in property_database.js</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 onload="run()"> |
michael@0 | 12 | <p id="display"></p> |
michael@0 | 13 | <iframe id="quirks" src="data:text/html,<div id='testnode'></div>"></iframe> |
michael@0 | 14 | <div id="content" style="display: none"> |
michael@0 | 15 | |
michael@0 | 16 | <div id="testnode"></div> |
michael@0 | 17 | |
michael@0 | 18 | </div> |
michael@0 | 19 | <pre id="test"> |
michael@0 | 20 | <script class="testbody" type="text/javascript"> |
michael@0 | 21 | |
michael@0 | 22 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 23 | |
michael@0 | 24 | function check_not_accepted(decl, property, info, badval) |
michael@0 | 25 | { |
michael@0 | 26 | decl.setProperty(property, badval, ""); |
michael@0 | 27 | |
michael@0 | 28 | is(decl.getPropertyValue(property), "", |
michael@0 | 29 | "invalid value '" + badval + "' not accepted for '" + property + |
michael@0 | 30 | "' property"); |
michael@0 | 31 | |
michael@0 | 32 | if ("subproperties" in info) { |
michael@0 | 33 | for (var sidx in info.subproperties) { |
michael@0 | 34 | var subprop = info.subproperties[sidx]; |
michael@0 | 35 | is(decl.getPropertyValue(subprop), "", |
michael@0 | 36 | "invalid value '" + badval + "' not accepted for '" + property + |
michael@0 | 37 | "' property when testing subproperty '" + subprop + "'"); |
michael@0 | 38 | } |
michael@0 | 39 | } |
michael@0 | 40 | |
michael@0 | 41 | decl.removeProperty(property); |
michael@0 | 42 | } |
michael@0 | 43 | |
michael@0 | 44 | function check_value_balanced(decl, property, badval) |
michael@0 | 45 | { |
michael@0 | 46 | var goodProp = |
michael@0 | 47 | (property == "background-color") ? "color" : "background-color"; |
michael@0 | 48 | decl.cssText = goodProp + ": red; " + property + ": " + badval + "; " + |
michael@0 | 49 | goodProp + ": green"; |
michael@0 | 50 | is(decl.getPropertyValue(goodProp), "green", |
michael@0 | 51 | "invalid value '" + property + ": " + badval + |
michael@0 | 52 | "' is balanced and does not lead to parsing errors afterwards"); |
michael@0 | 53 | decl.cssText = ""; |
michael@0 | 54 | } |
michael@0 | 55 | |
michael@0 | 56 | function check_value_unbalanced(decl, property, badval) |
michael@0 | 57 | { |
michael@0 | 58 | var goodProp = |
michael@0 | 59 | (property == "background-color") ? "color" : "background-color"; |
michael@0 | 60 | decl.cssText = goodProp + ": green; " + property + ": " + badval + "; " + |
michael@0 | 61 | goodProp + ": red"; |
michael@0 | 62 | is(decl.getPropertyValue(goodProp), "green", |
michael@0 | 63 | "invalid value '" + property + ": " + badval + |
michael@0 | 64 | "' is unbalanced and absorbs what follows it"); |
michael@0 | 65 | decl.cssText = ""; |
michael@0 | 66 | } |
michael@0 | 67 | |
michael@0 | 68 | function check_empty_value_rejected(decl, emptyval, property) |
michael@0 | 69 | { |
michael@0 | 70 | var goodProp = |
michael@0 | 71 | (property == "background-color") ? "color" : "background-color"; |
michael@0 | 72 | decl.cssText = goodProp + ": red; " + property + ":" + emptyval + "; " + |
michael@0 | 73 | goodProp + ": green"; |
michael@0 | 74 | is(decl.length, 1, |
michael@0 | 75 | "empty value '" + property + ":" + emptyval + |
michael@0 | 76 | "' is not accepted"); |
michael@0 | 77 | is(decl.getPropertyValue(goodProp), "green", |
michael@0 | 78 | "empty value '" + property + ":" + emptyval + |
michael@0 | 79 | "' is balanced and does not lead to parsing errors afterwards"); |
michael@0 | 80 | decl.cssText = ""; |
michael@0 | 81 | } |
michael@0 | 82 | |
michael@0 | 83 | function run() |
michael@0 | 84 | { |
michael@0 | 85 | var gDeclaration = document.getElementById("testnode").style; |
michael@0 | 86 | var gQuirksDeclaration = document.getElementById("quirks").contentDocument |
michael@0 | 87 | .getElementById("testnode").style; |
michael@0 | 88 | |
michael@0 | 89 | for (var property in gCSSProperties) { |
michael@0 | 90 | var info = gCSSProperties[property]; |
michael@0 | 91 | |
michael@0 | 92 | check_empty_value_rejected(gDeclaration, "", property); |
michael@0 | 93 | check_empty_value_rejected(gDeclaration, " ", property); |
michael@0 | 94 | |
michael@0 | 95 | for (var idx in info.invalid_values) { |
michael@0 | 96 | check_not_accepted(gDeclaration, property, info, |
michael@0 | 97 | info.invalid_values[idx]); |
michael@0 | 98 | check_not_accepted(gQuirksDeclaration, property, info, |
michael@0 | 99 | info.invalid_values[idx]); |
michael@0 | 100 | check_value_balanced(gDeclaration, property, |
michael@0 | 101 | info.invalid_values[idx]); |
michael@0 | 102 | } |
michael@0 | 103 | |
michael@0 | 104 | if ("quirks_values" in info) { |
michael@0 | 105 | for (var quirkval in info.quirks_values) { |
michael@0 | 106 | var standardval = info.quirks_values[quirkval]; |
michael@0 | 107 | check_not_accepted(gDeclaration, property, info, quirkval); |
michael@0 | 108 | check_value_balanced(gDeclaration, property, quirkval); |
michael@0 | 109 | |
michael@0 | 110 | gQuirksDeclaration.setProperty(property, quirkval, ""); |
michael@0 | 111 | gDeclaration.setProperty(property, standardval, ""); |
michael@0 | 112 | var quirkret = gQuirksDeclaration.getPropertyValue(property); |
michael@0 | 113 | var standardret = gDeclaration.getPropertyValue(property); |
michael@0 | 114 | isnot(quirkret, "", property + ": " + quirkval + |
michael@0 | 115 | " should be accepted in quirks mode"); |
michael@0 | 116 | is(quirkret, standardret, property + ": " + quirkval + " result"); |
michael@0 | 117 | |
michael@0 | 118 | if ("subproperties" in info) { |
michael@0 | 119 | for (var sidx in info.subproperties) { |
michael@0 | 120 | var subprop = info.subproperties[sidx]; |
michael@0 | 121 | var quirksub = gQuirksDeclaration.getPropertyValue(subprop); |
michael@0 | 122 | var standardsub = gDeclaration.getPropertyValue(subprop); |
michael@0 | 123 | isnot(quirksub, "", property + ": " + quirkval + |
michael@0 | 124 | " should be accepted in quirks mode" + |
michael@0 | 125 | " when testing subproperty " + subprop); |
michael@0 | 126 | is(quirksub, standardsub, property + ": " + quirkval + " result" + |
michael@0 | 127 | " when testing subproperty " + subprop); |
michael@0 | 128 | } |
michael@0 | 129 | } |
michael@0 | 130 | |
michael@0 | 131 | gQuirksDeclaration.removeProperty(property); |
michael@0 | 132 | gDeclaration.removeProperty(property); |
michael@0 | 133 | } |
michael@0 | 134 | } |
michael@0 | 135 | |
michael@0 | 136 | for (var idx in info.unbalanced_values) { |
michael@0 | 137 | check_not_accepted(gDeclaration, property, info, |
michael@0 | 138 | info.invalid_values[idx]); |
michael@0 | 139 | check_not_accepted(gQuirksDeclaration, property, info, |
michael@0 | 140 | info.invalid_values[idx]); |
michael@0 | 141 | check_value_unbalanced(gDeclaration, property, |
michael@0 | 142 | info.unbalanced_values[idx]); |
michael@0 | 143 | } |
michael@0 | 144 | } |
michael@0 | 145 | |
michael@0 | 146 | SimpleTest.finish(); |
michael@0 | 147 | } |
michael@0 | 148 | |
michael@0 | 149 | </script> |
michael@0 | 150 | </pre> |
michael@0 | 151 | </body> |
michael@0 | 152 | </html> |