dom/xbl/test/file_bug372769.xhtml

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 <html xmlns="http://www.w3.org/1999/xhtml">
michael@0 2 <!--
michael@0 3 https://bugzilla.mozilla.org/show_bug.cgi?id=372769
michael@0 4 -->
michael@0 5 <head>
michael@0 6 <title>Test for Bug 372769</title>
michael@0 7 <bindings xmlns="http://www.mozilla.org/xbl">
michael@0 8 <binding id="test1">
michael@0 9 <implementation>
michael@0 10 <field name="one">1</field>
michael@0 11 <field name="two">9</field>
michael@0 12 <field name="three">3</field>
michael@0 13 <field name="four">10</field>
michael@0 14 <field name="five">11</field>
michael@0 15 <field name="six">this.four = 4; 6;</field>
michael@0 16 <field name="seven">this.five = 5; 7;</field>
michael@0 17 </implementation>
michael@0 18 </binding>
michael@0 19
michael@0 20 <binding id="test2">
michael@0 21 <implementation>
michael@0 22 <!-- Tests for recursive resolves -->
michael@0 23 <field name="eight">this.eight</field>
michael@0 24 <field name="nine">this.ten</field>
michael@0 25 <field name="ten">this.nine</field>
michael@0 26 <!-- Tests for non-DOM overrides -->
michael@0 27 <field name="eleven">11</field>
michael@0 28 <field name="twelve">12</field>
michael@0 29 <!-- Tests for DOM overrides -->
michael@0 30 <field name="parentNode">this.parentNode</field>
michael@0 31 <field name="ownerDocument">"ownerDocument override"</field>
michael@0 32 </implementation>
michael@0 33 </binding>
michael@0 34
michael@0 35 <binding id="test3-ancestor">
michael@0 36 <implementation>
michael@0 37 <field name="thirteen">"13 ancestor"</field>
michael@0 38 <field name="fourteen">"14 ancestor"</field>
michael@0 39 <property name="fifteen" readonly="true" onget="return '15 ancestor'"/>
michael@0 40 </implementation>
michael@0 41 </binding>
michael@0 42
michael@0 43 <binding id="test3" extends="#test3-ancestor">
michael@0 44 <implementation>
michael@0 45 <field name="thirteen">13</field>
michael@0 46 <field name="fifteen">15</field>
michael@0 47 <field name="sixteen">16</field>
michael@0 48 <field name="sixteen">"16 later"</field>
michael@0 49 <field name="seventeen">17</field>
michael@0 50 <field name="eighteen">"18 field"</field>
michael@0 51 <property name="eighteen" readonly="true" onget="return 18"/>
michael@0 52 <property name="nineteen" readonly="true" onget="return 19"/>
michael@0 53 <field name="nineteen">"19 field"</field>
michael@0 54 </implementation>
michael@0 55 </binding>
michael@0 56
michael@0 57 <binding id="test4">
michael@0 58 <implementation>
michael@0 59 <field name="twenty">for (var i in this) ; 20;</field>
michael@0 60 </implementation>
michael@0 61 </binding>
michael@0 62
michael@0 63 <binding id="test5">
michael@0 64 <implementation>
michael@0 65 <field name="twenty-one">for (var i in this) ; 21;</field>
michael@0 66 </implementation>
michael@0 67 </binding>
michael@0 68 </bindings>
michael@0 69 </head>
michael@0 70 <body>
michael@0 71 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=372769">Mozilla Bug 372769</a>
michael@0 72 <p id="display1" style="-moz-binding: url(#test1)"></p>
michael@0 73 <p id="display2" style="-moz-binding: url(#test2)"></p>
michael@0 74 <p id="display3" style="-moz-binding: url(#test3)"></p>
michael@0 75 <p id="display4" style="-moz-binding: url(#test4)"></p>
michael@0 76 <p id="display5" style="-moz-binding: url(#test5)"></p>
michael@0 77 <div id="content" style="display: none">
michael@0 78
michael@0 79 </div>
michael@0 80 <pre id="test">
michael@0 81 <script class="testbody" type="text/javascript">
michael@0 82 <![CDATA[
michael@0 83
michael@0 84 /** Test for Bug 372769 **/
michael@0 85
michael@0 86 SimpleTest = parent.SimpleTest;
michael@0 87 ok = parent.ok;
michael@0 88 is = parent.is;
michael@0 89 $ = function(x) { return document.getElementById(x); }
michael@0 90
michael@0 91 window.onload = function() {
michael@0 92 var d = $("display1");
michael@0 93 is(d.one, 1, "Should be able to read field");
michael@0 94
michael@0 95 d.two = 2;
michael@0 96 is(d.two, 2, "Should be able to write field");
michael@0 97
michael@0 98 is("three" in d, true, 'Should have a property named "three"');
michael@0 99 is(d.three, 3, "Should be 3");
michael@0 100
michael@0 101 is(d.four, 10, "Unexpected value so far");
michael@0 102
michael@0 103 // Save "five" for now
michael@0 104
michael@0 105 is(d.six, 6, "Should be 6");
michael@0 106
michael@0 107 is(d.four, 4, "Now should be 4");
michael@0 108
michael@0 109 d.four = 9;
michael@0 110 is(d.four, 9, "Just set it to 9");
michael@0 111
michael@0 112 var found = false;
michael@0 113 for (var prop in d) {
michael@0 114 if (prop == "seven") {
michael@0 115 found = true;
michael@0 116 break;
michael@0 117 }
michael@0 118 }
michael@0 119 is(found, true, "Enumeration is broken");
michael@0 120
michael@0 121 is(d.four, 9, "Shouldn't have rerun field six");
michael@0 122 is(d.five, 11, "Shouldn't have run field 7");
michael@0 123 is(d.seven, 7, "Should be 7")
michael@0 124 is(d.five, 5, "Should have run field 7");
michael@0 125
michael@0 126 d = $("display2");
michael@0 127 is(typeof(d.eight), "undefined", "Recursive resolve should bail out");
michael@0 128 is(typeof(d.nine), "undefined", "Recursive double resolve should bail out");
michael@0 129 is(typeof(d.ten), "undefined",
michael@0 130 "This recursive double resolve should bail out too");
michael@0 131
michael@0 132 // Get .eleven so it's resolved now
michael@0 133 is(d.eleven, 11, "Unexpected value for .eleven");
michael@0 134 var newProto = {};
michael@0 135 newProto.eleven = "Proto 11";
michael@0 136 newProto.twelve = "Proto 12";
michael@0 137 newProto.__proto__ = d.__proto__;
michael@0 138 d.__proto__ = newProto;
michael@0 139 is(d.eleven, 11, "Proto should not have affected this");
michael@0 140 is(d.twelve, "Proto 12", "Proto should have overridden 'twelve'");
michael@0 141
michael@0 142 is(d.parentNode, undefined, "We overrode this, yes we did");
michael@0 143 is(typeof(d.parentNode), "undefined", "This is a recursive resolve too");
michael@0 144 is(d.ownerDocument, "ownerDocument override",
michael@0 145 "Should have overridden ownerDocument");
michael@0 146
michael@0 147 d = $("display3");
michael@0 148 is(d.thirteen, 13, "descendant should win here");
michael@0 149 is(d.fourteen, "14 ancestor",
michael@0 150 "ancestor should win if descendant does nothing")
michael@0 151 is(d.fifteen, 15,
michael@0 152 "Field beats ancestor's property, since the latter lives on higher proto")
michael@0 153 is(d.sixteen, 16, "First field wins");
michael@0 154 is(d.__proto__.seventeen, undefined, "Shouldn't have this on proto");
michael@0 155 is(typeof(d.__proto__.seventeen), "undefined",
michael@0 156 "Really, should be undefined");
michael@0 157 is(d.seventeen, 17, "Should have this prop on the node itself, though");
michael@0 158 is(d.eighteen, 18, "Property beats field");
michael@0 159 is(d.nineteen, 19, "Property still beats field");
michael@0 160
michael@0 161 d = $("display4");
michael@0 162 is(d.twenty, 20, "Should be 20");
michael@0 163
michael@0 164 d = $("display5");
michael@0 165 found = false;
michael@0 166 for (var prop2 in d) {
michael@0 167 if (prop2 == "twenty-one") {
michael@0 168 found = true;
michael@0 169 break;
michael@0 170 }
michael@0 171 }
michael@0 172 is(found, true, "Enumeration is broken");
michael@0 173 is(d["twenty-one"], 21, "Should be 21");
michael@0 174 SimpleTest.finish();
michael@0 175 }
michael@0 176 ]]>
michael@0 177 </script>
michael@0 178 </pre>
michael@0 179 </body>
michael@0 180 </html>
michael@0 181

mercurial