test-dependencies-async.html 1.9 KB

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