Wed, 31 Dec 2014 07:16:47 +0100
Revert simplistic fix pending revisit of Mozilla integration attempt.
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <head> |
michael@0 | 4 | <title>Test for CSS Selectors</title> |
michael@0 | 5 | <!-- |
michael@0 | 6 | Separate from test_selectors.html so we don't need to deal with |
michael@0 | 7 | waiting for the binding document to load. |
michael@0 | 8 | --> |
michael@0 | 9 | <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 10 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
michael@0 | 11 | <style type="text/css"> |
michael@0 | 12 | |
michael@0 | 13 | #display { -moz-binding: url(xbl_bindings.xml#onedivchild); } |
michael@0 | 14 | |
michael@0 | 15 | </style> |
michael@0 | 16 | </head> |
michael@0 | 17 | <body onload="run()"> |
michael@0 | 18 | <div id="display"></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 run() { |
michael@0 | 25 | |
michael@0 | 26 | function setup_style() { |
michael@0 | 27 | var style_elem = document.createElement("style"); |
michael@0 | 28 | style_elem.setAttribute("type", "text/css"); |
michael@0 | 29 | document.getElementsByTagName("head")[0].appendChild(style_elem); |
michael@0 | 30 | var style_text = document.createTextNode(""); |
michael@0 | 31 | style_elem.appendChild(style_text); |
michael@0 | 32 | return style_text; |
michael@0 | 33 | } |
michael@0 | 34 | |
michael@0 | 35 | var style_text = setup_style(); |
michael@0 | 36 | |
michael@0 | 37 | var gCounter = 0; |
michael@0 | 38 | |
michael@0 | 39 | function test_selector(selector, matches_docdiv, matches_anondiv) |
michael@0 | 40 | { |
michael@0 | 41 | var zi = ++gCounter; |
michael@0 | 42 | style_text.data = selector + "{ z-index: " + zi + " }"; |
michael@0 | 43 | |
michael@0 | 44 | var doc_div = document.getElementById("display"); |
michael@0 | 45 | var anon_div = SpecialPowers.wrap(document).getAnonymousNodes(doc_div)[0]; |
michael@0 | 46 | var should_match = []; |
michael@0 | 47 | var should_not_match = []; |
michael@0 | 48 | (matches_docdiv ? should_match : should_not_match).push(doc_div); |
michael@0 | 49 | (matches_anondiv ? should_match : should_not_match).push(anon_div); |
michael@0 | 50 | |
michael@0 | 51 | for (var i = 0; i < should_match.length; ++i) { |
michael@0 | 52 | var e = should_match[i]; |
michael@0 | 53 | is(SpecialPowers.wrap(window).getComputedStyle(e, "").zIndex, zi, |
michael@0 | 54 | "element matched " + selector); |
michael@0 | 55 | } |
michael@0 | 56 | for (var i = 0; i < should_not_match.length; ++i) { |
michael@0 | 57 | var e = should_not_match[i]; |
michael@0 | 58 | is(SpecialPowers.wrap(window).getComputedStyle(e, "").zIndex, "auto", |
michael@0 | 59 | "element did not match " + selector); |
michael@0 | 60 | } |
michael@0 | 61 | |
michael@0 | 62 | style_text.data = ""; |
michael@0 | 63 | } |
michael@0 | 64 | |
michael@0 | 65 | // Test that the root of an XBL1 anonymous content subtree doesn't |
michael@0 | 66 | // match :nth-child(). |
michael@0 | 67 | test_selector("div.anondiv", false, true); |
michael@0 | 68 | test_selector("div:nth-child(odd)", true, false); |
michael@0 | 69 | test_selector("div:nth-child(even)", false, false); |
michael@0 | 70 | |
michael@0 | 71 | SimpleTest.finish(); |
michael@0 | 72 | } |
michael@0 | 73 | |
michael@0 | 74 | </script> |
michael@0 | 75 | </pre> |
michael@0 | 76 | </body> |
michael@0 | 77 | </html> |
michael@0 | 78 |