extensions.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /**
  2. * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. /* globals bender, CKEDITOR */
  6. 'use strict';
  7. ( function() {
  8. // Make Bender wait to start running tests.
  9. var done = bender.defer();
  10. // Wait for the "ckeditor" module to be ready to start testing.
  11. CKEDITOR.require( [ 'ckeditor' ], done );
  12. /**
  13. * AMD tools related to CKEditor.
  14. */
  15. bender.amd = {
  16. /**
  17. * Gets an object which holds the CKEditor modules guaranteed to be loaded before tests start.
  18. *
  19. * @params {...String} module The name of the module to load.
  20. * @returns {Object} The object that will hold the loaded modules.
  21. */
  22. require: function() {
  23. var modules = {};
  24. var done = bender.defer();
  25. var names = [].slice.call( arguments );
  26. // To avoid race conditions with required modules, require `ckeditor` first and then others. This guarantees
  27. // that `ckeditor` will be loaded before any other module.
  28. CKEDITOR.require( [ 'ckeditor' ], function() {
  29. CKEDITOR.require( names, function() {
  30. for ( var i = 0; i < names.length; i++ ) {
  31. modules[ names[ i ] ] = arguments[ i ] ;
  32. }
  33. // Finally give green light for tests to start.
  34. done();
  35. } );
  36. } );
  37. return modules;
  38. }
  39. };
  40. } )();