test-async-dependencies.html 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>reveal.js - Test Async Dependencies</title>
  6. <link rel="stylesheet" href="../css/reveal.css">
  7. <link rel="stylesheet" href="qunit-2.5.0.css">
  8. </head>
  9. <body style="overflow: auto;">
  10. <div id="qunit"></div>
  11. <div id="qunit-fixture"></div>
  12. <div class="reveal" style="display: none;">
  13. <div class="slides">
  14. <section>Slide content</section>
  15. </div>
  16. </div>
  17. <script src="../js/reveal.js"></script>
  18. <script src="qunit-2.5.0.js"></script>
  19. <script>
  20. window.externalScriptSequence = '';
  21. QUnit.module( 'Async Dependencies' );
  22. var scriptCount = 0;
  23. QUnit.test( 'Async scripts are loaded', function( assert ) {
  24. assert.expect( 5 );
  25. var done = assert.async( 5 );
  26. function callback( event ) {
  27. if( window.externalScriptSequence.length === 1 ) {
  28. assert.ok( window.externalScriptSequence === 'A', 'first callback was sync script' );
  29. }
  30. else {
  31. assert.ok( true, 'async script loaded' );
  32. }
  33. if( window.externalScriptSequence.length === 4 ) {
  34. assert.ok( window.externalScriptSequence.indexOf( 'A' ) !== -1 &&
  35. window.externalScriptSequence.indexOf( 'B' ) !== -1 &&
  36. window.externalScriptSequence.indexOf( 'C' ) !== -1 &&
  37. window.externalScriptSequence.indexOf( 'D' ) !== -1, 'four unique scripts were loaded' );
  38. }
  39. done();
  40. scriptCount ++;
  41. }
  42. Reveal.initialize({
  43. dependencies: [
  44. { src: 'assets/external-script-a.js', async: false, callback: callback },
  45. { src: 'assets/external-script-b.js', async: true, callback: callback },
  46. { src: 'assets/external-script-c.js', async: true, callback: callback },
  47. { src: 'assets/external-script-d.js', async: true, callback: callback }
  48. ]
  49. });
  50. });
  51. </script>
  52. </body>
  53. </html>