diff options
author | Richard Gibson <richard.gibson@gmail.com> | 2017-01-09 11:33:39 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-09 11:33:39 -0800 |
commit | 9d822bc1c13dd3393b418210a99537c22c06f2c3 (patch) | |
tree | e0ab229ea58b26d94306d23afe420ebfe0e87113 /test/unit/callbacks.js | |
parent | 14b393d0d64e119db7754b1075317a673810929c (diff) | |
download | jquery-9d822bc1c13dd3393b418210a99537c22c06f2c3.tar.gz jquery-9d822bc1c13dd3393b418210a99537c22c06f2c3.zip |
Callbacks: Prevent add() from unlocking with-memory lists
Fixes gh-3469
Closes gh-3470
Diffstat (limited to 'test/unit/callbacks.js')
-rw-r--r-- | test/unit/callbacks.js | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/test/unit/callbacks.js b/test/unit/callbacks.js index c6c379ded..04d44443d 100644 --- a/test/unit/callbacks.js +++ b/test/unit/callbacks.js @@ -366,3 +366,24 @@ QUnit.test( "jQuery.Callbacks() - disabled callback doesn't fire (gh-1790)", fun cb.fire(); assert.ok( !fired, "Disabled callback function didn't fire" ); } ); + +QUnit.test( "jQuery.Callbacks() - list with memory stays locked (gh-3469)", function( assert ) { + + assert.expect( 3 ); + + var cb = jQuery.Callbacks( "memory" ), + fired = 0, + count1 = function() { fired += 1; }, + count2 = function() { fired += 10; }; + + cb.add( count1 ); + cb.fire(); + assert.equal( fired, 1, "Pre-lock() fire" ); + + cb.lock(); + cb.add( count2 ); + assert.equal( fired, 11, "Post-lock() add" ); + + cb.fire(); + assert.equal( fired, 11, "Post-lock() fire ignored" ); +} ); |