Christophe Dervieux | e1893ae | 2021-10-07 17:09:02 +0200 | [diff] [blame^] | 1 | <!doctype html> |
| 2 | <html lang="en"> |
| 3 | |
| 4 | <head> |
| 5 | <meta charset="utf-8"> |
| 6 | |
| 7 | <title>reveal.js - Test Async Dependencies</title> |
| 8 | |
| 9 | <link rel="stylesheet" href="../dist/reveal.css"> |
| 10 | <link rel="stylesheet" href="../node_modules/qunit/qunit/qunit.css"> |
| 11 | <script src="../node_modules/qunit/qunit/qunit.js"></script> |
| 12 | </head> |
| 13 | |
| 14 | <body style="overflow: auto;"> |
| 15 | |
| 16 | <div id="qunit"></div> |
| 17 | <div id="qunit-fixture"></div> |
| 18 | |
| 19 | <div class="reveal" style="display: none;"> |
| 20 | |
| 21 | <div class="slides"> |
| 22 | |
| 23 | <section>Slide content</section> |
| 24 | |
| 25 | </div> |
| 26 | |
| 27 | </div> |
| 28 | |
| 29 | <script src="../dist/reveal.js"></script> |
| 30 | <script> |
| 31 | var externalScriptSequence = ''; |
| 32 | var scriptCount = 0; |
| 33 | |
| 34 | QUnit.config.autostart = false; |
| 35 | QUnit.module( 'Async Dependencies' ); |
| 36 | |
| 37 | QUnit.test( 'Async scripts are loaded', function( assert ) { |
| 38 | assert.expect( 5 ); |
| 39 | var done = assert.async( 5 ); |
| 40 | |
| 41 | function callback( event ) { |
| 42 | if( externalScriptSequence.length === 1 ) { |
| 43 | assert.ok( externalScriptSequence === 'A', 'first callback was sync script' ); |
| 44 | done(); |
| 45 | } |
| 46 | else { |
| 47 | assert.ok( true, 'async script loaded' ); |
| 48 | done(); |
| 49 | } |
| 50 | |
| 51 | if( externalScriptSequence.length === 4 ) { |
| 52 | assert.ok( externalScriptSequence.indexOf( 'A' ) !== -1 && |
| 53 | externalScriptSequence.indexOf( 'B' ) !== -1 && |
| 54 | externalScriptSequence.indexOf( 'C' ) !== -1 && |
| 55 | externalScriptSequence.indexOf( 'D' ) !== -1, 'four unique scripts were loaded' ); |
| 56 | done(); |
| 57 | } |
| 58 | |
| 59 | scriptCount ++; |
| 60 | } |
| 61 | |
| 62 | Reveal.initialize({ |
| 63 | dependencies: [ |
| 64 | { src: 'assets/external-script-a.js', async: false, callback: callback }, |
| 65 | { src: 'assets/external-script-b.js', async: true, callback: callback }, |
| 66 | { src: 'assets/external-script-c.js', async: true, callback: callback }, |
| 67 | { src: 'assets/external-script-d.js', async: true, callback: callback } |
| 68 | ] |
| 69 | }); |
| 70 | }); |
| 71 | |
| 72 | QUnit.start(); |
| 73 | |
| 74 | </script> |
| 75 | |
| 76 | </body> |
| 77 | </html> |