aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorOleg Gaidarenko <markelog@gmail.com>2015-11-13 16:38:00 +0300
committerOleg Gaidarenko <markelog@gmail.com>2015-11-13 20:04:19 +0300
commit793925ff3be0a185ba5d2c733252eac324fb3cd5 (patch)
tree22a7229e998ebb0e189d632b0b6e3bd23f5fc1a4 /test
parentcad0f469a8b6785643fe2ca08fe1dae3e49046b1 (diff)
downloadjquery-793925ff3be0a185ba5d2c733252eac324fb3cd5.tar.gz
jquery-793925ff3be0a185ba5d2c733252eac324fb3cd5.zip
Revert "Callbacks: Don't abort execution on .lock()"
This reverts commit 32bf9178cace8c52a31c468a28adde9a4fdc4671.
Diffstat (limited to 'test')
-rw-r--r--test/unit/callbacks.js64
1 files changed, 27 insertions, 37 deletions
diff --git a/test/unit/callbacks.js b/test/unit/callbacks.js
index c6c379ded..0bae02a87 100644
--- a/test/unit/callbacks.js
+++ b/test/unit/callbacks.js
@@ -65,7 +65,7 @@ jQuery.each( tests, function( strFlags, resultString ) {
QUnit.test( "jQuery.Callbacks( " + showFlags( flags ) + " ) - " + filterLabel, function( assert ) {
- assert.expect( 29 );
+ assert.expect( 28 );
var cblist,
results = resultString.split( /\s+/ );
@@ -76,20 +76,20 @@ jQuery.each( tests, function( strFlags, resultString ) {
assert.strictEqual( cblist.locked(), false, ".locked() initially false" );
assert.strictEqual( cblist.disabled(), false, ".disabled() initially false" );
assert.strictEqual( cblist.fired(), false, ".fired() initially false" );
- cblist.add( function( str ) {
+ cblist.add(function( str ) {
output += str;
- } );
+ });
assert.strictEqual( cblist.fired(), false, ".fired() still false after .add" );
cblist.fire( "A" );
assert.strictEqual( output, "XA", "Basic binding and firing" );
assert.strictEqual( cblist.fired(), true, ".fired() detects firing" );
output = "X";
cblist.disable();
- cblist.add( function( str ) {
+ cblist.add(function( str ) {
output += str;
- } );
+ });
assert.strictEqual( output, "X", "Adding a callback after disabling" );
- cblist.fire( "A" );
+ cblist.fire("A");
assert.strictEqual( output, "X", "Firing after disabling" );
assert.strictEqual( cblist.disabled(), true, ".disabled() becomes true" );
assert.strictEqual( cblist.locked(), true, "disabling locks" );
@@ -113,20 +113,20 @@ jQuery.each( tests, function( strFlags, resultString ) {
// Basic binding and firing (context, arguments)
output = "X";
cblist = jQuery.Callbacks( flags );
- cblist.add( function() {
+ cblist.add(function() {
assert.equal( this, window, "Basic binding and firing (context)" );
output += Array.prototype.join.call( arguments, "" );
- } );
+ });
cblist.fireWith( window, [ "A", "B" ] );
assert.strictEqual( output, "XAB", "Basic binding and firing (arguments)" );
// fireWith with no arguments
output = "";
cblist = jQuery.Callbacks( flags );
- cblist.add( function() {
+ cblist.add(function() {
assert.equal( this, window, "fireWith with no arguments (context is window)" );
assert.strictEqual( arguments.length, 0, "fireWith with no arguments (no arguments)" );
- } );
+ });
cblist.fireWith();
// Basic binding, removing and firing
@@ -150,34 +150,24 @@ jQuery.each( tests, function( strFlags, resultString ) {
// Locking
output = "X";
cblist = jQuery.Callbacks( flags );
- cblist.add( function( str ) {
+ cblist.add(function( str ) {
output += str;
- } );
+ });
cblist.lock();
- cblist.add( function( str ) {
+ cblist.add(function( str ) {
output += str;
- } );
- cblist.fire( "A" );
- cblist.add( function( str ) {
+ });
+ cblist.fire("A");
+ cblist.add(function( str ) {
output += str;
- } );
+ });
assert.strictEqual( output, "X", "Lock early" );
assert.strictEqual( cblist.locked(), true, "Locking reflected in accessor" );
- // Locking while firing (gh-1990)
- output = "X";
- cblist = jQuery.Callbacks( flags );
- cblist.add( cblist.lock );
- cblist.add( function( str ) {
- output += str;
- } );
- cblist.fire( "A" );
- assert.strictEqual( output, "XA", "Locking doesn't abort execution (gh-1990)" );
-
// Ordering
output = "X";
cblist = jQuery.Callbacks( flags );
- cblist.add( function() {
+ cblist.add(function() {
cblist.add( outputC );
outputA();
}, outputB );
@@ -186,7 +176,7 @@ jQuery.each( tests, function( strFlags, resultString ) {
// Add and fire again
output = "X";
- cblist.add( function() {
+ cblist.add(function() {
cblist.add( outputC );
outputA();
}, outputB );
@@ -199,23 +189,23 @@ jQuery.each( tests, function( strFlags, resultString ) {
// Multiple fire
output = "X";
cblist = jQuery.Callbacks( flags );
- cblist.add( function( str ) {
+ cblist.add(function( str ) {
output += str;
- } );
- cblist.fire( "A" );
+ });
+ cblist.fire("A");
assert.strictEqual( output, "XA", "Multiple fire (first fire)" );
output = "X";
- cblist.add( function( str ) {
+ cblist.add(function( str ) {
output += str;
- } );
+ });
assert.strictEqual( output, results.shift(), "Multiple fire (first new callback)" );
output = "X";
- cblist.fire( "B" );
+ cblist.fire("B");
assert.strictEqual( output, results.shift(), "Multiple fire (second fire)" );
output = "X";
- cblist.add( function( str ) {
+ cblist.add(function( str ) {
output += str;
- } );
+ });
assert.strictEqual( output, results.shift(), "Multiple fire (second new callback)" );
// Return false