blob: de1404212aedbcdea199d597fa20e0c2325e3ddf [file] [log] [blame]
Christophe Dervieuxe1893ae2021-10-07 17:09:02 +02001<!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
Marc Kupietz09b75752023-10-07 09:32:19 +020034 QUnit.config.testTimeout = 30000;
Christophe Dervieuxe1893ae2021-10-07 17:09:02 +020035 QUnit.config.autostart = false;
36 QUnit.module( 'Async Dependencies' );
37
38 QUnit.test( 'Async scripts are loaded', function( assert ) {
39 assert.expect( 5 );
40 var done = assert.async( 5 );
41
42 function callback( event ) {
43 if( externalScriptSequence.length === 1 ) {
44 assert.ok( externalScriptSequence === 'A', 'first callback was sync script' );
45 done();
46 }
47 else {
48 assert.ok( true, 'async script loaded' );
49 done();
50 }
51
52 if( externalScriptSequence.length === 4 ) {
53 assert.ok( externalScriptSequence.indexOf( 'A' ) !== -1 &&
54 externalScriptSequence.indexOf( 'B' ) !== -1 &&
55 externalScriptSequence.indexOf( 'C' ) !== -1 &&
56 externalScriptSequence.indexOf( 'D' ) !== -1, 'four unique scripts were loaded' );
57 done();
58 }
59
60 scriptCount ++;
61 }
62
63 Reveal.initialize({
64 dependencies: [
65 { src: 'assets/external-script-a.js', async: false, callback: callback },
66 { src: 'assets/external-script-b.js', async: true, callback: callback },
67 { src: 'assets/external-script-c.js', async: true, callback: callback },
68 { src: 'assets/external-script-d.js', async: true, callback: callback }
69 ]
70 });
71 });
72
73 QUnit.start();
74
75 </script>
76
77 </body>
78</html>