annotate iframe-resizer/test/mutationObserver.html @ 2:3c160414da2e default tip

initial upload
author shiltemann
date Thu, 26 Feb 2015 14:05:23 +0100
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
3c160414da2e initial upload
shiltemann
parents:
diff changeset
1 <!DOCTYPE html>
3c160414da2e initial upload
shiltemann
parents:
diff changeset
2 <html>
3c160414da2e initial upload
shiltemann
parents:
diff changeset
3 <head>
3c160414da2e initial upload
shiltemann
parents:
diff changeset
4 <meta charset="utf-8">
3c160414da2e initial upload
shiltemann
parents:
diff changeset
5 <title>QUnit LoadHide</title>
3c160414da2e initial upload
shiltemann
parents:
diff changeset
6 <link rel="stylesheet" href="resources/qunit.css">
3c160414da2e initial upload
shiltemann
parents:
diff changeset
7 </head>
3c160414da2e initial upload
shiltemann
parents:
diff changeset
8 <body>
3c160414da2e initial upload
shiltemann
parents:
diff changeset
9 <div id="qunit"></div>
3c160414da2e initial upload
shiltemann
parents:
diff changeset
10 <div id="qunit-fixture">
3c160414da2e initial upload
shiltemann
parents:
diff changeset
11
3c160414da2e initial upload
shiltemann
parents:
diff changeset
12 <div style="width:600px;">
3c160414da2e initial upload
shiltemann
parents:
diff changeset
13 <iframe src="resources/frame.content.html" width="100%" scrolling="no"></iframe>
3c160414da2e initial upload
shiltemann
parents:
diff changeset
14 </div>
3c160414da2e initial upload
shiltemann
parents:
diff changeset
15
3c160414da2e initial upload
shiltemann
parents:
diff changeset
16 </div>
3c160414da2e initial upload
shiltemann
parents:
diff changeset
17 <script src="resources/qunit.js"></script>
3c160414da2e initial upload
shiltemann
parents:
diff changeset
18 <script src="resources/jquery.js"></script>
3c160414da2e initial upload
shiltemann
parents:
diff changeset
19 <script src="../js/iframeResizer.min.js"></script>
3c160414da2e initial upload
shiltemann
parents:
diff changeset
20 <script>
3c160414da2e initial upload
shiltemann
parents:
diff changeset
21
3c160414da2e initial upload
shiltemann
parents:
diff changeset
22 'use strict';
3c160414da2e initial upload
shiltemann
parents:
diff changeset
23
3c160414da2e initial upload
shiltemann
parents:
diff changeset
24 function mutationObserverTest(){
3c160414da2e initial upload
shiltemann
parents:
diff changeset
25 asyncTest( "iFrame MutationObserver", function() {
3c160414da2e initial upload
shiltemann
parents:
diff changeset
26
3c160414da2e initial upload
shiltemann
parents:
diff changeset
27 var callbackCounter = 0;
3c160414da2e initial upload
shiltemann
parents:
diff changeset
28
3c160414da2e initial upload
shiltemann
parents:
diff changeset
29 $('iframe').iFrameResize({
3c160414da2e initial upload
shiltemann
parents:
diff changeset
30 log:true,
3c160414da2e initial upload
shiltemann
parents:
diff changeset
31 resizedCallback:function(messageData){
3c160414da2e initial upload
shiltemann
parents:
diff changeset
32
3c160414da2e initial upload
shiltemann
parents:
diff changeset
33 switch (''+(++callbackCounter)){
3c160414da2e initial upload
shiltemann
parents:
diff changeset
34 case '1':
3c160414da2e initial upload
shiltemann
parents:
diff changeset
35 document.getElementsByTagName('iframe')[0].contentWindow.postMessage( msgId + 'changeContent', '*' );
3c160414da2e initial upload
shiltemann
parents:
diff changeset
36 break;
3c160414da2e initial upload
shiltemann
parents:
diff changeset
37 case '2':
3c160414da2e initial upload
shiltemann
parents:
diff changeset
38 ok( true, 'iFrame detected content change');
3c160414da2e initial upload
shiltemann
parents:
diff changeset
39 ok( 'mutationObserver' === messageData.type, 'Received '+messageData.type+' message back from iFrame. Expected mutationObserver' );
3c160414da2e initial upload
shiltemann
parents:
diff changeset
40 start();
3c160414da2e initial upload
shiltemann
parents:
diff changeset
41 }
3c160414da2e initial upload
shiltemann
parents:
diff changeset
42 }
3c160414da2e initial upload
shiltemann
parents:
diff changeset
43 });
3c160414da2e initial upload
shiltemann
parents:
diff changeset
44 });
3c160414da2e initial upload
shiltemann
parents:
diff changeset
45 }
3c160414da2e initial upload
shiltemann
parents:
diff changeset
46
3c160414da2e initial upload
shiltemann
parents:
diff changeset
47 var msgId = '[iFrameSizerTest]:';
3c160414da2e initial upload
shiltemann
parents:
diff changeset
48
3c160414da2e initial upload
shiltemann
parents:
diff changeset
49 var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver;
3c160414da2e initial upload
shiltemann
parents:
diff changeset
50
3c160414da2e initial upload
shiltemann
parents:
diff changeset
51 if (MutationObserver)
3c160414da2e initial upload
shiltemann
parents:
diff changeset
52 mutationObserverTest()
3c160414da2e initial upload
shiltemann
parents:
diff changeset
53 else{
3c160414da2e initial upload
shiltemann
parents:
diff changeset
54 console.warn('(MutationObserver not supported in this browser! Unable to run test)');
3c160414da2e initial upload
shiltemann
parents:
diff changeset
55 test('iFrame MutationObserver',function(){
3c160414da2e initial upload
shiltemann
parents:
diff changeset
56 ok(true,'MutationObserver not supported in this browser! Unable to run test.');
3c160414da2e initial upload
shiltemann
parents:
diff changeset
57 });
3c160414da2e initial upload
shiltemann
parents:
diff changeset
58 }
3c160414da2e initial upload
shiltemann
parents:
diff changeset
59
3c160414da2e initial upload
shiltemann
parents:
diff changeset
60 </script>
3c160414da2e initial upload
shiltemann
parents:
diff changeset
61 </body>
3c160414da2e initial upload
shiltemann
parents:
diff changeset
62 </html>