view iframe-resizer/test/resize.width.html @ 8:86219e4aa239 draft

Uploaded
author saskia-hiltemann
date Mon, 28 Aug 2017 10:23:21 -0400
parents ac5f9272033b
children
line wrap: on
line source

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>QUnit LoadHide</title>
  <link rel="stylesheet" href="resources/qunit.css">
</head>
<body>
  <div id="qunit"></div>
  <div id="qunit-fixture">

    <div style="width:600px;">
      <iframe src="resources/frame.content.html" width="100%" scrolling="no"></iframe>
    </div>

  </div>
  <script src="resources/qunit.js"></script>
  <script src="resources/jquery.js"></script>
  <script src="../js/iframeResizer.min.js"></script>
  <script>
  
    'use strict';
    var msgId = '[iFrameSizerTest]:';

    function resize(size){
      console.info('Size width:'+size);
      $('#qunit-fixture > div').width(size);
    }
    
    asyncTest( "iFrame Resize Event", function() {

      var callbackCounter = 0;

      $('iframe').iFrameResize({
        log:true,
        interval:1000,
        heightCalculationMethod:'max',
        resizedCallback:function(messageData){
          
          switch  (''+(++callbackCounter)){
            case '1':
              setTimeout(function(){resize(300);},100);
              break;
            case '2':
              setTimeout(function(){resize(600)},100);
              ok( 'resize' === messageData.type, '1 Received '+messageData.type+' message back from iFrame. Expected resize');
              ok( '300' === messageData.width, '2 iFrame width = '+messageData.width+'. Expected 300.');
              break;
            default:
              ok( 'resetPage' === messageData.type, '3 Received '+messageData.type+' message back from iFrame. Expected resetPage');
              if ('600' === messageData.width){
                ok( '600' === messageData.width, '4 iFrame width = '+messageData.width+'. Expected 600.');
                start();
              }
          }
        }
      });
    });

		
  </script>
</body>
</html>