1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/xbl/test/file_bug397934.xhtml Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,117 @@ 1.4 +<html xmlns="http://www.w3.org/1999/xhtml"> 1.5 +<!-- 1.6 +https://bugzilla.mozilla.org/show_bug.cgi?id=397934 1.7 +--> 1.8 +<head> 1.9 + <title>Test for Bug 397934</title> 1.10 + <bindings xmlns="http://www.mozilla.org/xbl"> 1.11 + <binding id="ancestor"> 1.12 + <implementation> 1.13 + <field name="testAncestor">"ancestor"</field> 1.14 + </implementation> 1.15 + </binding> 1.16 + <binding id="test1" extends="#ancestor"> 1.17 + <implementation> 1.18 + <constructor> 1.19 + this.storage = window; 1.20 + </constructor> 1.21 + <field name="window"></field> 1.22 + <field name="storage">null</field> 1.23 + <field name="parentNode"></field> 1.24 + <field name="ownerDocument">"ownerDocument"</field> 1.25 + <field name="emptyTest1"></field> 1.26 + <field name="emptyTest1">"empty1"</field> 1.27 + <field name="emptyTest2">"empty2"</field> 1.28 + <field name="emptyTest2"></field> 1.29 + <field name="testAncestor"></field> 1.30 + <field name="testEvalOnce">XPCNativeWrapper.unwrap(window).counter++; undefined</field> 1.31 + </implementation> 1.32 + </binding> 1.33 + <binding id="test2" extends="#ancestor"> 1.34 + <implementation> 1.35 + <constructor> 1.36 + this.storage = window; 1.37 + </constructor> 1.38 + <field name="window">undefined</field> 1.39 + <field name="storage">null</field> 1.40 + <field name="parentNode">undefined</field> 1.41 + <field name="ownerDocument">"ownerDocument"</field> 1.42 + <field name="emptyTest1">undefined</field> 1.43 + <field name="emptyTest1">"empty1"</field> 1.44 + <field name="emptyTest2">"empty2"</field> 1.45 + <field name="emptyTest2">undefined</field> 1.46 + <field name="testAncestor">undefined</field> 1.47 + </implementation> 1.48 + </binding> 1.49 + </bindings> 1.50 +</head> 1.51 +<body> 1.52 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=397934">Mozilla Bug 397934</a> 1.53 +<p id="display1" style="-moz-binding: url(#test1)"></p> 1.54 +<p id="display2" style="-moz-binding: url(#test2)"></p> 1.55 +<div id="content" style="display: none"> 1.56 + 1.57 +</div> 1.58 +<pre id="test"> 1.59 +<script class="testbody" type="text/javascript"> 1.60 +<![CDATA[ 1.61 + 1.62 +/** Test for Bug 397934 **/ 1.63 +SimpleTest = parent.SimpleTest; 1.64 +ok = parent.ok; 1.65 +is = parent.is; 1.66 +$ = function(x) { return document.getElementById(x); } 1.67 +window.onload = function() { 1.68 + var d; 1.69 + d = $("display1"); 1.70 + is(d.storage, window, 1.71 + "test1" + 1.72 + ": |window| in the constructor should have resolved to our window"); 1.73 + is(d.ownerDocument, "ownerDocument", 1.74 + "test1" + ": Control to test field overriding DOM prop"); 1.75 + is(d.parentNode, document.body, "test1" + ": unexpected parent"); 1.76 + is(d.emptyTest1, undefined, 1.77 + "test1" + ": First field wins even if undefined"); 1.78 + is(typeof(d.emptyTest1), "undefined", 1.79 + "test1" + ": First field wins even if undefined, double-check"); 1.80 + is(d.emptyTest2, "empty2", 1.81 + "test1" + ": First field wins"); 1.82 + is(d.testAncestor, "ancestor", 1.83 + "test1" + ": Empty field should not override ancestor binding"); 1.84 + 1.85 + var win = window; 1.86 + win.counter = 0; 1.87 + d.testEvalOnce; 1.88 + d.testEvalOnce; 1.89 + is(win.counter, 1, "Field should have evaluated once and only once"); 1.90 + 1.91 + d = $("display2"); 1.92 + is(d.storage, undefined, 1.93 + "test2" + 1.94 + ": |window| in the constructor should have resolved to undefined"); 1.95 + is(typeof(d.storage), "undefined", 1.96 + "test2" + 1.97 + ": |window| in the constructor should really have resolved to undefined"); 1.98 + is(d.ownerDocument, "ownerDocument", 1.99 + "test2" + ": Control to test field overriding DOM prop"); 1.100 + is(d.parentNode, undefined, "test2" + ": unexpected parent"); 1.101 + is(typeof(d.parentNode), "undefined", "test2" + ": unexpected parent for real"); 1.102 + is(d.emptyTest1, undefined, 1.103 + "test2" + ": First field wins even if undefined"); 1.104 + is(typeof(d.emptyTest1), "undefined", 1.105 + "test2" + ": First field wins even if undefined, double-check"); 1.106 + is(d.emptyTest2, "empty2", 1.107 + "test2" + ": First field wins"); 1.108 + is(d.testAncestor, undefined, 1.109 + "test2" + ": Undefined field should override ancestor binding"); 1.110 + is(typeof(d.testAncestor), "undefined", 1.111 + "test2" + ": Undefined field should really override ancestor binding"); 1.112 + SimpleTest.finish(); 1.113 +} 1.114 + 1.115 +]]> 1.116 +</script> 1.117 +</pre> 1.118 +</body> 1.119 +</html> 1.120 +