annotate iframe-resizer/test/size.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:400px;">
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="../js/iframeResizer.min.js"></script>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
20 <script>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
21
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
22 'use strict';
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
23 var msgId = '[iFrameSizerTest]:';
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
24
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
25 asyncTest( "iFrame size Event", function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
26
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
27 var callbackCounter = 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
28
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
29 $('iframe').iFrameResize({
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
30 log:true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
31 doWidth:true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
32 enablePublicMethods:true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
33 interval:0,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
34 resizedCallback:function(messageData){
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
35 var msgType = 'size';
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
36
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
37 switch (''+(++callbackCounter)){
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
38 case '1':
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
39 document.getElementsByTagName('iframe')[0].contentWindow.postMessage( msgId + msgType, '*' );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
40 break;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
41 case '2':
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
42 ok( msgType === messageData.type, 'Received '+messageData.type+' message back from iFrame. Expected '+msgType);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
43 document.getElementsByTagName('iframe')[0].contentWindow.postMessage( msgId + 'size100', '*' );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
44 break;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
45 case '3':
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
46 ok( msgType === messageData.type, 'Received '+messageData.type+' message back from iFrame. Expected '+msgType);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
47 ok( '100' === messageData.height, 'Height received = 100');
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
48 //ok( 100 === $('iframe').height(), 'IFrame height = 100'); Works in phaatomJS, but not chrome!
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
49 document.getElementsByTagName('iframe')[0].contentWindow.postMessage( msgId + 'size200300', '*' );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
50 break;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
51 case '4':
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
52 ok( msgType === messageData.type, 'Received '+messageData.type+' message back from iFrame. Expected '+msgType);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
53 ok( '200' === messageData.height, 'Height received = 200');
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
54 ok( '300' === messageData.width, 'Width received = 300');
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
55 start();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
56 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
57 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
58 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
59 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
60
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
61
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
62 </script>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
63 </body>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
64 </html>