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 | https://bugzilla.mozilla.org/show_bug.cgi?id=649740 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <title>Test for Bug 649740</title> |
michael@0 | 8 | <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 9 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
michael@0 | 10 | <style id="style"> |
michael@0 | 11 | </style> |
michael@0 | 12 | </head> |
michael@0 | 13 | <body> |
michael@0 | 14 | <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=649740">Mozilla Bug 649740</a> |
michael@0 | 15 | <p id="display1"></p> |
michael@0 | 16 | <p id="display2"></p> |
michael@0 | 17 | <pre id="test"> |
michael@0 | 18 | <script type="application/javascript"> |
michael@0 | 19 | |
michael@0 | 20 | /** Test for Bug 649740 **/ |
michael@0 | 21 | |
michael@0 | 22 | function condition(s) { |
michael@0 | 23 | return s.replace(/^@supports\s*/, '').replace(/ \s*{\s*}\s*$/, ''); |
michael@0 | 24 | } |
michael@0 | 25 | |
michael@0 | 26 | var styleSheetText = |
michael@0 | 27 | "@supports(color: green){ }\n" + |
michael@0 | 28 | "@supports (color: green) { }\n" + |
michael@0 | 29 | "@supports ((color: green)) { }\n" + |
michael@0 | 30 | "@supports (color: green) and (color: blue) { }\n" + |
michael@0 | 31 | "@supports ( Font: 20px serif ! Important) { }"; |
michael@0 | 32 | |
michael@0 | 33 | function runTest() { |
michael@0 | 34 | var style = document.getElementById("style"); |
michael@0 | 35 | style.textContent = styleSheetText; |
michael@0 | 36 | |
michael@0 | 37 | var sheet = style.sheet; |
michael@0 | 38 | |
michael@0 | 39 | is(condition(sheet.cssRules[0].cssText), "(color: green)"); |
michael@0 | 40 | is(condition(sheet.cssRules[1].cssText), "(color: green)"); |
michael@0 | 41 | is(condition(sheet.cssRules[2].cssText), "((color: green))"); |
michael@0 | 42 | is(condition(sheet.cssRules[3].cssText), "(color: green) and (color: blue)"); |
michael@0 | 43 | is(condition(sheet.cssRules[4].cssText), "( Font: 20px serif ! Important)"); |
michael@0 | 44 | |
michael@0 | 45 | var cs1 = getComputedStyle(document.getElementById("display1"), ""); |
michael@0 | 46 | var cs2 = getComputedStyle(document.getElementById("display2"), ""); |
michael@0 | 47 | function check_balanced_condition(condition, expected_match) { |
michael@0 | 48 | style.textContent = "#display1, #display2 { text-decoration: overline }\n" + |
michael@0 | 49 | "@supports " + condition + "{\n" + |
michael@0 | 50 | " #display1 { text-decoration: line-through }\n" + |
michael@0 | 51 | "}\n" + |
michael@0 | 52 | "#display2 { text-decoration: underline }\n"; |
michael@0 | 53 | is(cs1.textDecoration, |
michael@0 | 54 | expected_match ? "line-through" : "overline", |
michael@0 | 55 | "@supports condition \"" + condition + "\" should " + |
michael@0 | 56 | (expected_match ? "" : "NOT ") + "match"); |
michael@0 | 57 | is(cs2.textDecoration, "underline", |
michael@0 | 58 | "@supports condition \"" + condition + "\" should be balanced"); |
michael@0 | 59 | } |
michael@0 | 60 | |
michael@0 | 61 | check_balanced_condition("not (color: green)", false); |
michael@0 | 62 | check_balanced_condition("not (colour: green)", true); |
michael@0 | 63 | check_balanced_condition("not(color: green)", false); |
michael@0 | 64 | check_balanced_condition("not(colour: green)", false); |
michael@0 | 65 | check_balanced_condition("not/* */(color: green)", false); |
michael@0 | 66 | check_balanced_condition("not/* */(colour: green)", false); |
michael@0 | 67 | check_balanced_condition("not /* */ (color: green)", false); |
michael@0 | 68 | check_balanced_condition("not /* */ (colour: green)", true); |
michael@0 | 69 | check_balanced_condition("(color: green) and (color: blue)", true); |
michael@0 | 70 | check_balanced_condition("(color: green) /* */ /* */ and /* */ /* */ (color: blue)", true); |
michael@0 | 71 | check_balanced_condition("(color: green) and(color: blue)", false); |
michael@0 | 72 | check_balanced_condition("(color: green) and/* */(color: blue)", false); |
michael@0 | 73 | check_balanced_condition("(color: green)and (color: blue)", false); |
michael@0 | 74 | check_balanced_condition("(color: green) or (color: blue)", true); |
michael@0 | 75 | check_balanced_condition("(color: green) /* */ /* */ or /* */ /* */ (color: blue)", true); |
michael@0 | 76 | check_balanced_condition("(color: green) or(color: blue)", false); |
michael@0 | 77 | check_balanced_condition("(color: green) or/* */(color: blue)", false); |
michael@0 | 78 | check_balanced_condition("(color: green)or (color: blue)", false); |
michael@0 | 79 | |
michael@0 | 80 | SimpleTest.finish(); |
michael@0 | 81 | } |
michael@0 | 82 | |
michael@0 | 83 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 84 | SpecialPowers.pushPrefEnv({ "set": [["layout.css.supports-rule.enabled", true]] }, runTest); |
michael@0 | 85 | </script> |
michael@0 | 86 | </pre> |
michael@0 | 87 | </body> |
michael@0 | 88 | </html> |