Skip to content

Commit 87b2fda

Browse files
Make a DOM test simulate a click instead of triggering a custom event.
1 parent 78082ec commit 87b2fda

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

test/unit/dom_test.js

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,18 @@ var createParagraph = function(text) {
77
return p;
88
}
99

10+
function simulateClick(node) {
11+
var oEvent;
12+
if (document.createEvent) {
13+
oEvent = document.createEvent('MouseEvents');
14+
oEvent.initMouseEvent('click', true, true, document.defaultView,
15+
0, 0, 0, 0, 0, false, false, false, false, 0, node);
16+
node.dispatchEvent(oEvent);
17+
} else {
18+
node.click();
19+
}
20+
}
21+
1022
new Test.Unit.Runner({
1123
setup: function() {
1224
if (documentViewportProperties) return;
@@ -1550,15 +1562,20 @@ new Test.Unit.Runner({
15501562
child.store('foo', 'bar');
15511563

15521564
var trigger = false;
1553-
child.observe('test:event', function(event) { trigger = true; });
1565+
child.observe('click', function(event) { trigger = true; });
15541566
var childUID = child._prototypeUID;
15551567

15561568
parent.update("");
15571569

15581570
// At this point, `child` should have been purged.
1559-
this.assert(!(childUID in Element.Storage), "purged element's UID should no longer exist in `Element.Storage`");
1560-
1561-
var event = child.fire('test:event');
1571+
this.assert(
1572+
!(childUID in Element.Storage),
1573+
"purged element's UID should no longer exist in `Element.Storage`"
1574+
);
1575+
1576+
// Simulate a click to be sure the element's handler has been
1577+
// unregistered.
1578+
simulateClick(child);
15621579
this.assert(!trigger, "fired event should not have triggered handler");
15631580
}
15641581
});

0 commit comments

Comments
 (0)