f3fed050519b073a392ef10048afe1e25700c139Luke Smith <link type="text/css" rel="stylesheet" href="/build/console/assets/skins/sam/console.css">
f3fed050519b073a392ef10048afe1e25700c139Luke Smith <link type="text/css" rel="stylesheet" href="/build/test/assets/test-console.css">
f3fed050519b073a392ef10048afe1e25700c139Luke Smith <style type="text/css" id="styleblock" class="highlight-ignore">
f3fed050519b073a392ef10048afe1e25700c139Luke Smith font: normal 125%/1.4 Arial, sans-serif;
0a9c6f9f30a66e52ec4ea4ed93504580b3a5669aAdam Moore .yui3-skin-sam .yui3-console .yui3-console-content {
f3fed050519b073a392ef10048afe1e25700c139Luke Smith font-size: 10px;
f3fed050519b073a392ef10048afe1e25700c139Luke Smith width: 32em;
0a9c6f9f30a66e52ec4ea4ed93504580b3a5669aAdam Moore .yui3-skin-sam .yui3-console .yui3-console-bd {
f3fed050519b073a392ef10048afe1e25700c139Luke Smith height: 50em;
0a9c6f9f30a66e52ec4ea4ed93504580b3a5669aAdam Moore .yui3-skin-sam .yui3-console-entry-pass .yui3-console-entry-cat {
f3fed050519b073a392ef10048afe1e25700c139Luke Smith background: #070;
f3fed050519b073a392ef10048afe1e25700c139Luke Smith color: #fff;
0a9c6f9f30a66e52ec4ea4ed93504580b3a5669aAdam Moore .yui3-skin-sam .yui3-console-entry-fail .yui3-console-entry-cat {
f3fed050519b073a392ef10048afe1e25700c139Luke Smith background: #700;
f3fed050519b073a392ef10048afe1e25700c139Luke Smith color: #fff;
f3fed050519b073a392ef10048afe1e25700c139Luke Smith .highlight-example {
f3fed050519b073a392ef10048afe1e25700c139Luke Smith display: inline;
f3fed050519b073a392ef10048afe1e25700c139Luke Smith float: left;
f3fed050519b073a392ef10048afe1e25700c139Luke Smith width: 650px;
f3fed050519b073a392ef10048afe1e25700c139Luke Smith .highlight-example h2 {
f3fed050519b073a392ef10048afe1e25700c139Luke Smith display: none;
f3fed050519b073a392ef10048afe1e25700c139Luke Smith<script type="text/javascript" src="/build/yui/yui.js"></script>
cb4f4f79feb7498d1f3406b88fb62209e5f5a444Adam Moore<script type="text/javascript" src="/build/event-custom/event-custom.js"></script>
cb4f4f79feb7498d1f3406b88fb62209e5f5a444Adam Moore<script type="text/javascript" src="/build/console/console.js"></script>
cb4f4f79feb7498d1f3406b88fb62209e5f5a444Adam Moore<script type="text/javascript" src="/build/test/test.js"></script>
f3fed050519b073a392ef10048afe1e25700c139Luke Smith}).use('test','console',function (Y) {
f3fed050519b073a392ef10048afe1e25700c139Luke Smithvar suite = new Y.Test.Suite("Event firing sequence test");
f3fed050519b073a392ef10048afe1e25700c139Luke Smith/*****************************/
f3fed050519b073a392ef10048afe1e25700c139Luke Smith/* Tests begin here */
f3fed050519b073a392ef10048afe1e25700c139Luke Smith/*****************************/
f3fed050519b073a392ef10048afe1e25700c139Luke Smith name : "single event sequence",
f3fed050519b073a392ef10048afe1e25700c139Luke Smith setUp : function () {
0a9c6f9f30a66e52ec4ea4ed93504580b3a5669aAdam Moore emitFacade: true
f3fed050519b073a392ef10048afe1e25700c139Luke Smith test_seqSimple : function () {
f3fed050519b073a392ef10048afe1e25700c139Luke Smith var results = '';
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.source.on('foo', function () { results += 'A'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.source.after('foo', function () { results += 'B'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith test_seqDefaultFnComplete : function () {
f3fed050519b073a392ef10048afe1e25700c139Luke Smith var results = '';
f3fed050519b073a392ef10048afe1e25700c139Luke Smith defaultFn: function () { results += 'B'; }});
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.source.on('foo', function () { results += 'A'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.source.after('foo', function () { results += 'C'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith Y.Assert.areSame("ABC",results);
f3fed050519b073a392ef10048afe1e25700c139Luke Smith test_seqDefaultFnPrevented : function () {
f3fed050519b073a392ef10048afe1e25700c139Luke Smith var results = '';
f3fed050519b073a392ef10048afe1e25700c139Luke Smith emitFacade: true,
f3fed050519b073a392ef10048afe1e25700c139Luke Smith defaultFn: function () { results += '1'; }});
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.source.on('foo', function (e) {
f3fed050519b073a392ef10048afe1e25700c139Luke Smith results += 'A';
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.source.after('foo', function () { results += '2'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith test_seqPreventedFnComplete : function () {
f3fed050519b073a392ef10048afe1e25700c139Luke Smith var results = '';
f3fed050519b073a392ef10048afe1e25700c139Luke Smith preventedFn: function () { results += '1'; }});
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.source.on('foo', function () { results += 'A'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.source.after('foo', function () { results += 'B'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith test_seqPreventedFnPrevented : function () {
f3fed050519b073a392ef10048afe1e25700c139Luke Smith var results = '';
f3fed050519b073a392ef10048afe1e25700c139Luke Smith emitFacade: true,
f3fed050519b073a392ef10048afe1e25700c139Luke Smith preventedFn: function () { results += 'B'; }});
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.source.on('foo', function (e) {
f3fed050519b073a392ef10048afe1e25700c139Luke Smith results += 'A';
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.source.after('foo', function () { results += '1'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith test_seqDefaultAndPreventedFnComplete : function () {
f3fed050519b073a392ef10048afe1e25700c139Luke Smith var results = '';
f3fed050519b073a392ef10048afe1e25700c139Luke Smith defaultFn: function () { results += 'B'; },
f3fed050519b073a392ef10048afe1e25700c139Luke Smith preventedFn: function () { results += '1'; }
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.source.on('foo', function () { results += 'A'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.source.after('foo', function () { results += 'C'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith Y.Assert.areSame("ABC",results);
f3fed050519b073a392ef10048afe1e25700c139Luke Smith test_seqDefaultAndPreventedFnPrevented : function () {
f3fed050519b073a392ef10048afe1e25700c139Luke Smith var results = '';
f3fed050519b073a392ef10048afe1e25700c139Luke Smith emitFacade: true,
f3fed050519b073a392ef10048afe1e25700c139Luke Smith defaultFn: function () { results += '1'; },
f3fed050519b073a392ef10048afe1e25700c139Luke Smith preventedFn: function () { results += 'B'; }
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.source.on('foo', function (e) {
f3fed050519b073a392ef10048afe1e25700c139Luke Smith results += 'A';
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.source.after('foo', function () { results += '2'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith name : "broadcast",
f3fed050519b073a392ef10048afe1e25700c139Luke Smith setUp : function () {
f3fed050519b073a392ef10048afe1e25700c139Luke Smith test_broadcast0: function () {
f3fed050519b073a392ef10048afe1e25700c139Luke Smith var results = '';
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.source.publish('foo', { broadcast: 0 });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.source.on('foo', function () { results += 'A'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.source.after('foo', function () { results += 'B'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith Y.on('foo', function () { results += '1'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith Y.after('foo', function () { results += '2'; });
0a9c6f9f30a66e52ec4ea4ed93504580b3a5669aAdam Moore Y.Global.on('foo', function () { results += '3'; });
0a9c6f9f30a66e52ec4ea4ed93504580b3a5669aAdam Moore Y.Global.after('foo', function () { results += '4'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith Y.Assert.areSame('AB', results);
f3fed050519b073a392ef10048afe1e25700c139Luke Smith test_broadcast1: function () {
f3fed050519b073a392ef10048afe1e25700c139Luke Smith var results = '';
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.source.publish('foo', { broadcast: 1 });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.source.on('foo', function () { results += 'A'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.source.after('foo', function () { results += 'D'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith Y.on('foo', function () { results += 'B'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith Y.after('foo', function () { results += 'C'; });
0a9c6f9f30a66e52ec4ea4ed93504580b3a5669aAdam Moore Y.Global.on('foo', function () { results += '1'; });
0a9c6f9f30a66e52ec4ea4ed93504580b3a5669aAdam Moore Y.Global.after('foo', function () { results += '2'; });
0a9c6f9f30a66e52ec4ea4ed93504580b3a5669aAdam Moore // Y.Assert.areSame('ABCD', results);
0a9c6f9f30a66e52ec4ea4ed93504580b3a5669aAdam Moore Y.Assert.areSame('ADBC', results);
f3fed050519b073a392ef10048afe1e25700c139Luke Smith test_broadcast2: function () {
f3fed050519b073a392ef10048afe1e25700c139Luke Smith var results = '';
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.source.publish('foo', { broadcast: 2 });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.source.on('foo', function () { results += 'A'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.source.after('foo', function () { results += 'F'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith Y.on('foo', function () { results += 'B'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith Y.after('foo', function () { results += 'E'; });
0a9c6f9f30a66e52ec4ea4ed93504580b3a5669aAdam Moore Y.Global.on('foo', function () { results += 'C'; });
0a9c6f9f30a66e52ec4ea4ed93504580b3a5669aAdam Moore Y.Global.after('foo', function () { results += 'D'; });
0a9c6f9f30a66e52ec4ea4ed93504580b3a5669aAdam Moore // Y.Assert.areSame('ABCDEF', results);
f3fed050519b073a392ef10048afe1e25700c139Luke Smith Y.Assert.areSame('ABCDEF', results);
f3fed050519b073a392ef10048afe1e25700c139Luke Smith test_broadcast1Complete: function () {
f3fed050519b073a392ef10048afe1e25700c139Luke Smith var results = '';
f3fed050519b073a392ef10048afe1e25700c139Luke Smith broadcast: 1,
f3fed050519b073a392ef10048afe1e25700c139Luke Smith emitFacade: true,
f3fed050519b073a392ef10048afe1e25700c139Luke Smith defaultFn: function () { results += 'C'; },
f3fed050519b073a392ef10048afe1e25700c139Luke Smith preventedFn: function () { results += '1'; },
f3fed050519b073a392ef10048afe1e25700c139Luke Smith stoppedFn: function () { results += '2' }
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.source.on('foo', function () { results += 'A'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.source.after('foo', function () { results += 'E'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith Y.on('foo', function () { results += 'B'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith Y.after('foo', function () { results += 'D'; });
0a9c6f9f30a66e52ec4ea4ed93504580b3a5669aAdam Moore Y.Global.on('foo', function () { results += '3'; });
0a9c6f9f30a66e52ec4ea4ed93504580b3a5669aAdam Moore Y.Global.after('foo', function () { results += '4'; });
0a9c6f9f30a66e52ec4ea4ed93504580b3a5669aAdam Moore // Y.Assert.areSame('ABCDE', results);
0a9c6f9f30a66e52ec4ea4ed93504580b3a5669aAdam Moore Y.Assert.areSame('ACBDE', results);
f3fed050519b073a392ef10048afe1e25700c139Luke Smith test_broadcast1Prevented: function () {
f3fed050519b073a392ef10048afe1e25700c139Luke Smith var results = '';
f3fed050519b073a392ef10048afe1e25700c139Luke Smith broadcast: 1,
f3fed050519b073a392ef10048afe1e25700c139Luke Smith emitFacade: true,
f3fed050519b073a392ef10048afe1e25700c139Luke Smith defaultFn: function () { results += '1'; },
f3fed050519b073a392ef10048afe1e25700c139Luke Smith preventedFn: function () { results += 'C'; },
f3fed050519b073a392ef10048afe1e25700c139Luke Smith stoppedFn: function () { results += '2' }
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.source.on('foo', function () { results += 'A'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.source.after('foo', function () { results += '3'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith Y.on('foo', function (e) {
f3fed050519b073a392ef10048afe1e25700c139Luke Smith results += 'B';
f3fed050519b073a392ef10048afe1e25700c139Luke Smith Y.after('foo', function () { results += '4'; });
0a9c6f9f30a66e52ec4ea4ed93504580b3a5669aAdam Moore Y.Global.on('foo', function () { results += '5'; });
0a9c6f9f30a66e52ec4ea4ed93504580b3a5669aAdam Moore Y.Global.after('foo', function () { results += '6'; });
0a9c6f9f30a66e52ec4ea4ed93504580b3a5669aAdam Moore // Y.Assert.areSame('ABC', results);
0a9c6f9f30a66e52ec4ea4ed93504580b3a5669aAdam Moore Y.Assert.areSame('A1BC4', results);
f3fed050519b073a392ef10048afe1e25700c139Luke Smith test_broadcast1StoppedAtSource: function () {
f3fed050519b073a392ef10048afe1e25700c139Luke Smith var results = '';
f3fed050519b073a392ef10048afe1e25700c139Luke Smith broadcast: 1,
f3fed050519b073a392ef10048afe1e25700c139Luke Smith emitFacade: true,
f3fed050519b073a392ef10048afe1e25700c139Luke Smith defaultFn: function () { results += 'C'; },
f3fed050519b073a392ef10048afe1e25700c139Luke Smith preventedFn: function () { results += '1'; },
f3fed050519b073a392ef10048afe1e25700c139Luke Smith stoppedFn: function () { results += 'B' }
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.source.on('foo', function (e) {
f3fed050519b073a392ef10048afe1e25700c139Luke Smith results += 'A';
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.source.after('foo', function () { results += 'D'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith Y.on('foo', function () { results += '1'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith Y.after('foo', function () { results += '2'; });
0a9c6f9f30a66e52ec4ea4ed93504580b3a5669aAdam Moore Y.Global.on('foo', function () { results += '3'; });
0a9c6f9f30a66e52ec4ea4ed93504580b3a5669aAdam Moore Y.Global.after('foo', function () { results += '4'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith // Is this right? stopProp allows defaultFn, but to what level should
f3fed050519b073a392ef10048afe1e25700c139Luke Smith // the after subscribers be executed?
f3fed050519b073a392ef10048afe1e25700c139Luke Smith Y.Assert.areSame('ABCD', results);
f3fed050519b073a392ef10048afe1e25700c139Luke Smith test_broadcast1StoppedAtYUIInstance: function () {
f3fed050519b073a392ef10048afe1e25700c139Luke Smith var results = '';
f3fed050519b073a392ef10048afe1e25700c139Luke Smith broadcast: 1,
f3fed050519b073a392ef10048afe1e25700c139Luke Smith emitFacade: true,
f3fed050519b073a392ef10048afe1e25700c139Luke Smith defaultFn: function () { results += 'D'; },
f3fed050519b073a392ef10048afe1e25700c139Luke Smith preventedFn: function () { results += '1'; },
f3fed050519b073a392ef10048afe1e25700c139Luke Smith stoppedFn: function () { results += 'C' }
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.source.on('foo', function (e) { results += 'A'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.source.after('foo', function () { results += 'F'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith Y.on('foo', function (e) {
f3fed050519b073a392ef10048afe1e25700c139Luke Smith results += 'B';
f3fed050519b073a392ef10048afe1e25700c139Luke Smith Y.after('foo', function () { results += 'E'; });
0a9c6f9f30a66e52ec4ea4ed93504580b3a5669aAdam Moore Y.Global.on('foo', function () { results += '2'; });
0a9c6f9f30a66e52ec4ea4ed93504580b3a5669aAdam Moore Y.Global.after('foo', function () { results += '3'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith // Is this right? stopProp allows defaultFn, but to what level should
0a9c6f9f30a66e52ec4ea4ed93504580b3a5669aAdam Moore // the after subscribers be executed? --- No, broadcast is not bubbling
0a9c6f9f30a66e52ec4ea4ed93504580b3a5669aAdam Moore // Y.Assert.areSame('ABCDEF', results);
0a9c6f9f30a66e52ec4ea4ed93504580b3a5669aAdam Moore Y.Assert.areSame('AD1BCE', results);
f3fed050519b073a392ef10048afe1e25700c139Luke Smith test_broadcast2Complete: function () {
f3fed050519b073a392ef10048afe1e25700c139Luke Smith var results = '';
f3fed050519b073a392ef10048afe1e25700c139Luke Smith broadcast: 2,
f3fed050519b073a392ef10048afe1e25700c139Luke Smith emitFacade: true,
f3fed050519b073a392ef10048afe1e25700c139Luke Smith defaultFn: function () { results += 'C'; },
f3fed050519b073a392ef10048afe1e25700c139Luke Smith preventedFn: function () { results += '1'; },
f3fed050519b073a392ef10048afe1e25700c139Luke Smith stoppedFn: function () { results += '2' }
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.source.on('foo', function () { results += 'A'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.source.after('foo', function () { results += 'E'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith Y.on('foo', function () { results += 'B'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith Y.after('foo', function () { results += 'D'; });
0a9c6f9f30a66e52ec4ea4ed93504580b3a5669aAdam Moore Y.Global.on('foo', function () { results += '3'; });
0a9c6f9f30a66e52ec4ea4ed93504580b3a5669aAdam Moore Y.Global.after('foo', function () { results += '4'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith Y.Assert.areSame('ABCDE', results);
f3fed050519b073a392ef10048afe1e25700c139Luke Smith test_broadcast2PreventedAtYUIInstance: function () {
f3fed050519b073a392ef10048afe1e25700c139Luke Smith var results = '';
f3fed050519b073a392ef10048afe1e25700c139Luke Smith broadcast: 2,
f3fed050519b073a392ef10048afe1e25700c139Luke Smith emitFacade: true,
f3fed050519b073a392ef10048afe1e25700c139Luke Smith defaultFn: function () { results += '1'; },
f3fed050519b073a392ef10048afe1e25700c139Luke Smith preventedFn: function () { results += 'C'; },
f3fed050519b073a392ef10048afe1e25700c139Luke Smith stoppedFn: function () { results += '2' }
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.source.on('foo', function () { results += 'A'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.source.after('foo', function () { results += '3'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith Y.on('foo', function (e) {
f3fed050519b073a392ef10048afe1e25700c139Luke Smith results += 'B';
f3fed050519b073a392ef10048afe1e25700c139Luke Smith Y.after('foo', function () { results += '4'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith // preventDefault does not stop event bubbling
0a9c6f9f30a66e52ec4ea4ed93504580b3a5669aAdam Moore Y.Global.on('foo', function () { results += 'D'; });
0a9c6f9f30a66e52ec4ea4ed93504580b3a5669aAdam Moore Y.Global.after('foo', function () { results += '6'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith Y.Assert.areSame('ABCD', results);
f3fed050519b073a392ef10048afe1e25700c139Luke Smith test_broadcast2PreventedAtYUIGlobal: function () {
f3fed050519b073a392ef10048afe1e25700c139Luke Smith var results = '';
f3fed050519b073a392ef10048afe1e25700c139Luke Smith broadcast: 2,
f3fed050519b073a392ef10048afe1e25700c139Luke Smith emitFacade: true,
f3fed050519b073a392ef10048afe1e25700c139Luke Smith defaultFn: function () { results += '1'; },
f3fed050519b073a392ef10048afe1e25700c139Luke Smith preventedFn: function () { results += 'D'; },
f3fed050519b073a392ef10048afe1e25700c139Luke Smith stoppedFn: function () { results += '2' }
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.source.on('foo', function () { results += 'A'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.source.after('foo', function () { results += '3'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith Y.on('foo', function (e) { results += 'B'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith Y.after('foo', function () { results += '4'; });
0a9c6f9f30a66e52ec4ea4ed93504580b3a5669aAdam Moore Y.Global.on('foo', function (e) {
f3fed050519b073a392ef10048afe1e25700c139Luke Smith results += 'C';
0a9c6f9f30a66e52ec4ea4ed93504580b3a5669aAdam Moore Y.Global.after('foo', function () { results += '5'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith Y.Assert.areSame('ABCD', results);
f3fed050519b073a392ef10048afe1e25700c139Luke Smith test_broadcast2StoppedAtSource: function () {
f3fed050519b073a392ef10048afe1e25700c139Luke Smith var results = '';
f3fed050519b073a392ef10048afe1e25700c139Luke Smith broadcast: 2,
f3fed050519b073a392ef10048afe1e25700c139Luke Smith emitFacade: true,
f3fed050519b073a392ef10048afe1e25700c139Luke Smith defaultFn: function () { results += 'C'; },
f3fed050519b073a392ef10048afe1e25700c139Luke Smith preventedFn: function () { results += '1'; },
f3fed050519b073a392ef10048afe1e25700c139Luke Smith stoppedFn: function () { results += 'B' }
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.source.on('foo', function (e) {
f3fed050519b073a392ef10048afe1e25700c139Luke Smith results += 'A';
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.source.after('foo', function () { results += 'D'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith Y.on('foo', function () { results += '1'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith Y.after('foo', function () { results += '2'; });
0a9c6f9f30a66e52ec4ea4ed93504580b3a5669aAdam Moore Y.Global.on('foo', function () { results += '3'; });
0a9c6f9f30a66e52ec4ea4ed93504580b3a5669aAdam Moore Y.Global.after('foo', function () { results += '4'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith // Is this right? stopProp allows defaultFn, but to what level should
f3fed050519b073a392ef10048afe1e25700c139Luke Smith // the after subscribers be executed?
f3fed050519b073a392ef10048afe1e25700c139Luke Smith Y.Assert.areSame('ABCD', results);
f3fed050519b073a392ef10048afe1e25700c139Luke Smith test_broadcast2StoppedAtYUIInstance: function () {
f3fed050519b073a392ef10048afe1e25700c139Luke Smith var results = '';
f3fed050519b073a392ef10048afe1e25700c139Luke Smith broadcast: 2,
f3fed050519b073a392ef10048afe1e25700c139Luke Smith emitFacade: true,
f3fed050519b073a392ef10048afe1e25700c139Luke Smith defaultFn: function () { results += 'D'; },
f3fed050519b073a392ef10048afe1e25700c139Luke Smith preventedFn: function () { results += '1'; },
f3fed050519b073a392ef10048afe1e25700c139Luke Smith stoppedFn: function () { results += 'C' }
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.source.on('foo', function (e) { results += 'A'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.source.after('foo', function () { results += 'F'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith Y.on('foo', function (e) {
f3fed050519b073a392ef10048afe1e25700c139Luke Smith results += 'B';
f3fed050519b073a392ef10048afe1e25700c139Luke Smith Y.after('foo', function () { results += 'E'; });
0a9c6f9f30a66e52ec4ea4ed93504580b3a5669aAdam Moore Y.Global.on('foo', function () { results += '2'; });
0a9c6f9f30a66e52ec4ea4ed93504580b3a5669aAdam Moore Y.Global.after('foo', function () { results += '3'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith // Is this right? stopProp allows defaultFn, but to what level should
f3fed050519b073a392ef10048afe1e25700c139Luke Smith // the after subscribers be executed?
f3fed050519b073a392ef10048afe1e25700c139Luke Smith Y.Assert.areSame('ABCDEF', results);
f3fed050519b073a392ef10048afe1e25700c139Luke Smith test_broadcast2StoppedAtYUIGlobal: function () {
f3fed050519b073a392ef10048afe1e25700c139Luke Smith var results = '';
f3fed050519b073a392ef10048afe1e25700c139Luke Smith broadcast: 2,
f3fed050519b073a392ef10048afe1e25700c139Luke Smith emitFacade: true,
f3fed050519b073a392ef10048afe1e25700c139Luke Smith defaultFn: function () { results += 'E'; },
f3fed050519b073a392ef10048afe1e25700c139Luke Smith preventedFn: function () { results += '1'; },
f3fed050519b073a392ef10048afe1e25700c139Luke Smith stoppedFn: function () { results += 'D' }
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.source.on('foo', function (e) { results += 'A'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.source.after('foo', function () { results += 'H'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith Y.on('foo', function () { results += 'B'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith Y.after('foo', function () { results += 'G'; });
0a9c6f9f30a66e52ec4ea4ed93504580b3a5669aAdam Moore Y.Global.on('foo', function (e) {
f3fed050519b073a392ef10048afe1e25700c139Luke Smith results += 'C';
f3fed050519b073a392ef10048afe1e25700c139Luke Smith e.stopPropagation(); // should be moot at this point
0a9c6f9f30a66e52ec4ea4ed93504580b3a5669aAdam Moore Y.Global.after('foo', function () { results += 'F'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith // Is this right? stopProp allows defaultFn, but to what level should
f3fed050519b073a392ef10048afe1e25700c139Luke Smith // the after subscribers be executed?
f3fed050519b073a392ef10048afe1e25700c139Luke Smith Y.Assert.areSame('ABCDEFGH', results);
f3fed050519b073a392ef10048afe1e25700c139Luke Smith name : "bubble",
f3fed050519b073a392ef10048afe1e25700c139Luke Smith setUp : function () {
0a9c6f9f30a66e52ec4ea4ed93504580b3a5669aAdam Moore emitFacade: true
0a9c6f9f30a66e52ec4ea4ed93504580b3a5669aAdam Moore emitFacade: true
0a9c6f9f30a66e52ec4ea4ed93504580b3a5669aAdam Moore emitFacade: true
f3fed050519b073a392ef10048afe1e25700c139Luke Smith test_bubbleComplete: function () {
f3fed050519b073a392ef10048afe1e25700c139Luke Smith var results = '';
f3fed050519b073a392ef10048afe1e25700c139Luke Smith broadcast: 0,
f3fed050519b073a392ef10048afe1e25700c139Luke Smith defaultFn : function () { results += 'D'; },
f3fed050519b073a392ef10048afe1e25700c139Luke Smith preventedFn : function () { results += '1'; },
f3fed050519b073a392ef10048afe1e25700c139Luke Smith stoppedFn : function () { results += '2'; }
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.source.on('foo', function () { results += 'A'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.source.after('foo', function () { results += 'G'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.middleMan1.on('foo', function () { results += 'B'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.middleMan1.after('foo', function () { results += 'F'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.middleMan2.on('foo', function () { results += 'C'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.middleMan2.after('foo', function () { results += 'E'; });
0a9c6f9f30a66e52ec4ea4ed93504580b3a5669aAdam Moore Y.Assert.areSame('ABCDGEF', results);
f3fed050519b073a392ef10048afe1e25700c139Luke Smith test_bubblePrevented: function () {
f3fed050519b073a392ef10048afe1e25700c139Luke Smith var results = '';
f3fed050519b073a392ef10048afe1e25700c139Luke Smith broadcast: 0,
f3fed050519b073a392ef10048afe1e25700c139Luke Smith emitFacade: true,
f3fed050519b073a392ef10048afe1e25700c139Luke Smith defaultFn : function () { results += '1'; },
f3fed050519b073a392ef10048afe1e25700c139Luke Smith preventedFn : function () { results += 'C'; },
f3fed050519b073a392ef10048afe1e25700c139Luke Smith stoppedFn : function () { results += '2'; }
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.source.on('foo', function () { results += 'A'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.source.after('foo', function () { results += '3'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.middleMan1.on('foo', function (e) {
f3fed050519b073a392ef10048afe1e25700c139Luke Smith results += 'B';
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.middleMan1.after('foo', function () { results += '4'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.middleMan2.on('foo', function () { results += 'D'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.middleMan2.after('foo', function () { results += '5'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith Y.Assert.areSame('ABCD', results);
f3fed050519b073a392ef10048afe1e25700c139Luke Smith test_bubbleStopped: function () {
f3fed050519b073a392ef10048afe1e25700c139Luke Smith var results = '';
f3fed050519b073a392ef10048afe1e25700c139Luke Smith broadcast: 0,
f3fed050519b073a392ef10048afe1e25700c139Luke Smith emitFacade: true,
f3fed050519b073a392ef10048afe1e25700c139Luke Smith defaultFn : function () { results += 'D'; },
f3fed050519b073a392ef10048afe1e25700c139Luke Smith preventedFn : function () { results += '1'; },
f3fed050519b073a392ef10048afe1e25700c139Luke Smith stoppedFn : function () { results += 'C'; }
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.source.on('foo', function () { results += 'A'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.source.after('foo', function () { results += 'F'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.middleMan1.on('foo', function (e) {
f3fed050519b073a392ef10048afe1e25700c139Luke Smith results += 'B';
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.middleMan1.after('foo', function () { results += 'E'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.middleMan2.on('foo', function () { results += '2'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.middleMan2.after('foo', function () { results += '3'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith Y.Assert.areSame('ABCDEF', results);
f3fed050519b073a392ef10048afe1e25700c139Luke Smith test_bubbleAndBroadcast1Complete: function () {
f3fed050519b073a392ef10048afe1e25700c139Luke Smith var results = '';
f3fed050519b073a392ef10048afe1e25700c139Luke Smith emitFacade: true,
f3fed050519b073a392ef10048afe1e25700c139Luke Smith broadcast: 1,
f3fed050519b073a392ef10048afe1e25700c139Luke Smith defaultFn : function () { results += 'E'; },
f3fed050519b073a392ef10048afe1e25700c139Luke Smith preventedFn : function () { results += '1'; },
f3fed050519b073a392ef10048afe1e25700c139Luke Smith stoppedFn : function () { results += '2'; }
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.source.on('foo', function () { results += 'A'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.source.after('foo', function () { results += 'I'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.middleMan1.on('foo', function (e) { results += 'B'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.middleMan1.after('foo', function () { results += 'H'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.middleMan2.on('foo', function () { results += 'C'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.middleMan2.after('foo', function () { results += 'G'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith Y.on('foo', function () { results += 'D'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith Y.after('foo', function () { results += 'F'; });
0a9c6f9f30a66e52ec4ea4ed93504580b3a5669aAdam Moore Y.Global.on('foo', function () { results += '3'; });
0a9c6f9f30a66e52ec4ea4ed93504580b3a5669aAdam Moore Y.Global.after('foo', function () { results += '4'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith Y.Assert.areSame('ABCDEFGHI', results);
f3fed050519b073a392ef10048afe1e25700c139Luke Smith test_bubbleAndBroadcast1Prevented: function () {
f3fed050519b073a392ef10048afe1e25700c139Luke Smith var results = '';
f3fed050519b073a392ef10048afe1e25700c139Luke Smith emitFacade: true,
f3fed050519b073a392ef10048afe1e25700c139Luke Smith broadcast: 1,
f3fed050519b073a392ef10048afe1e25700c139Luke Smith defaultFn : function () { results += '1'; },
f3fed050519b073a392ef10048afe1e25700c139Luke Smith preventedFn : function () { results += 'C'; },
f3fed050519b073a392ef10048afe1e25700c139Luke Smith stoppedFn : function () { results += '2'; }
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.source.on('foo', function () { results += 'A'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.source.after('foo', function () { results += '3'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.middleMan1.on('foo', function (e) {
f3fed050519b073a392ef10048afe1e25700c139Luke Smith results += 'B';
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.middleMan1.after('foo', function () { results += '4'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.middleMan2.on('foo', function () { results += 'D'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.middleMan2.after('foo', function () { results += '5'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith Y.on('foo', function () { results += 'E'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith Y.after('foo', function () { results += '6'; });
0a9c6f9f30a66e52ec4ea4ed93504580b3a5669aAdam Moore Y.Global.on('foo', function () { results += '7'; });
0a9c6f9f30a66e52ec4ea4ed93504580b3a5669aAdam Moore Y.Global.after('foo', function () { results += '8'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith Y.Assert.areSame('ABCDE', results);
f3fed050519b073a392ef10048afe1e25700c139Luke Smith test_bubbleAndBroadcast1Stopped: function () {
f3fed050519b073a392ef10048afe1e25700c139Luke Smith var results = '';
f3fed050519b073a392ef10048afe1e25700c139Luke Smith emitFacade: true,
f3fed050519b073a392ef10048afe1e25700c139Luke Smith broadcast: 1,
f3fed050519b073a392ef10048afe1e25700c139Luke Smith defaultFn : function () { results += 'E'; },
f3fed050519b073a392ef10048afe1e25700c139Luke Smith preventedFn : function () { results += '1'; },
f3fed050519b073a392ef10048afe1e25700c139Luke Smith stoppedFn : function () { results += 'D'; }
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.source.on('foo', function () { results += 'A'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.source.after('foo', function () { results += 'H'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.middleMan1.on('foo', function (e) { results += 'B'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.middleMan1.after('foo', function () { results += 'G'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.middleMan2.on('foo', function (e) {
f3fed050519b073a392ef10048afe1e25700c139Luke Smith results += 'C';
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.middleMan2.after('foo', function () { results += 'F'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith Y.on('foo', function () { results += '2'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith Y.after('foo', function () { results += '3'; });
0a9c6f9f30a66e52ec4ea4ed93504580b3a5669aAdam Moore Y.Global.on('foo', function () { results += '4'; });
0a9c6f9f30a66e52ec4ea4ed93504580b3a5669aAdam Moore Y.Global.after('foo', function () { results += '5'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith Y.Assert.areSame('ABCDEFGH', results);
f3fed050519b073a392ef10048afe1e25700c139Luke Smith test_bubbleAndBroadcast2Prevented: function () {
f3fed050519b073a392ef10048afe1e25700c139Luke Smith var results = '';
f3fed050519b073a392ef10048afe1e25700c139Luke Smith emitFacade: true,
f3fed050519b073a392ef10048afe1e25700c139Luke Smith broadcast: 2,
f3fed050519b073a392ef10048afe1e25700c139Luke Smith defaultFn : function () { results += '1'; },
f3fed050519b073a392ef10048afe1e25700c139Luke Smith preventedFn : function () { results += 'D'; },
f3fed050519b073a392ef10048afe1e25700c139Luke Smith stoppedFn : function () { results += '2'; }
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.source.on('foo', function () { results += 'A'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.source.after('foo', function () { results += '3'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.middleMan1.on('foo', function (e) { results += 'B'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.middleMan1.after('foo', function () { results += '4'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.middleMan2.on('foo', function (e) {
f3fed050519b073a392ef10048afe1e25700c139Luke Smith results += 'C';
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.middleMan2.after('foo', function () { results += '5'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith Y.on('foo', function () { results += 'E'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith Y.after('foo', function () { results += '6'; });
0a9c6f9f30a66e52ec4ea4ed93504580b3a5669aAdam Moore Y.Global.on('foo', function () { results += 'F'; });
0a9c6f9f30a66e52ec4ea4ed93504580b3a5669aAdam Moore Y.Global.after('foo', function () { results += '7'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith Y.Assert.areSame('ABCDE', results);
f3fed050519b073a392ef10048afe1e25700c139Luke Smith test_bubbleAndBroadcast2Stopped: function () {
f3fed050519b073a392ef10048afe1e25700c139Luke Smith var results = '';
f3fed050519b073a392ef10048afe1e25700c139Luke Smith emitFacade: true,
f3fed050519b073a392ef10048afe1e25700c139Luke Smith broadcast: 2,
f3fed050519b073a392ef10048afe1e25700c139Luke Smith defaultFn : function () { results += 'E'; },
f3fed050519b073a392ef10048afe1e25700c139Luke Smith preventedFn : function () { results += '1'; },
f3fed050519b073a392ef10048afe1e25700c139Luke Smith stoppedFn : function () { results += 'D'; }
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.source.on('foo', function () { results += 'A'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.source.after('foo', function () { results += 'H'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.middleMan1.on('foo', function (e) { results += 'B'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.middleMan1.after('foo', function () { results += 'G'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.middleMan2.on('foo', function (e) {
f3fed050519b073a392ef10048afe1e25700c139Luke Smith results += 'C';
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this.middleMan2.after('foo', function () { results += 'F'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith Y.on('foo', function () { results += '2'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith Y.after('foo', function () { results += '3'; });
0a9c6f9f30a66e52ec4ea4ed93504580b3a5669aAdam Moore Y.Global.on('foo', function () { results += '4'; });
0a9c6f9f30a66e52ec4ea4ed93504580b3a5669aAdam Moore Y.Global.after('foo', function () { results += '5'; });
f3fed050519b073a392ef10048afe1e25700c139Luke Smith Y.Assert.areSame('ABCDEFGH', results);
f3fed050519b073a392ef10048afe1e25700c139Luke Smith// Work around for Y.substitute handling "{key:value}" as tokens
f3fed050519b073a392ef10048afe1e25700c139Luke SmithY.Console.prototype.printLogEntry = function (m) {
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this._htmlEscapeMessage(m),
f3fed050519b073a392ef10048afe1e25700c139Luke Smith cat_class : this.getClassName('entry',m.category),
cb4f4f79feb7498d1f3406b88fb62209e5f5a444Adam Moore var n = Y.Node.create(this.one('entryTemplate').replace(/\{([\w-]+)\}/g,
f3fed050519b073a392ef10048afe1e25700c139Luke Smith function (_,k) { return k in m ? m[k] : ''; }));
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this._addToConsole(n);
f3fed050519b073a392ef10048afe1e25700c139Luke Smith return this;
f3fed050519b073a392ef10048afe1e25700c139Luke Smithvar yconsole = new Y.Console({
f3fed050519b073a392ef10048afe1e25700c139Luke Smith contentBox:"log",
f3fed050519b073a392ef10048afe1e25700c139Luke Smith newestOnTop: false,
f3fed050519b073a392ef10048afe1e25700c139Luke Smith height: '500px'
f3fed050519b073a392ef10048afe1e25700c139Luke Smith if (m.category === 'section') {
f3fed050519b073a392ef10048afe1e25700c139Luke Smith this._addToConsole(Y.Node.create("<h3>"+m.message+"</h3>"));
f3fed050519b073a392ef10048afe1e25700c139Luke Smith return this;
f3fed050519b073a392ef10048afe1e25700c139Luke Smith } else if (m.category === "break") {
f3fed050519b073a392ef10048afe1e25700c139Luke Smith return this;
f3fed050519b073a392ef10048afe1e25700c139Luke Smith } else if (m.category === "info") {
f3fed050519b073a392ef10048afe1e25700c139Luke Smith return this;
f3fed050519b073a392ef10048afe1e25700c139Luke Smith return Y.Console.prototype.printLogEntry.call(this,m);
f3fed050519b073a392ef10048afe1e25700c139Luke SmithY.log("Tests","section","TestRunner");
9a76bc095233b0cb0be3a913f5913bfc72c38b6cSatyen DesaiY.Test.Runner.setName("CustomEventSequence");