comparison iframe-resizer/test/margin.html @ 0:ac5f9272033b draft

first upload
author saskia-hiltemann
date Tue, 01 Jul 2014 11:42:23 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:ac5f9272033b
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <meta charset="utf-8">
5 <title>QUnit LoadHide</title>
6 <link rel="stylesheet" href="resources/qunit.css">
7 </head>
8 <body>
9 <div id="qunit"></div>
10 <div id="qunit-fixture">
11
12 <div style="width:1600px;">
13 <iframe src="resources/frame.content.html" width="100%" scrolling="no"></iframe>
14 </div>
15
16 </div>
17 <script src="resources/qunit.js"></script>
18 <script src="resources/jquery.js"></script>
19 <script src="resources/testLib.js"></script>
20 <script src="../js/iframeResizer.min.js"></script>
21 <script>
22
23 'use strict';
24 var msgId = '[iFrameSizerTest]:';
25
26 var margins = [
27 '10px 5em',
28 '15px 5ex',
29 '20px',
30 '25px',
31 '75px'
32 ];
33
34 function Counter(){
35 var i=0;
36 return function(){return i++};
37 }
38
39 var counter = Counter();
40
41 for (var i=0; i !== margins.length; i++){
42 asyncTest( "Margin " + margins[i], function() {
43 var
44 height = 0,
45 i = counter(), //counteract async
46 margin = margins[i];
47
48 iFrameResize({
49 log:true,
50 enablePublicMethods:true,
51 bodyMargin:margin,
52 resizedCallback:function(messageData){
53 ok( true, 'Receive message back from iFrame.' );
54 height=parseInt(messageData.height,10);
55 sendMessage('chkHeight');
56 },
57 messageCallback:function(messageData){
58 var
59 marginCheck = 2 *parseInt(margin,10),
60 bodyHeight = parseInt(messageData.message,10);
61
62 ok(height === (marginCheck + bodyHeight), 'Margin = ' + margin);
63 console.log('.');
64 start();
65 }
66 });
67 });
68
69 }
70
71 </script>
72 </body>
73 </html>