1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/layout/inspector/tests/test_bug609549.xhtml Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,67 @@ 1.4 +<html xmlns="http://www.w3.org/1999/xhtml"> 1.5 +<!-- 1.6 +https://bugzilla.mozilla.org/show_bug.cgi?id=609549 1.7 +--> 1.8 +<head> 1.9 + <title>Test for Bug 609549</title> 1.10 + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.11 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 1.12 + 1.13 + <bindings xmlns="http://www.mozilla.org/xbl"> 1.14 + <binding id="testBinding"> 1.15 + <!-- No linebreaks since this is html and whitespace is preserved. --> 1.16 + <content><div anonid="box-A">x</div><div anonid="box-B"><children includes="span"/></div><div anonid="box-C">x</div><children/></content> 1.17 + </binding> 1.18 + </bindings> 1.19 +</head> 1.20 + 1.21 +<body> 1.22 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=609549">Mozilla Bug 609549</a> 1.23 +<div id="bound" style="-moz-binding: url(#testBinding);"><p id="p">lorem ipsum dolor sit amet</p><span id="sandwiched">sandwiched</span></div> 1.24 + 1.25 +<div id="content" style="display: none"> 1.26 + 1.27 +</div> 1.28 +<pre id="test"> 1.29 +<script type="application/javascript"> 1.30 +<![CDATA[ 1.31 + 1.32 +/** Test for Bug 609549 **/ 1.33 +SimpleTest.waitForExplicitFinish(); 1.34 + 1.35 +addLoadEvent(function() { 1.36 + var domUtils = SpecialPowers.Cc["@mozilla.org/inspector/dom-utils;1"]. 1.37 + getService(SpecialPowers.Ci.inIDOMUtils); 1.38 + ok("getChildrenForNode" in domUtils, "domUtils has no getChildrenForNode"); 1.39 + var withoutAnons = SpecialPowers.unwrap(domUtils.getChildrenForNode($("bound"), false)); 1.40 + 1.41 + is(withoutAnons.length, $("bound").childNodes.length, 1.42 + "withoutAnons should be the same length as childNodes"); 1.43 + is(withoutAnons[0], $("p"), "didn't get paragraph - without anons"); 1.44 + is(withoutAnons[1], $("sandwiched"), 1.45 + "didn't get sandwiched span - without anons"); 1.46 + 1.47 + var withAnons = domUtils.getChildrenForNode($("bound"), true); 1.48 + 1.49 + is(withAnons.length, 4, "bad withAnons.length"); 1.50 + is(withAnons[0].getAttribute("anonid"), "box-A", 1.51 + "didn't get anonymous box-A"); 1.52 + is(withAnons[1].getAttribute("anonid"), "box-B", 1.53 + "didn't get anonymous box-B"); 1.54 + is(withAnons[2].getAttribute("anonid"), "box-C", 1.55 + "didn't get anonymous box-C"); 1.56 + is(withAnons[3].id, "p", "didn't get paragraph - with anons"); 1.57 + 1.58 + var bKids = domUtils.getChildrenForNode(withAnons[1], true); 1.59 + is(bKids.length, 1, "bKids.length is bad"); 1.60 + is(SpecialPowers.unwrap(bKids[0]), $("sandwiched"), 1.61 + "didn't get sandwiched span inserted into box-B"); 1.62 + 1.63 + SimpleTest.finish(); 1.64 +}); 1.65 + 1.66 +]]> 1.67 +</script> 1.68 +</pre> 1.69 +</body> 1.70 +</html>