Skip to content

Commit 339d419

Browse files
committed
Merge branch 't/12935' into major
2 parents dc3ecf4 + 5c7fed3 commit 339d419

File tree

2 files changed

+62
-51
lines changed

2 files changed

+62
-51
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
"version": "4.5.0",
44
"description": "The development version of CKEditor - JavaScript WYSIWYG web text editor.",
55
"devDependencies": {
6-
"benderjs": "~0.2.1",
6+
"benderjs": "~0.2.2",
77
"benderjs-jquery": "~0.3.0",
88
"benderjs-sinon": "~0.2.1",
9-
"benderjs-yui": "~0.2.3",
9+
"benderjs-yui": "~0.2.4",
1010
"grunt": "~0",
1111
"grunt-contrib-imagemin": "^0.8.1",
1212
"grunt-jscs": "~1",

tests/_benderjs/ckeditor/static/extensions.js

Lines changed: 60 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
YTest = bender.Y.Test,
1111
i;
1212

13-
// override and extend assertions
13+
// Override and extend assertions.
1414
window.assert = bender.assert;
1515
window.arrayAssert = bender.arrayAssert;
1616
window.objectAssert = bender.objectAssert;
1717

18-
// clean-up data from previous tests if available
19-
// TODO check if this could be deleted after separating test context from parent
18+
// Clean-up data from previous tests if available.
19+
// TODO check if this could be deleted after separating test context from parent.
2020
if ( bender.editor ) {
2121
delete bender.editor;
2222
}
@@ -109,7 +109,8 @@
109109
};
110110

