File tree Expand file tree Collapse file tree 2 files changed +48
-0
lines changed Expand file tree Collapse file tree 2 files changed +48
-0
lines changed Original file line number Diff line number Diff line change 1+ // Navigation helper for the test iframe. Queues navigation actions and
2+ // callbacks, then executes them serially with respect to async. This is to
3+ // avoid deep nesting of callbacks in tests.
4+ //
5+ // After last successful navigation, asyncTest is automatically resumed.
6+ //
7+ // Usage:
8+ //
9+ // navigate(this.frame)
10+ // .pjax(pjaxOptions, function(frame){ ... }
11+ // .back(-1, function(frame){ ... }
12+ //
13+ function navigate ( frame ) {
14+ var queue = [ ]
15+ var api = { }
16+
17+ api . pjax = function ( options , callback ) {
18+ queue . push ( [ options , callback ] )
19+ return api
20+ }
21+ api . back = api . pjax
22+
23+ var workOff = function ( ) {
24+ var item = queue . shift ( )
25+ if ( ! item ) {
26+ start ( )
27+ return
28+ }
29+
30+ var target = item [ 0 ] , callback = item [ 1 ]
31+
32+ frame . $ ( frame . document ) . one ( "pjax:end" , function ( ) {
33+ if ( callback ) callback ( frame )
34+ setTimeout ( workOff , 0 )
35+ } )
36+
37+ if ( typeof target == "number" ) {
38+ frame . history . go ( target )
39+ } else {
40+ frame . $ . pjax ( target )
41+ }
42+ }
43+
44+ setTimeout ( workOff , 0 )
45+
46+ return api
47+ }
Original file line number Diff line number Diff line change 99 < script type ="text/javascript " src ="/vendor/qunit.js "> </ script >
1010 < script type ="text/javascript "> QUnit . config . testTimeout = 10000 </ script >
1111 < script type ="text/javascript " src ="/jquery.pjax.js "> </ script >
12+ < script type ="text/javascript " src ="/test/unit/helpers.js "> </ script >
1213 < script type ="text/javascript " src ="/test/unit/pjax.js "> </ script >
1314 < script type ="text/javascript " src ="/test/unit/fn_pjax.js "> </ script >
1415 < script type ="text/javascript " src ="/test/unit/pjax_fallback.js "> </ script >
You can’t perform that action at this time.
0 commit comments