Mercurial > repos > saskia-hiltemann > ireport
comparison iframe-resizer/test/mutationObserver.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:600px;"> | |
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="../js/iframeResizer.min.js"></script> | |
20 <script> | |
21 | |
22 'use strict'; | |
23 | |
24 function mutationObserverTest(){ | |
25 asyncTest( "iFrame MutationObserver", function() { | |
26 | |
27 var callbackCounter = 0; | |
28 | |
29 $('iframe').iFrameResize({ | |
30 log:true, | |
31 resizedCallback:function(messageData){ | |
32 | |
33 switch (''+(++callbackCounter)){ | |
34 case '1': | |
35 document.getElementsByTagName('iframe')[0].contentWindow.postMessage( msgId + 'changeContent', '*' ); | |
36 break; | |
37 case '2': | |
38 ok( true, 'iFrame detected content change'); | |
39 ok( 'mutationObserver' === messageData.type, 'Received '+messageData.type+' message back from iFrame. Expected mutationObserver' ); | |
40 start(); | |
41 } | |
42 } | |
43 }); | |
44 }); | |
45 } | |
46 | |
47 var msgId = '[iFrameSizerTest]:'; | |
48 | |
49 var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver; | |
50 | |
51 if (MutationObserver) | |
52 mutationObserverTest() | |
53 else{ | |
54 console.warn('(MutationObserver not supported in this browser! Unable to run test)'); | |
55 test('iFrame MutationObserver',function(){ | |
56 ok(true,'MutationObserver not supported in this browser! Unable to run test.'); | |
57 }); | |
58 } | |
59 | |
60 </script> | |
61 </body> | |
62 </html> |