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. /* jshint node: false, browser: true, globalstrict: true */
  6. /* globals bender, CKEDITOR */
  7. 'use strict';
  8. ( () => {
  9. // Make Bender wait to start running tests.
  10. const done = bender.defer();
  11. // Wait for the "ckeditor" module to be ready to start testing.
  12. CKEDITOR.require( [ 'ckeditor' ], done );
  13. /**
  14. * AMD tools related to CKEditor.
  15. */
  16. bender.amd = {
  17. /**
  18. * Gets an object which holds the CKEditor modules guaranteed to be loaded before tests start.
  19. *
  20. * @params {...String} module The name of the module to load.
  21. * @returns {Object} The object that will hold the loaded modules.
  22. */
  23. require() {
  24. const modules = {};
  25. const done = bender.defer();
  26. const names = [].slice.call( arguments );
  27. // To avoid race conditions with required modules, require `ckeditor` first and then others. This guarantees
  28. // that `ckeditor` will be loaded before any other module.
  29. CKEDITOR.require( [ 'ckeditor' ], function() {
  30. CKEDITOR.require( names, function() {
  31. for ( let i = 0; i < names.length; i++ ) {
  32. modules[ names[ i ] ] = arguments[ i ] ;
  33. }
  34. // Finally give green light for tests to start.
  35. done();
  36. } );
  37. } );
  38. return modules;
  39. }
  40. };
  41. } )();