111111
/**
112-
* Asserts that HTML data are the same. Use {@link bender.tools.compatHtml} to sort attributes, fix styles and encode Nbsp.
112+
* Asserts that HTML data are the same. Use {@link bender.tools.compatHtml} to sort attributes,
113+
* fix styles and encode `nbsp`.
113114
*
114115
* @param {String} expected
115116
* @param {String} actual
@@ -119,7 +120,7 @@
119120
assert.areSame( expected, bender.tools.compatHtml( actual, false, true, false, true, true ), message );
120121
};
121122

122-
// add support test ignore
123+
// Add support test ignore.
123124
YUITest.Ignore = function() {};
124125

125126
bender.assert.ignore = function() {
@@ -153,7 +154,7 @@
153154

154155
if ( typeof test == 'string' ) {
155156
updateResult( node.parent, test );
156-
// Ignore all tests in this whole test case
157+
// Ignore all tests in this whole test case.
157158
} else {
158159
for ( name in test ) {
159160
if ( typeof test[ name ] == 'function' && name.match( /^test/ ) ) {
@@ -165,47 +166,47 @@
165166
};
166167

167168
YTest.Runner._resumeTest = function( segment ) {
168-
//get relevant information
169+
// Get relevant information.
169170
var node = this._cur,
170171
failed = false,
171172
ignored = false,
172173
error = null,
173174
testName, testCase, shouldFail, shouldError;
174175

175-
//we know there's no more waiting now
176+
// We know there's no more waiting now.
176177
this._waiting = false;
177178

178-
//if there's no node, it probably means a wait() was called after resume()
179+
// If there's no node, it probably means a wait() was called after resume().
179180
if ( !node ) {
180181
return;
181182
}
182183

183184
testName = node.testObject;
184185
testCase = node.parent.testObject;
185186

186-
//cancel other waits if available
187+
// Cancel other waits if available.
187188
if ( testCase.__yui_wait ) {
188189
clearTimeout( testCase.__yui_wait );
189190
delete testCase.__yui_wait;
190191
}
191192

192-
//get the "should" test cases
193+
// Get the "should" test cases.
193194
shouldFail = testName.indexOf( 'fail:' ) === 0 ||
194195
( testCase._should.fail || {} )[ testName ];
195196

196197
shouldError = ( testCase._should.error || {} )[ testName ];
197198

198199
this._inTest = true;
199200

200-
//try the test
201+
// Try the test.
201202
try {
202-
//run the test
203+
// Run the test.
203204
segment.call( testCase, this._context );
204205

205-
//if the test hasn't already failed and doesn't have any asserts...
206+
// If the test hasn't already failed and doesn't have any asserts...
206207
if ( !YUITest.Assert._getCount() && !this._ignoreEmpty ) {
207208
throw new YUITest.AssertionError( 'Test has no asserts.' );
208-
//if it should fail, and it got here, then it's a fail because it didn't
209+
// If it should fail, and it got here, then it's a fail because it didn't.
209210
} else if ( shouldFail ) {
210211
error = new YUITest.ShouldFail();
211212
failed = true;
@@ -214,7 +215,7 @@
214215
failed = true;
215216
}
216217
} catch ( thrown ) {
217-
//cancel any pending waits, the test already failed
218+
// Cancel any pending waits, the test already failed.
218219
if ( testCase.__yui_wait ) {
219220
clearTimeout( testCase.__yui_wait );
220221
delete testCase.__yui_wait;
@@ -231,7 +232,7 @@
231232
} else if ( thrown instanceof YUITest.Wait ) {
232233
if ( typeof thrown.segment == 'function' ) {
233234
if ( typeof thrown.delay == 'number' ) {
234-
//some environments don't support setTimeout
235+
// Some environments don't support setTimeout.
235236
if ( typeof setTimeout != 'undefined' ) {
236237
testCase.__yui_wait = setTimeout( function() {
237238
YUITest.TestRunner._resumeTest( thrown.segment );
@@ -246,7 +247,7 @@
246247

247248
return;
248249
} else {
249-
//first check to see if it should error
250+
// First check to see if it should error.
250251
if ( !shouldError ) {
251252
error = new YUITest.UnexpectedError( thrown );
252253
failed = true;
@@ -270,21 +271,21 @@
270271
this._inTest = false;
271272

272273
if ( !ignored ) {
273-
//fire appropriate event
274+
// Fire appropriate event.
274275
this.fire( {
275276
type: failed ? this.TEST_FAIL_EVENT : this.TEST_PASS_EVENT,
276277
testCase: testCase,
277278
testName: testName,
278279
error: failed ? error : undefined
279280
} );
280281

281-
//run the tear down
282+
// Run the tear down.
282283
this._execNonTestMethod( node.parent, 'tearDown', false );
283284

284-
//reset the assert count
285+
// Reset the assert count.
285286
YUITest.Assert._reset();
286287

287-
//update results
288+
// Update results.
288289
node.parent.results[ testName ] = {
289290
result: failed ? 'fail' : 'pass',
290291
message: error ? error.getMessage() : 'Test passed',
@@ -302,7 +303,7 @@
302303
node.parent.results.total++;
303304
}
304305

305-
//set timeout not supported in all environments
306+
// Set timeout not supported in all environments.
306307
if ( typeof setTimeout != 'undefined' ) {
307308
setTimeout( function() {
308309
YUITest.TestRunner._run();
@@ -397,7 +398,7 @@
397398

398399
if ( bender.plugins ) {
399400
toLoad++;
400-
bender.deferred = true;
401+
defer();
401402

402403
CKEDITOR.plugins.load( config.plugins, onLoad );
403404
}
@@ -408,7 +409,7 @@
408409
}
409410

410411
toLoad++;
411-
bender.deferred = true;
412+
defer();
412413

413414
CKEDITOR.scriptLoader.load( config.adapters, onLoad );
414415
}
@@ -419,36 +420,40 @@
419420
}
420421

421422
if ( !toLoad ) {
422-
if ( bender.deferred ) {
423-
delete bender.deferred;
424-
}
425-
426-
bender.startRunner();
423+
startRunner();
427424
}
428425
}
429426
};
430427

431-
// keep reference to adapter's test function
432-
bender.orgTest = bender.test;
428+
var unlock, deferredTests;
433429

434-
bender.test = function( tests ) {
435-
if ( bender.deferred ) {
436-
delete bender.deferred;
430+
// Defers Bender's startup.
431+
function defer() {
432+
if ( !unlock ) {
433+
unlock = bender.defer();
434+
}
435+
}
436+
437+
// Keep a reference to the original bender.test function.
438+
var orgTest = bender.test;
439+
440+
// Flag saying if we need to restart the tests, e.g. when bender.test was executed asynchronously.
441+
var restart = false;
437442

438-
bender.deferredTests = tests;
443+
bender.test = function( tests ) {
444+
if ( unlock && !restart ) {
445+
deferredTests = tests;
439446
} else {
440-
bender.startRunner( tests );
447+
startRunner( tests );
441448
}
442449
};
443450

444-
bender.startRunner = function( tests ) {
445-
tests = tests || bender.deferredTests;
446-
447-
if ( bender.deferredTests ) {
448-
delete bender.deferredTests;
449-
}
451+
function startRunner( tests ) {
452+
tests = tests || deferredTests;
450453

454+
// startRunner was executed but there were no tests available yet.
451455
if ( !tests ) {
456+
restart = true;
452457
return;
453458
}
454459

@@ -477,9 +482,15 @@
477482
}
478483
}
479484

480-
bender.orgTest( tests );
485+
// Run the original bender.test function.
486+
orgTest( tests );
481487

482-
// async:init stage 1: set up bender.editor
488+
// Unlock Bender startup.
489+
if ( unlock ) {
490+
unlock();
491+
}
492+
493+
// async:init stage 1: set up bender.editor.
483494
function setUpEditor() {
484495
if ( !bender.editor ) {
485496
// If there is no bender.editor jump to stage 2.
@@ -494,7 +505,7 @@
494505
} );
495506
}
496507

497-
// async:init stage 2: set up bender.editors
508+
// async:init stage 2: set up bender.editors.
498509
function setUpEditors() {
499510
if ( !bender.editors ) {
500511
// If there is no bender.editor jump to stage 3.
@@ -544,7 +555,7 @@
544555
}
545556
}
546557

547-
// async:init stage 3: call original async/async:init and finish async:init (testCase.callback).
558+
// async:init stage 3: call original async/async:init and finish async:init (testCase.callback).
548559
function callback() {
549560
if ( bender._init ) {
550561
var init = bender._init;
@@ -565,7 +576,7 @@
565576
}
566577
}
567578
}
568-
};
579+
}
569580

570581
function onDocumentReady( callback ) {
571582
function complete() {
@@ -620,7 +631,7 @@
620631
};
621632
} )( this, bender );
622633

623-
// workaround for IE8 - window.resume / window.wait won't work in this environment...
634+
// Workaround for IE8 - window.resume / window.wait won't work in this environment...
624635
var resume = bender.Y.Test.Case.prototype.resume = ( function() { // jshint ignore:line
625636
var org = bender.Y.Test.Case.prototype.resume;
626637

0 commit comments

Comments
 (0)