annotate iframe-resizer/test/margin.html @ 5:4e21ce709269 draft

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