(tc)
| 102 | var testRunCount = 0; |
| 103 | |
| 104 | var test = function (tc) { |
| 105 | var hitCount = 0; |
| 106 | var results = []; |
| 107 | tc.onmyevent = function () { results.push("one"); }; |
| 108 | |
| 109 | tc.dispatchEvent("myevent", "my detail"); |
| 110 | LiveUnit.Assert.areEqual(1, results.length); |
| 111 | LiveUnit.Assert.isTrue(sequenceEquals(["one"], results)); |
| 112 | |
| 113 | // After adding another event listener "one" should still be dispatched first |
| 114 | results = []; |
| 115 | tc.addEventListener("myevent", function () { results.push("two"); }); |
| 116 | tc.dispatchEvent("myevent", "my detail"); |
| 117 | LiveUnit.Assert.areEqual(2, results.length); |
| 118 | LiveUnit.Assert.isTrue(sequenceEquals(["one", "two"], results)); |
| 119 | |
| 120 | // After replacing the event listener property value the new property value |
| 121 | // should be dispatched first. |
| 122 | results = []; |
| 123 | tc.onmyevent = function () { results.push("three"); }; |
| 124 | tc.dispatchEvent("myevent", "my detail"); |
| 125 | LiveUnit.Assert.areEqual(2, results.length); |
| 126 | LiveUnit.Assert.isTrue(sequenceEquals(["three", "two"], results)); |
| 127 | |
| 128 | // After setting the event listener property value to null we should |
| 129 | // only see the explicitly registered listener getting called. |
| 130 | results = []; |
| 131 | tc.onmyevent = null; |
| 132 | tc.dispatchEvent("myevent", "my detail"); |
| 133 | LiveUnit.Assert.areEqual(1, results.length); |
| 134 | LiveUnit.Assert.isTrue(sequenceEquals(["two"], results)); |
| 135 | |
| 136 | // After adding a new event listener property value we see that it is |
| 137 | // dispatched at the end because the nulling out of the property removed |
| 138 | // the slot reservation. |
| 139 | results = []; |
| 140 | tc.onmyevent = function () { results.push("four"); }; |
| 141 | tc.dispatchEvent("myevent", "my detail"); |
| 142 | LiveUnit.Assert.areEqual(2, results.length); |
| 143 | LiveUnit.Assert.isTrue(sequenceEquals(["two", "four"], results)); |
| 144 | |
| 145 | testRunCount++; |
| 146 | }; |
| 147 | |
| 148 | // Put this in its own function to ensure we don't accidentially capture above. |
| 149 | // |
nothing calls this directly
no test coverage detected