customevent.html revision cb4f4f79feb7498d1f3406b88fb62209e5f5a444
ba3008548cd047b233fcd32bb3c5d69926eed22fAndrew Forrest<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
ba3008548cd047b233fcd32bb3c5d69926eed22fAndrew Forrest<script type="text/javascript" src="/build/yui/yui.js"></script>
ba3008548cd047b233fcd32bb3c5d69926eed22fAndrew Forrest<p><input type="button" value="Run Tests" id="btnRun" disabled="true" /></p>
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste var global_notified;
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste //YUI.add("selector-native", function(){});
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste filter: "debug",
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste useConsole: true,
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste onCSS: function(Y) {
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste Y.log('CSS is done loading', 'info', 'testcase');
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste logExclude: { get: true, Dom: true, Selector: true, Node: true, attribute: true, event: true, base: true, widget: true },
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste base: 'raw',
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste // dom: null,
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste attribute: 'min'
ba3008548cd047b233fcd32bb3c5d69926eed22fAndrew Forrest }).use("dump", "test", "console", function(Y) {
ba3008548cd047b233fcd32bb3c5d69926eed22fAndrew Forrest // Y.Global.on('yui:log', function(e) {
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste var button = Y.one('#btnRun');
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste // Set up the page
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste button.set("disabled", false);
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste Y.on("click", function() {
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste var myConsole = new Y.Console().render();
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste var testEventTarget = new Y.Test.Case({
ba3008548cd047b233fcd32bb3c5d69926eed22fAndrew Forrest name: "Custom event tests",
ba3008548cd047b233fcd32bb3c5d69926eed22fAndrew Forrest testAugment: function() {
ba3008548cd047b233fcd32bb3c5d69926eed22fAndrew Forrest var fired = false;
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste var O = function(id) {
ba3008548cd047b233fcd32bb3c5d69926eed22fAndrew Forrest Y.log('O constructor executed ' + id);
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste oOo: function(ok) {
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste // pass configuration info into EventTarget with the following
ba3008548cd047b233fcd32bb3c5d69926eed22fAndrew Forrest emitFacade: true
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste var o = new O(),
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste handle = o.on('testAugment', function(e, arg1, arg2) {
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste Y.Assert.isTrue(this instanceof O);
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste fired = true;
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste o.fire('testAugment', { foo: 'afoo' }, 1, 2);
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste // if the first argument is not an object, the
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste // event facade is moved in front of the args rather
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste // than overwriting existing object.
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste o.on('testAugment', function(e, arg1, arg2) {
ba3008548cd047b233fcd32bb3c5d69926eed22fAndrew Forrest o.fire('testAugment', 1, 2);
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste testExtend: function() {
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste var fired = false;
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste var Base = function() {
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste Y.log('Base constructor executed');
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste arguments.callee.superclass.constructor.apply(this, arguments);
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste base: function() {
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste Y.log('all your base...');
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste var b = new Base();
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste b.on('testExtend', function(arg1, arg2) {
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste Y.Assert.isTrue(this instanceof Base);
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste fired = true;
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste b.fire('testExtend', 1, 2);
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste testPrefix: function() {
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste var fired1 = false,
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste fired2 = false;
a054572695c2812c82211ccbca678d29d687fed8Kajetan Hemzaczek var O = function(id) {
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste Y.log('O constructor executed ' + id);
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste oOo: function(ok) {
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste // pass configuration info into EventTarget with the following
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste // construct
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste emitFacade: true,
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste prefix: 'prefix'
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste var o = new O();
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste o.on('testPrefix', function(e, arg1, arg2) {
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste Y.Assert.isTrue(this instanceof O);
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste fired1 = true;
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste o.on('prefix:testPrefix', function(e, arg1, arg2) {
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste Y.Assert.isTrue(this instanceof O);
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste fired2 = true;
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste o.fire('testPrefix', { foo: 'afoo' }, 1, 2);
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste fired1 = false;
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste fired2 = false;
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste o.fire('prefix:testPrefix', { foo: 'afoo' }, 1, 2);
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste testDetachKey: function() {
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste var fired1 = false,
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste fired2 = false;
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste Y.on('handle|test:event', function() {
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste fired1 = true;
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste // one listener
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste Y.fire('test:event');
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste Y.detach('handle|test:event');
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste fired1 = false;
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste fired2 = false;
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste Y.on('handle|test:event', function() {
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste fired2 = true;
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste // first lisener detached, added a new listener
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste Y.fire('test:event');
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste Y.detach('handle|test:event');
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste fired1 = false;
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste fired2 = false;
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste Y.after('handle|test:event', function(arg1) {
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste Y.Assert.areEqual('orange', arg1);
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste fired2 = true;
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste // comma or pipe
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste Y.on('handle|test:event', function(arg1) {
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste Y.Assert.areEqual('orange', arg1);
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste fired1 = true;
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste // testing on and after order
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste Y.fire('test:event', 'orange');
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste fired1 = false;
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste fired2 = false;
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste // spaces after the comma or lack thereof should have
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste // no effect on the addition or removal of listeners
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste var ret = Y.detach('handle|test:event');
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste // added both an on listener and an after listener,
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste // then detached both
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste Y.fire('test:event', 'orange');
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste testDetachAllByKey: function() {
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste var fired1 = false,
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste fired2 = false;
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste Y.after('handle|event2', function() {
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste fired2 = true;
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste Y.on('handle|event2', function() {
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste fired1 = true;
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste // detachAll
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste Y.Assert.isFalse(fired1, 'fired1, the after listener should not have fired.');
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste Y.Assert.isFalse(fired2, 'fired2, the on listener should not have fired.');
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste testChain: function() {
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste var fired1 = false,
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste fired2 = false,
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste fired3 = false,
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste fired4 = false,
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste fired5 = false;
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste // should be executed once, after f2
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste var f1 = function() {
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste fired1 = true;
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste // should be executed once, before f1
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste var f2 = function() {
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste fired2 = true;
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste // should be executed once, different event from f1 and f2
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste var f3 = function() {
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste fired3 = true;
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste // detached before fired, should not executed
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste var f4 = function() {
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste fired4 = true;
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste // should fire once, preserving the custom prefix rather
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste // than using the configured event target prefix
a054572695c2812c82211ccbca678d29d687fed8Kajetan Hemzaczek var f5 = function() {
a054572695c2812c82211ccbca678d29d687fed8Kajetan Hemzaczek fired5 = true;
a054572695c2812c82211ccbca678d29d687fed8Kajetan Hemzaczek // configure chaining via global default or on the event target
a054572695c2812c82211ccbca678d29d687fed8Kajetan Hemzaczek YUI({ /* chain: true */
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste logInclude: {
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste }).use('*', function(Y2) {
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste prefix: 'foo',
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste chain : true
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste // without event target prefix manipulation (incomplete now)
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste // @TODO an error here is throwing an uncaught exception rather than failing the test
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste // Y2.after('p:e', f1).on('p:e', f2).on('p:e2', f3).on('detach, p:e', f4).detach('detach, p:e').fire('p:e').fire('p:e2');
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste // with event target prefix manipulation ('e' is the same event as 'foo:e',
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste // but 'pre:e' is a different event only accessible by using that exact name)
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Joosteo.after('e', f1).on('foo:e', f2).on('foo:e2', f3).on('detach, e', f4).detach('detach,e').fire('foo:e').fire('e2').on('pre:e', f5).fire('pre:e');
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste Y.Assert.isTrue(fired1); // verifies chaining, on/after order, and adding the event target prefix
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste Y.Assert.isTrue(fired2); // verifies chaining, on/after order, and accepting the prefix in the event name
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste Y.Assert.isTrue(fired3); // verifies no interaction between events, and prefix manipulation
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste Y.Assert.isFalse(fired4); // verifies detach works (regardless of spaces after comma)
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste Y.Assert.isTrue(fired5); // verifies custom prefix
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste testObjType: function() {
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste 'y:click': function() {f1 = true},
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste 'y:clack': function() {f2 = true}
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste testBubble: function() {
98edafaa1060580ef39bce8710345d9fe25b5b04Jaco Jooste var count = 0,
ba3008548cd047b233fcd32bb3c5d69926eed22fAndrew Forrest emitFacade: true,
ba3008548cd047b233fcd32bb3c5d69926eed22fAndrew Forrest bubbles: true
a = new Y.EventTarget(config),
b = new Y.EventTarget(config);
b.addTarget(a);
// b.publish('test:foo');
a.on('test:foo', function(e) {
ret = b.fire('test:foo', {}, b);
Y.Assert.areEqual(1, count);
Y.Assert.isTrue(ret);
b.on('test:foo', function(e) {
ret = b.fire('test:foo', {}, b);
Y.Assert.areEqual(1, count);
Y.Assert.isFalse(ret);
Y.publish('y:foo1', {
Y.Assert.isTrue(this instanceof YUI);
Y.on('y:foo1', function(e) {
Y.on('y:foo1', function(e) {
Y.fire('y:foo1');
Y.Assert.areEqual(1, count);
Y.publish('y:foo', {
Y.on('y:foo', function(e) {
handle = Y.on('y:foo', function(e) {
handle2 = Y.on('y:foo', function(e) {
Y.detach(handle);
Y.fire('y:foo');
Y.Assert.areEqual(1, count);
var handle3 = Y.on('y:click', function() {
Y.fire('y:click');
Y.fire('y:click');
var o = new Y.EventTarget();
o.on('foo', function(e) {
o.on('foo', function(e) {
o.detachAll();
o.fire('foo');
Y.Assert.areEqual(0, count);
var handle3 = Y.on('y:click', function() {
Y.detachAll();
Y.fire('y:click');
Y.Assert.areEqual(1, count);
var o = new Y.EventTarget(), s1, s2, s3, s4;
o.publish('y:foo2', {
Y.on('y:foo2', function() {
Y.log('Y foo2 executed');
Y.Global.on('y:foo2', function() {
Y.log('GLOBAL foo2 executed');
o.fire('y:foo2');
Y.Assert.areEqual(1, s1);
Y.Assert.areNotEqual(1, s2);
o.publish('y:bar', {
Y.on('y:bar', function() {
Y.log('Y bar executed');
Y.Global.on('y:bar', function() {
Y.log('GLOBAL bar executed');
o.fire('y:bar');
Y.Assert.areEqual(1, s3);
Y.Assert.areEqual(1, s4);
Y.Global.on('y:bar', function(e) {
Y.log('GLOBAL bar executed');
o.fire('y:bar');
o.fire('y:bar');
Y.publish('fireonce', {
Y.fire('fireonce', 'foo', 'bar');
Y.on('fireonce', function(arg1, arg2) {
Y.Assert.areEqual('foo', arg1, 'arg1 not correct for lazy fireOnce listener')
Y.Assert.areEqual('bar', arg2, 'arg2 not correct for lazy fireOnce listener')
Y.fire('fireonce', 'foo2', 'bar2');
Y.fire('fireonce', 'foo3', 'bar3');
Y.on('fireonce', function(arg1, arg2) {
Y.log('the notification is asynchronous, so I need to wait for this test');
Y.Assert.areEqual(1, notified, 'listener notified more than once.');
Y.Assert.isFalse(global_notified, 'notification was not asynchronous');
Y.Assert.isTrue(global_notified, 'asynchronous notification did not seem to work.');
var node = Y.one('#adiv');
node.publish('foo1', {
node.on('foo1', function(e) {
Y.Assert.areEqual('foo1', e._type);
node.on('foo1', function(e) {
node.fire('foo1', {
Y.Assert.areEqual(1, preventCount);
Y.Assert.areEqual(2, heard);
called = this.name;
leaf = new Y.EventTarget(config),
branch = new Y.EventTarget(config),
root = new Y.EventTarget(config);
leaf.name = 'leaf';
branch.name = 'branch';
root.name = 'root';
leaf.addTarget(branch);
branch.addTarget(root);
leaf.publish('test:foo', { defaultFn: fn});
branch.publish('test:foo', { defaultFn: fn});
root.publish('test:foo', { defaultFn: fn});
leaf.on('test:foo', function(e) {
branch.on('test:foo', function() {
root.on('test:foo', function() {
root.after('test:foo', function() {
branch.after('test:foo', function() {
Y.Assert.areEqual('branch', called, 'branch.after should be executed after the branch default function');
leaf.after('test:foo', function(e) {
leaf.fire('test:foo', {}, leaf);
Y.Assert.areEqual(6, count);
called = this.name;
leaf = new Y.EventTarget(config),
branch = new Y.EventTarget(config),
root = new Y.EventTarget(config);
leaf.name = 'leaf';
branch.name = 'branch';
root.name = 'root';
leaf.addTarget(branch);
branch.addTarget(root);
leaf.publish('test:foo', { defaultFn: fn});
branch.publish('test:foo', { defaultFn: fn});
root.publish('test:foo', { defaultFn: fn});
leaf.on('test:foo', function(e) {
branch.on('test:foo', function() {
root.on('test:foo', function() {
leaf.after('test:foo', function(e) {
// Y.Assert.areEqual('root', called, 'leaf.after should be executed after the root default function');
branch.after('test:foo', function() {
// Y.Assert.areEqual('root', called, 'leaf.after should be executed after the root default function');
root.after('test:foo', function() {
// Y.Assert.areEqual('root', called, 'leaf.after should be executed after the root default function');
leaf.fire('test:foo', {}, leaf);
Y.Assert.areEqual(6, count, 'total subscriber count');
z = new Y.EventTarget(config),
a = new Y.EventTarget(config),
b = new Y.EventTarget(config);
b.addTarget(a);
a.addTarget(z);
z.on('*:foo', function(e) {
ret = b.fire('a:foo', {}, b);
Y.Assert.areEqual(1, count);
Y.Assert.isTrue(ret);
ret = b.fire('b:foo', {}, b);
Y.Assert.areEqual(2, count);
Y.Assert.isTrue(ret);
ret = b.fire('foo', {}, b);
Y.Assert.areEqual(3, count);
Y.Assert.isTrue(ret);
z = new Y.EventTarget(config),
a = new Y.EventTarget(config),
b = new Y.EventTarget(config);
b.addTarget(a);
a.addTarget(z);
z.after('*:foo', function(e) {
// e.preventDefault();
ret = b.fire('a:foo', {}, b);
Y.Assert.areEqual(0, count);
Y.once('foo', function(e) {
Y.fire('foo', 'bar');
Y.Assert.areEqual(1, count);
Y.fire('foo', 'bar');
Y.Assert.areEqual(1, count);
Y.Test.Runner.add(testEventTarget);
// base: "/build/",