1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/xbl/test/file_bug372769.xhtml Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,181 @@ 1.4 +<html xmlns="http://www.w3.org/1999/xhtml"> 1.5 +<!-- 1.6 +https://bugzilla.mozilla.org/show_bug.cgi?id=372769 1.7 +--> 1.8 +<head> 1.9 + <title>Test for Bug 372769</title> 1.10 + <bindings xmlns="http://www.mozilla.org/xbl"> 1.11 + <binding id="test1"> 1.12 + <implementation> 1.13 + <field name="one">1</field> 1.14 + <field name="two">9</field> 1.15 + <field name="three">3</field> 1.16 + <field name="four">10</field> 1.17 + <field name="five">11</field> 1.18 + <field name="six">this.four = 4; 6;</field> 1.19 + <field name="seven">this.five = 5; 7;</field> 1.20 + </implementation> 1.21 + </binding> 1.22 + 1.23 + <binding id="test2"> 1.24 + <implementation> 1.25 + <!-- Tests for recursive resolves --> 1.26 + <field name="eight">this.eight</field> 1.27 + <field name="nine">this.ten</field> 1.28 + <field name="ten">this.nine</field> 1.29 + <!-- Tests for non-DOM overrides --> 1.30 + <field name="eleven">11</field> 1.31 + <field name="twelve">12</field> 1.32 + <!-- Tests for DOM overrides --> 1.33 + <field name="parentNode">this.parentNode</field> 1.34 + <field name="ownerDocument">"ownerDocument override"</field> 1.35 + </implementation> 1.36 + </binding> 1.37 + 1.38 + <binding id="test3-ancestor"> 1.39 + <implementation> 1.40 + <field name="thirteen">"13 ancestor"</field> 1.41 + <field name="fourteen">"14 ancestor"</field> 1.42 + <property name="fifteen" readonly="true" onget="return '15 ancestor'"/> 1.43 + </implementation> 1.44 + </binding> 1.45 + 1.46 + <binding id="test3" extends="#test3-ancestor"> 1.47 + <implementation> 1.48 + <field name="thirteen">13</field> 1.49 + <field name="fifteen">15</field> 1.50 + <field name="sixteen">16</field> 1.51 + <field name="sixteen">"16 later"</field> 1.52 + <field name="seventeen">17</field> 1.53 + <field name="eighteen">"18 field"</field> 1.54 + <property name="eighteen" readonly="true" onget="return 18"/> 1.55 + <property name="nineteen" readonly="true" onget="return 19"/> 1.56 + <field name="nineteen">"19 field"</field> 1.57 + </implementation> 1.58 + </binding> 1.59 + 1.60 + <binding id="test4"> 1.61 + <implementation> 1.62 + <field name="twenty">for (var i in this) ; 20;</field> 1.63 + </implementation> 1.64 + </binding> 1.65 + 1.66 + <binding id="test5"> 1.67 + <implementation> 1.68 + <field name="twenty-one">for (var i in this) ; 21;</field> 1.69 + </implementation> 1.70 + </binding> 1.71 +</bindings> 1.72 +</head> 1.73 +<body> 1.74 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=372769">Mozilla Bug 372769</a> 1.75 +<p id="display1" style="-moz-binding: url(#test1)"></p> 1.76 +<p id="display2" style="-moz-binding: url(#test2)"></p> 1.77 +<p id="display3" style="-moz-binding: url(#test3)"></p> 1.78 +<p id="display4" style="-moz-binding: url(#test4)"></p> 1.79 +<p id="display5" style="-moz-binding: url(#test5)"></p> 1.80 +<div id="content" style="display: none"> 1.81 + 1.82 +</div> 1.83 +<pre id="test"> 1.84 +<script class="testbody" type="text/javascript"> 1.85 +<![CDATA[ 1.86 + 1.87 +/** Test for Bug 372769 **/ 1.88 + 1.89 +SimpleTest = parent.SimpleTest; 1.90 +ok = parent.ok; 1.91 +is = parent.is; 1.92 +$ = function(x) { return document.getElementById(x); } 1.93 + 1.94 +window.onload = function() { 1.95 + var d = $("display1"); 1.96 + is(d.one, 1, "Should be able to read field"); 1.97 + 1.98 + d.two = 2; 1.99 + is(d.two, 2, "Should be able to write field"); 1.100 + 1.101 + is("three" in d, true, 'Should have a property named "three"'); 1.102 + is(d.three, 3, "Should be 3"); 1.103 + 1.104 + is(d.four, 10, "Unexpected value so far"); 1.105 + 1.106 + // Save "five" for now 1.107 + 1.108 + is(d.six, 6, "Should be 6"); 1.109 + 1.110 + is(d.four, 4, "Now should be 4"); 1.111 + 1.112 + d.four = 9; 1.113 + is(d.four, 9, "Just set it to 9"); 1.114 + 1.115 + var found = false; 1.116 + for (var prop in d) { 1.117 + if (prop == "seven") { 1.118 + found = true; 1.119 + break; 1.120 + } 1.121 + } 1.122 + is(found, true, "Enumeration is broken"); 1.123 + 1.124 + is(d.four, 9, "Shouldn't have rerun field six"); 1.125 + is(d.five, 11, "Shouldn't have run field 7"); 1.126 + is(d.seven, 7, "Should be 7") 1.127 + is(d.five, 5, "Should have run field 7"); 1.128 + 1.129 + d = $("display2"); 1.130 + is(typeof(d.eight), "undefined", "Recursive resolve should bail out"); 1.131 + is(typeof(d.nine), "undefined", "Recursive double resolve should bail out"); 1.132 + is(typeof(d.ten), "undefined", 1.133 + "This recursive double resolve should bail out too"); 1.134 + 1.135 + // Get .eleven so it's resolved now 1.136 + is(d.eleven, 11, "Unexpected value for .eleven"); 1.137 + var newProto = {}; 1.138 + newProto.eleven = "Proto 11"; 1.139 + newProto.twelve = "Proto 12"; 1.140 + newProto.__proto__ = d.__proto__; 1.141 + d.__proto__ = newProto; 1.142 + is(d.eleven, 11, "Proto should not have affected this"); 1.143 + is(d.twelve, "Proto 12", "Proto should have overridden 'twelve'"); 1.144 + 1.145 + is(d.parentNode, undefined, "We overrode this, yes we did"); 1.146 + is(typeof(d.parentNode), "undefined", "This is a recursive resolve too"); 1.147 + is(d.ownerDocument, "ownerDocument override", 1.148 + "Should have overridden ownerDocument"); 1.149 + 1.150 + d = $("display3"); 1.151 + is(d.thirteen, 13, "descendant should win here"); 1.152 + is(d.fourteen, "14 ancestor", 1.153 + "ancestor should win if descendant does nothing") 1.154 + is(d.fifteen, 15, 1.155 + "Field beats ancestor's property, since the latter lives on higher proto") 1.156 + is(d.sixteen, 16, "First field wins"); 1.157 + is(d.__proto__.seventeen, undefined, "Shouldn't have this on proto"); 1.158 + is(typeof(d.__proto__.seventeen), "undefined", 1.159 + "Really, should be undefined"); 1.160 + is(d.seventeen, 17, "Should have this prop on the node itself, though"); 1.161 + is(d.eighteen, 18, "Property beats field"); 1.162 + is(d.nineteen, 19, "Property still beats field"); 1.163 + 1.164 + d = $("display4"); 1.165 + is(d.twenty, 20, "Should be 20"); 1.166 + 1.167 + d = $("display5"); 1.168 + found = false; 1.169 + for (var prop2 in d) { 1.170 + if (prop2 == "twenty-one") { 1.171 + found = true; 1.172 + break; 1.173 + } 1.174 + } 1.175 + is(found, true, "Enumeration is broken"); 1.176 + is(d["twenty-one"], 21, "Should be 21"); 1.177 + SimpleTest.finish(); 1.178 +} 1.179 +]]> 1.180 +</script> 1.181 +</pre> 1.182 +</body> 1.183 +</html> 1.184 +