Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

test-iframe-backgrounds.html 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>reveal.js - Test Iframe Backgrounds</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 data-background-iframe="https://revealjs.com">1</section>
  16. <section data-background-iframe="https://revealjs.com">2</section>
  17. <section data-background-iframe="https://revealjs.com" data-preload>3</section>
  18. <section data-background-iframe="https://revealjs.com">4</section>
  19. <section data-background-iframe="https://revealjs.com">5</section>
  20. <section data-background-iframe="https://revealjs.com">6</section>
  21. </div>
  22. </div>
  23. <script src="../dist/reveal.js"></script>
  24. <script>
  25. QUnit.config.testTimeout = 30000;
  26. Reveal.initialize({ viewDistance: 3 }).then( () => {
  27. function getIframe( index ) {
  28. return document.querySelectorAll( '.slide-background' )[index].querySelector( 'iframe' );
  29. }
  30. QUnit.module( 'Iframe' );
  31. QUnit.test( 'Using default settings', function( assert ) {
  32. Reveal.slide(0);
  33. assert.strictEqual( getIframe(1).hasAttribute( 'src' ), false, 'not preloaded when within viewDistance' );
  34. Reveal.slide(1);
  35. assert.strictEqual( getIframe(1).hasAttribute( 'src' ), true, 'loaded when slide becomes visible' );
  36. Reveal.slide(0);
  37. assert.strictEqual( getIframe(1).hasAttribute( 'src' ), false, 'unloaded when slide becomes invisible' );
  38. });
  39. QUnit.test( 'Using data-preload', function( assert ) {
  40. Reveal.slide(1);
  41. assert.strictEqual( getIframe(2).hasAttribute( 'src' ), true, 'preloaded within viewDistance' );
  42. assert.strictEqual( getIframe(1).hasAttribute( 'src' ), true, 'loaded when slide becomes visible' );
  43. Reveal.slide(0);
  44. assert.strictEqual( getIframe(3).hasAttribute( 'src' ), false, 'unloads outside of viewDistance' );
  45. });
  46. QUnit.test( 'Using preloadIframes: true', function( assert ) {
  47. Reveal.configure({ preloadIframes: true });
  48. Reveal.slide(1);
  49. assert.strictEqual( getIframe(0).hasAttribute( 'src' ), true, 'preloaded within viewDistance' );
  50. assert.strictEqual( getIframe(1).hasAttribute( 'src' ), true, 'preloaded within viewDistance' );
  51. assert.strictEqual( getIframe(2).hasAttribute( 'src' ), true, 'preloaded within viewDistance' );
  52. });
  53. QUnit.test( 'Using preloadIframes: false', function( assert ) {
  54. Reveal.configure({ preloadIframes: false });
  55. Reveal.slide(0);
  56. assert.strictEqual( getIframe(1).hasAttribute( 'src' ), false, 'not preloaded within viewDistance' );
  57. assert.strictEqual( getIframe(2).hasAttribute( 'src' ), false, 'not preloaded within viewDistance' );
  58. Reveal.slide(1);
  59. assert.strictEqual( getIframe(1).hasAttribute( 'src' ), true, 'loaded when slide becomes visible' );
  60. });
  61. } );
  62. </script>
  63. </body>
  64. </html>