view iframe-resizer/test/resize.width.html @ 0:ac5f9272033b draft

first upload
author saskia-hiltemann
date Tue, 01 Jul 2014 11:42:23 -0400
parents
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>