first commit
This commit is contained in:
45
iframe-resizer-master/test/_init.html
Executable file
45
iframe-resizer-master/test/_init.html
Executable file
@ -0,0 +1,45 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>QUnit LoadHide</title>
|
||||
<link rel="stylesheet" href="resources/qunit.css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="qunit"></div>
|
||||
<div id="qunit-fixture">
|
||||
<div style="width:600px;">
|
||||
<iframe
|
||||
src="resources/frame.lateload.html"
|
||||
width="100%"
|
||||
scrolling="no"
|
||||
></iframe>
|
||||
</div>
|
||||
</div>
|
||||
<script src="resources/qunit.js"></script>
|
||||
<script src="resources/jquery.js"></script>
|
||||
<script src="../js/ie8.polyfils.min.js"></script>
|
||||
<script src="../js/iframeResizer.min.js"></script>
|
||||
<script>
|
||||
'use strict'
|
||||
var msgId = '[iFrameSizerTest]:'
|
||||
|
||||
asyncTest('postMessage Response', function() {
|
||||
iFrameResize({
|
||||
//log:true,
|
||||
bodyBackground: 'wheat',
|
||||
heightCalculationMethod: 'max',
|
||||
onInit: function(iframe) {
|
||||
ok(true, 'Receive init message back from iFrame.')
|
||||
ok('iFrameResizer0' === iframe.id, 'iFrame id = iFrameResizer0.')
|
||||
setTimeout(function() {
|
||||
iframe.iFrameResizer.close()
|
||||
start()
|
||||
}, 10)
|
||||
}
|
||||
})
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
52
iframe-resizer-master/test/_init_once.html
Executable file
52
iframe-resizer-master/test/_init_once.html
Executable file
@ -0,0 +1,52 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>QUnit LoadHide</title>
|
||||
<link rel="stylesheet" href="resources/qunit.css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="qunit"></div>
|
||||
<div id="qunit-fixture">
|
||||
<div class="iframe-wrapper" style="width:600px;">
|
||||
<iframe
|
||||
src="resources/frame.content.html"
|
||||
width="100%"
|
||||
scrolling="no"
|
||||
></iframe>
|
||||
</div>
|
||||
</div>
|
||||
<script src="resources/qunit.js"></script>
|
||||
<script src="resources/jquery.js"></script>
|
||||
<script src="../src/iframeResizer.js"></script>
|
||||
<script src="../js/ie8.polyfils.min.js"></script>
|
||||
<script>
|
||||
'use strict'
|
||||
var receivedIframeIds = []
|
||||
asyncTest('postMessage Response', function() {
|
||||
iFrameResize({
|
||||
//log:true,
|
||||
bodyBackground: 'wheat',
|
||||
heightCalculationMethod: 'max',
|
||||
onInit: function(iframe) {
|
||||
ok(true, 'Receive init message back from iFrame.')
|
||||
receivedIframeIds.push(iframe.id)
|
||||
if (receivedIframeIds.length === 2) {
|
||||
ok(
|
||||
receivedIframeIds.indexOf('iFrameResizer0') > -1,
|
||||
'iFrame id = iFrameResizer0 is present.'
|
||||
)
|
||||
ok(
|
||||
receivedIframeIds.indexOf('iFrameResizer1') > -1,
|
||||
'iFrame id = iFrameResizer1 is present.'
|
||||
)
|
||||
} else {
|
||||
start()
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
73
iframe-resizer-master/test/_init_once_async.html
Executable file
73
iframe-resizer-master/test/_init_once_async.html
Executable file
@ -0,0 +1,73 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>QUnit LoadHide</title>
|
||||
<link rel="stylesheet" href="resources/qunit.css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="qunit"></div>
|
||||
<div id="qunit-fixture">
|
||||
<div class="iframe-wrapper" style="width:600px;">
|
||||
<iframe
|
||||
src="resources/frame.content.html"
|
||||
width="100%"
|
||||
scrolling="no"
|
||||
></iframe>
|
||||
</div>
|
||||
</div>
|
||||
<script src="resources/qunit.js"></script>
|
||||
<script src="resources/jquery.js"></script>
|
||||
<script src="../js/ie8.polyfils.min.js"></script>
|
||||
<script src="../src/iframeResizer.js"></script>
|
||||
<script>
|
||||
'use strict'
|
||||
var $iframeFirst = $('iframe')
|
||||
var recievedIframeIds = []
|
||||
function getIframeFirstAttrs() {
|
||||
var attrs = {}
|
||||
var blacklistedAttrs = { id: true }
|
||||
function cloneAllowedAttr() {
|
||||
var attrName = this.name
|
||||
if (!(attrName in blacklistedAttrs)) {
|
||||
attrs[attrName] = this.value
|
||||
}
|
||||
}
|
||||
$.each($iframeFirst[0].attributes, cloneAllowedAttr)
|
||||
return attrs
|
||||
}
|
||||
|
||||
function addSecondIframeAndScript() {
|
||||
var $injectedIframe = $('<iframe/>').attr(getIframeFirstAttrs())
|
||||
var firstScriptSource = $('script[src*=iframeResizer]').attr('src')
|
||||
$iframeFirst.after($injectedIframe)
|
||||
$.getScript(firstScriptSource, function() {
|
||||
iFrameResize({
|
||||
//log:true,
|
||||
bodyBackground: 'wheat',
|
||||
heightCalculationMethod: 'max',
|
||||
onInit: function(iframe) {
|
||||
ok(true, 'Receive init message back from iFrame1.')
|
||||
ok('iFrameResizer1' === iframe.id, 'iFrame id = iFrameResizer1.')
|
||||
start()
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
asyncTest('postMessage Response', function() {
|
||||
iFrameResize({
|
||||
//log:true,
|
||||
bodyBackground: 'wheat',
|
||||
heightCalculationMethod: 'max',
|
||||
onInit: function(iframe) {
|
||||
ok(true, 'Receive init message back from iFrame0.')
|
||||
ok('iFrameResizer0' === iframe.id, 'iFrame id = iFrameResizer0.')
|
||||
addSecondIframeAndScript()
|
||||
}
|
||||
})
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
47
iframe-resizer-master/test/background.html
Executable file
47
iframe-resizer-master/test/background.html
Executable file
@ -0,0 +1,47 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>QUnit LoadHide</title>
|
||||
<link rel="stylesheet" href="resources/qunit.css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="qunit"></div>
|
||||
<div id="qunit-fixture">
|
||||
<div style="width:600px;">
|
||||
<iframe
|
||||
src="resources/frame.content.html"
|
||||
width="100%"
|
||||
scrolling="no"
|
||||
></iframe>
|
||||
</div>
|
||||
</div>
|
||||
<script src="resources/qunit.js"></script>
|
||||
<script src="resources/jquery.js"></script>
|
||||
<script src="resources/testLib.js"></script>
|
||||
<script src="../js/ie8.polyfils.min.js"></script>
|
||||
<script src="../js/iframeResizer.min.js"></script>
|
||||
<script>
|
||||
'use strict'
|
||||
var msgId = '[iFrameSizerTest]:'
|
||||
|
||||
var background = 'rgb(245, 222, 179)'
|
||||
|
||||
asyncTest('getId', function() {
|
||||
iFrameResize({
|
||||
//log:true,
|
||||
bodyBackground: background,
|
||||
onResized: function(messageData) {
|
||||
ok(true, 'Receive init message back from iFrame.')
|
||||
sendMessage('chkBackground')
|
||||
},
|
||||
onMessage: function(messageData) {
|
||||
ok(background === messageData.message, 'Background = ' + background)
|
||||
start()
|
||||
}
|
||||
})
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
55
iframe-resizer-master/test/changePage.html
Executable file
55
iframe-resizer-master/test/changePage.html
Executable file
@ -0,0 +1,55 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>QUnit LoadHide</title>
|
||||
<link rel="stylesheet" href="resources/qunit.css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="qunit"></div>
|
||||
<div id="qunit-fixture">
|
||||
<div style="width:400px;">
|
||||
<iframe
|
||||
src="resources/frame.content.html"
|
||||
width="100%"
|
||||
scrolling="no"
|
||||
></iframe>
|
||||
</div>
|
||||
</div>
|
||||
<script src="resources/qunit.js"></script>
|
||||
<script src="resources/jquery.js"></script>
|
||||
<script src="resources/testLib.js"></script>
|
||||
<script src="../js/ie8.polyfils.min.js"></script>
|
||||
<script src="../js/iframeResizer.min.js"></script>
|
||||
<script>
|
||||
'use strict'
|
||||
var msgId = '[iFrameSizerTest]:'
|
||||
|
||||
jQuery.noConflict()
|
||||
|
||||
asyncTest('iFrame change page', function() {
|
||||
var evtCounter = 0
|
||||
|
||||
jQuery('iframe').iFrameResize({
|
||||
//log:true,
|
||||
onResized: function(messageData) {
|
||||
switch ('' + ++evtCounter) {
|
||||
case '1':
|
||||
sendMessage('pageChange')
|
||||
break
|
||||
case '2':
|
||||
ok(
|
||||
'init' === messageData.type,
|
||||
'Received ' +
|
||||
messageData.type +
|
||||
' message back from iFrame. Expected init'
|
||||
)
|
||||
start()
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
44
iframe-resizer-master/test/close.html
Executable file
44
iframe-resizer-master/test/close.html
Executable file
@ -0,0 +1,44 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>QUnit LoadHide</title>
|
||||
<link rel="stylesheet" href="resources/qunit.css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="qunit"></div>
|
||||
<div id="qunit-fixture">
|
||||
<div style="width:400px;">
|
||||
<iframe
|
||||
src="resources/frame.content.html"
|
||||
width="100%"
|
||||
scrolling="no"
|
||||
></iframe>
|
||||
</div>
|
||||
</div>
|
||||
<script src="resources/qunit.js"></script>
|
||||
<script src="resources/jquery.js"></script>
|
||||
<script src="resources/testLib.js"></script>
|
||||
<script src="../js/ie8.polyfils.min.js"></script>
|
||||
<script src="../js/iframeResizer.min.js"></script>
|
||||
<script>
|
||||
'use strict'
|
||||
|
||||
asyncTest('iFrame close Event', function() {
|
||||
var evtCounter = 0
|
||||
|
||||
$('iframe').iFrameResize({
|
||||
//log:true,
|
||||
onInit: function() {
|
||||
sendMessage('close')
|
||||
},
|
||||
onClosed: function() {
|
||||
ok(0 === $('iframe').length, 'IFrame removed from page')
|
||||
start()
|
||||
}
|
||||
})
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
48
iframe-resizer-master/test/getId.html
Executable file
48
iframe-resizer-master/test/getId.html
Executable file
@ -0,0 +1,48 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>QUnit LoadHide</title>
|
||||
<link rel="stylesheet" href="resources/qunit.css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="qunit"></div>
|
||||
<div id="qunit-fixture">
|
||||
<div style="width:600px;">
|
||||
<iframe
|
||||
id="test"
|
||||
src="resources/frame.content.html"
|
||||
width="100%"
|
||||
scrolling="no"
|
||||
></iframe>
|
||||
</div>
|
||||
</div>
|
||||
<script src="resources/qunit.js"></script>
|
||||
<script src="resources/jquery.js"></script>
|
||||
<script src="resources/testLib.js"></script>
|
||||
<script src="../js/ie8.polyfils.min.js"></script>
|
||||
<script src="../js/iframeResizer.min.js"></script>
|
||||
<script>
|
||||
'use strict'
|
||||
var msgId = '[iFrameSizerTest]:'
|
||||
|
||||
asyncTest('getId', function() {
|
||||
iFrameResize(
|
||||
{
|
||||
//log:true,
|
||||
onResized: function(messageData) {
|
||||
ok(true, 'Receive init message back from iFrame.')
|
||||
sendMessage('chkGetId')
|
||||
},
|
||||
onMessage: function(messageData) {
|
||||
ok(messageData.iframe.id === messageData.message, 'getId method.')
|
||||
start()
|
||||
}
|
||||
},
|
||||
document.getElementById('test')
|
||||
)
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
59
iframe-resizer-master/test/interval.html
Executable file
59
iframe-resizer-master/test/interval.html
Executable file
@ -0,0 +1,59 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>QUnit LoadHide</title>
|
||||
<link rel="stylesheet" href="resources/qunit.css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="qunit"></div>
|
||||
<div id="qunit-fixture">
|
||||
<div style="width:600px;">
|
||||
<iframe
|
||||
src="resources/frame.content.html"
|
||||
width="100%"
|
||||
scrolling="no"
|
||||
></iframe>
|
||||
</div>
|
||||
</div>
|
||||
<script src="resources/qunit.js"></script>
|
||||
<script src="resources/jquery.js"></script>
|
||||
<script src="resources/testLib.js"></script>
|
||||
<script src="../js/ie8.polyfils.min.js"></script>
|
||||
<script src="../js/iframeResizer.min.js"></script>
|
||||
<script>
|
||||
'use strict'
|
||||
var msgId = '[iFrameSizerTest]:'
|
||||
|
||||
asyncTest('iFrame negative interval timer ', function() {
|
||||
var evtCounter = 0,
|
||||
started = false
|
||||
|
||||
$('iframe').iFrameResize({
|
||||
//log:true,
|
||||
interval: -1,
|
||||
onResized: function(messageData) {
|
||||
switch ('' + ++evtCounter) {
|
||||
case '1':
|
||||
sendMessage('changeContent')
|
||||
break
|
||||
default:
|
||||
//ok( true, 'iFrame detected content change');
|
||||
if ('resize' !== messageData.type && false === started) {
|
||||
started = true
|
||||
ok(
|
||||
'interval' === messageData.type,
|
||||
'Received ' +
|
||||
messageData.type +
|
||||
' message back from iFrame. Expected interval.'
|
||||
)
|
||||
start()
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
49
iframe-resizer-master/test/jqueryNoConflict.html
Executable file
49
iframe-resizer-master/test/jqueryNoConflict.html
Executable file
@ -0,0 +1,49 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>QUnit LoadHide</title>
|
||||
<link rel="stylesheet" href="resources/qunit.css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="qunit"></div>
|
||||
<div id="qunit-fixture">
|
||||
<div style="width:600px;">
|
||||
<iframe
|
||||
src="resources/frame.content.html"
|
||||
width="100%"
|
||||
scrolling="no"
|
||||
></iframe>
|
||||
</div>
|
||||
</div>
|
||||
<script src="resources/qunit.js"></script>
|
||||
<script src="resources/jquery.js"></script>
|
||||
<script>
|
||||
//var myOwnJquery = jQuery.noConflict(true);
|
||||
</script>
|
||||
<script src="../js/iframeResizer.min.js"></script>
|
||||
<script>
|
||||
'use strict'
|
||||
var msgId = '[iFrameSizerTest]:'
|
||||
|
||||
asyncTest('init with jQuery.noConflict', function() {
|
||||
try {
|
||||
$('iframe').iFrameResize({
|
||||
//log:true,
|
||||
bodyBackground: 'wheat',
|
||||
heightCalculationMethod: 'max',
|
||||
onInit: function(iframe) {
|
||||
ok(true, 'Receive init message back from iFrame.')
|
||||
start()
|
||||
}
|
||||
})
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
ok(false)
|
||||
start()
|
||||
}
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
92
iframe-resizer-master/test/lateImageLoad.html
Executable file
92
iframe-resizer-master/test/lateImageLoad.html
Executable file
@ -0,0 +1,92 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>QUnit LoadHide</title>
|
||||
<link rel="stylesheet" href="resources/qunit.css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="qunit"></div>
|
||||
<div id="qunit-fixture">
|
||||
<div style="width:600px;">
|
||||
<iframe
|
||||
src="resources/frame.content.html"
|
||||
height="100%"
|
||||
scrolling="no"
|
||||
></iframe>
|
||||
</div>
|
||||
</div>
|
||||
<script src="resources/qunit.js"></script>
|
||||
<script src="resources/jquery.js"></script>
|
||||
<script src="resources/testLib.js"></script>
|
||||
<script src="../js/ie8.polyfils.min.js"></script>
|
||||
<script src="../js/iframeResizer.min.js"></script>
|
||||
<script>
|
||||
'use strict'
|
||||
var msgId = '[iFrameSizerTest]:'
|
||||
|
||||
var MutationObserver =
|
||||
window.MutationObserver ||
|
||||
window.WebKitMutationObserver ||
|
||||
window.MozMutationObserver
|
||||
|
||||
function mutationObserverTest() {
|
||||
asyncTest('iFrame late image load', function() {
|
||||
var evtCounter = 0
|
||||
|
||||
$('iframe').iFrameResize({
|
||||
//log:true,
|
||||
sizeHeight: false,
|
||||
sizeWidth: true,
|
||||
interval: 1,
|
||||
onResized: function(messageData) {
|
||||
switch ('' + ++evtCounter) {
|
||||
case '1':
|
||||
sendMessage('image')
|
||||
break
|
||||
case '2':
|
||||
break
|
||||
case '3':
|
||||
ok('imageLoad' === messageData.type, 'type = imageLoad')
|
||||
start()
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
asyncTest('iFrame late image load with other mutations', function() {
|
||||
var evtCounter = 0
|
||||
|
||||
$('iframe').iFrameResize({
|
||||
//log:true,
|
||||
sizeHeight: false,
|
||||
sizeWidth: true,
|
||||
interval: 1,
|
||||
onResized: function(messageData) {
|
||||
switch ('' + ++evtCounter) {
|
||||
case '1':
|
||||
sendMessage('imageAsSecondMutation')
|
||||
break
|
||||
case '2':
|
||||
break
|
||||
case '3':
|
||||
ok('imageLoad' === messageData.type, 'type = imageLoad')
|
||||
start()
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// if (MutationObserver)
|
||||
// mutationObserverTest()
|
||||
// else{
|
||||
// console.warn('(MutationObserver not supported in this browser! Unable to run test)');
|
||||
// test('iFrame MutationObserver',function(){
|
||||
// ok(true,'MutationObserver not supported in this browser! Unable to run test.');
|
||||
// });
|
||||
// }
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
67
iframe-resizer-master/test/margin.html
Executable file
67
iframe-resizer-master/test/margin.html
Executable file
@ -0,0 +1,67 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>QUnit LoadHide</title>
|
||||
<link rel="stylesheet" href="resources/qunit.css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="qunit"></div>
|
||||
<div id="qunit-fixture">
|
||||
<div style="width:1600px;">
|
||||
<iframe
|
||||
src="resources/frame.content.html"
|
||||
width="100%"
|
||||
scrolling="no"
|
||||
></iframe>
|
||||
</div>
|
||||
</div>
|
||||
<script src="resources/qunit.js"></script>
|
||||
<script src="resources/jquery.js"></script>
|
||||
<script src="resources/testLib.js"></script>
|
||||
<script src="../js/ie8.polyfils.min.js"></script>
|
||||
<script src="../js/iframeResizer.min.js"></script>
|
||||
<script>
|
||||
'use strict'
|
||||
var msgId = '[iFrameSizerTest]:'
|
||||
|
||||
var margins = ['10px 5em', '15px 5ex', '20px', '25px', '75px']
|
||||
|
||||
function Counter() {
|
||||
var i = 0
|
||||
return function() {
|
||||
return i++
|
||||
}
|
||||
}
|
||||
|
||||
var counter = Counter()
|
||||
|
||||
for (var i = 0; i !== margins.length; i++) {
|
||||
asyncTest('Margin ' + margins[i], function() {
|
||||
var height = 0,
|
||||
i = counter(), //counteract async
|
||||
margin = margins[i]
|
||||
|
||||
iFrameResize({
|
||||
//log:true,
|
||||
bodyMargin: margin,
|
||||
onResized: function(messageData) {
|
||||
ok(true, 'Receive message back from iFrame.')
|
||||
height = parseInt(messageData.height, 10)
|
||||
sendMessage('chkHeight')
|
||||
},
|
||||
onMessage: function(messageData) {
|
||||
var marginCheck = 2 * parseInt(margin, 10),
|
||||
bodyHeight = parseInt(messageData.message, 10)
|
||||
|
||||
ok(height === marginCheck + bodyHeight, 'Margin = ' + margin)
|
||||
console.log('.')
|
||||
start()
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
74
iframe-resizer-master/test/mutationObserver.html
Executable file
74
iframe-resizer-master/test/mutationObserver.html
Executable file
@ -0,0 +1,74 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>QUnit LoadHide</title>
|
||||
<link rel="stylesheet" href="resources/qunit.css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="qunit"></div>
|
||||
<div id="qunit-fixture">
|
||||
<div style="width:600px;">
|
||||
<iframe
|
||||
src="resources/frame.content.html"
|
||||
width="100%"
|
||||
scrolling="no"
|
||||
></iframe>
|
||||
</div>
|
||||
</div>
|
||||
<script src="resources/qunit.js"></script>
|
||||
<script src="resources/jquery.js"></script>
|
||||
<script src="resources/testLib.js"></script>
|
||||
<script src="../js/iframeResizer.min.js"></script>
|
||||
<script>
|
||||
'use strict'
|
||||
|
||||
function mutationObserverTest() {
|
||||
asyncTest('iFrame MutationObserver', function() {
|
||||
var evtCounter = 0
|
||||
|
||||
$('iframe').iFrameResize({
|
||||
//log:true,
|
||||
onResized: function(messageData) {
|
||||
switch ('' + ++evtCounter) {
|
||||
case '1':
|
||||
sendMessage('changeContent')
|
||||
break
|
||||
case '2':
|
||||
ok(true, 'iFrame detected content change')
|
||||
ok(
|
||||
'mutationObserver' === messageData.type,
|
||||
'Received ' +
|
||||
messageData.type +
|
||||
' message back from iFrame. Expected mutationObserver'
|
||||
)
|
||||
start()
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
var msgId = '[iFrameSizerTest]:'
|
||||
|
||||
var MutationObserver =
|
||||
window.MutationObserver ||
|
||||
window.WebKitMutationObserver ||
|
||||
window.MozMutationObserver
|
||||
|
||||
if (MutationObserver) mutationObserverTest()
|
||||
else {
|
||||
console.warn(
|
||||
'(MutationObserver not supported in this browser! Unable to run test)'
|
||||
)
|
||||
test('iFrame MutationObserver', function() {
|
||||
ok(
|
||||
true,
|
||||
'MutationObserver not supported in this browser! Unable to run test.'
|
||||
)
|
||||
})
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
46
iframe-resizer-master/test/nested.html
Executable file
46
iframe-resizer-master/test/nested.html
Executable file
@ -0,0 +1,46 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>QUnit LoadHide</title>
|
||||
<link rel="stylesheet" href="resources/qunit.css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="qunit"></div>
|
||||
<div id="qunit-fixture">
|
||||
<div style="width:600px;">
|
||||
<iframe
|
||||
id="parentPage"
|
||||
src="resources/frame.content.html"
|
||||
width="100%"
|
||||
scrolling="no"
|
||||
></iframe>
|
||||
</div>
|
||||
</div>
|
||||
<script src="resources/qunit.js"></script>
|
||||
<script src="resources/jquery.js"></script>
|
||||
<script src="resources/testLib.js"></script>
|
||||
<script src="../js/ie8.polyfils.min.js"></script>
|
||||
<script src="../src/iframeResizer.js"></script>
|
||||
<script>
|
||||
'use strict'
|
||||
var count = 0,
|
||||
msgId = '[iFrameSizerTest]:'
|
||||
|
||||
asyncTest('Nested iFrame', function() {
|
||||
$('iframe').iFrameResize({
|
||||
//log:true,
|
||||
onResized: function(messageData) {
|
||||
ok(true, 'Receive init message back from iFrame.')
|
||||
sendMessage('nested')
|
||||
},
|
||||
onMessage: function(messageData) {
|
||||
ok('nested' === messageData.message, 'Nested iFrame sized.')
|
||||
start()
|
||||
}
|
||||
})
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
75
iframe-resizer-master/test/noMessageForBlackListedOrigins.html
Executable file
75
iframe-resizer-master/test/noMessageForBlackListedOrigins.html
Executable file
@ -0,0 +1,75 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>QUnit LoadHide</title>
|
||||
<link rel="stylesheet" href="resources/qunit.css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="qunit"></div>
|
||||
<div id="qunit-fixture">
|
||||
<div style="width:600px;">
|
||||
<iframe
|
||||
src="resources/frame.content.html"
|
||||
width="100%"
|
||||
scrolling="no"
|
||||
></iframe>
|
||||
</div>
|
||||
<iframe
|
||||
src="about:blank"
|
||||
width="100%"
|
||||
scrolling="no"
|
||||
></iframe>
|
||||
<iframe
|
||||
src="javascript:void(0)"
|
||||
width="100%"
|
||||
scrolling="no"
|
||||
></iframe>
|
||||
</div>
|
||||
<script src="resources/qunit.js"></script>
|
||||
<script src="resources/jquery.js"></script>
|
||||
<script src="resources/testLib.js"></script>
|
||||
<script src="../js/ie8.polyfils.min.js"></script>
|
||||
<script src="../js/iframeResizer.js"></script>
|
||||
<script>
|
||||
'use strict'
|
||||
var count = 0,
|
||||
msgId = '[iFrameSizerTest]:'
|
||||
|
||||
asyncTest('sendMessage (string)', function() {
|
||||
iFrameResize({
|
||||
//log:true,
|
||||
onResized: function(messageData) {
|
||||
ok(true, 'Receive init message back from iFrame.')
|
||||
sendMessage('chkSendMsg')
|
||||
},
|
||||
onMessage: function(messageData) {
|
||||
ok(
|
||||
'message: test string' === messageData.message,
|
||||
'Receive string message back from iFrame via sendMessage function.'
|
||||
)
|
||||
start()
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
asyncTest('sendMessage (object)', function() {
|
||||
iFrameResize({
|
||||
//log:true,
|
||||
onResized: function(messageData) {
|
||||
ok(true, 'Receive init message back from iFrame.')
|
||||
sendMessage('chkSendObj')
|
||||
},
|
||||
onMessage: function(messageData) {
|
||||
ok(
|
||||
'test object' === messageData.message.message,
|
||||
'Receive object message back from iFrame via sendMessage function.'
|
||||
)
|
||||
start()
|
||||
}
|
||||
})
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
105
iframe-resizer-master/test/removeIFrame.html
Executable file
105
iframe-resizer-master/test/removeIFrame.html
Executable file
@ -0,0 +1,105 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>QUnit LoadHide</title>
|
||||
<link rel="stylesheet" href="resources/qunit.css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="qunit"></div>
|
||||
<div id="qunit-fixture">
|
||||
<div style="width:600px;">
|
||||
<div class="focusable" tabindex="0"></div>
|
||||
<iframe
|
||||
src="resources/frame.content.html"
|
||||
width="100%"
|
||||
scrolling="no"
|
||||
tabindex="1"
|
||||
></iframe>
|
||||
</div>
|
||||
</div>
|
||||
<script src="resources/qunit.js"></script>
|
||||
<script src="resources/jquery.js"></script>
|
||||
<script src="resources/testLib.js"></script>
|
||||
<script src="../js/iframeResizer.min.js"></script>
|
||||
<script>
|
||||
'use strict'
|
||||
|
||||
var regexp1 = /\[iFrameSizer\]\[Host page: iFrameResizer[0-9]+\]/
|
||||
var regexp2 = /\[Window focus\] IFrame\(iFrameResizer[0-9]+\) not found/
|
||||
|
||||
function spyOn(obj, method) {
|
||||
var original = obj[method]
|
||||
var spy = {
|
||||
count: 0,
|
||||
args: [],
|
||||
restore: function() {
|
||||
obj[method] = original
|
||||
}
|
||||
}
|
||||
|
||||
obj[method] = function() {
|
||||
var args = [].slice.apply(arguments)
|
||||
spy.count++
|
||||
spy.args.push(args)
|
||||
return original.call(obj, args)
|
||||
}
|
||||
|
||||
return spy
|
||||
}
|
||||
|
||||
function removeIFrameTest() {
|
||||
asyncTest('Remove iFrame', function() {
|
||||
var iframeEl = $('iframe')
|
||||
iframeEl.iFrameResize({
|
||||
// log: true,
|
||||
onInit: function() {
|
||||
var warn = spyOn(console, 'warn')
|
||||
$('.focusable').focus()
|
||||
iframeEl[0].parentElement.removeChild(iframeEl[0])
|
||||
|
||||
setTimeout(function() {
|
||||
warn.restore()
|
||||
if (warn.count > 0) {
|
||||
warn.args.forEach(function(args) {
|
||||
ok(
|
||||
!regexp1.test(args[0]) && !regexp2.test(args[1]),
|
||||
'No warnings about already removed frames should get logged to the console. Instead "' +
|
||||
args.join('') +
|
||||
'" got logged.'
|
||||
)
|
||||
})
|
||||
} else {
|
||||
ok(
|
||||
true,
|
||||
'No warnings about already removed frames got logged to the console.'
|
||||
)
|
||||
}
|
||||
start()
|
||||
}, 100)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
if (
|
||||
window.MutationObserver ||
|
||||
window.WebKitMutationObserver ||
|
||||
window.MozMutationObserver
|
||||
) {
|
||||
removeIFrameTest()
|
||||
} else {
|
||||
console.warn(
|
||||
'(MutationObserver not supported in this browser! Unable to run test)'
|
||||
)
|
||||
test('Remove iFrame', function() {
|
||||
ok(
|
||||
true,
|
||||
'MutationObserver not supported in this browser! Unable to run test.'
|
||||
)
|
||||
})
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
51
iframe-resizer-master/test/resize.contentWidth.html
Executable file
51
iframe-resizer-master/test/resize.contentWidth.html
Executable file
@ -0,0 +1,51 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>QUnit LoadHide</title>
|
||||
<link rel="stylesheet" href="resources/qunit.css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="qunit"></div>
|
||||
<div id="qunit-fixture">
|
||||
<div style="width:600px;">
|
||||
<iframe
|
||||
src="resources/frame.content.html"
|
||||
height="100%"
|
||||
scrolling="no"
|
||||
></iframe>
|
||||
</div>
|
||||
</div>
|
||||
<script src="resources/qunit.js"></script>
|
||||
<script src="resources/jquery.js"></script>
|
||||
<script src="resources/testLib.js"></script>
|
||||
<script src="../js/ie8.polyfils.min.js"></script>
|
||||
<script src="../js/iframeResizer.min.js"></script>
|
||||
<script>
|
||||
'use strict'
|
||||
var msgId = '[iFrameSizerTest]:'
|
||||
|
||||
asyncTest('iFrame Resize height', function() {
|
||||
var evtCounter = 0
|
||||
|
||||
$('iframe').iFrameResize({
|
||||
//log:true,
|
||||
sizeHeight: false,
|
||||
sizeWidth: true,
|
||||
interval: 1,
|
||||
onResized: function(messageData) {
|
||||
switch ('' + ++evtCounter) {
|
||||
case '1':
|
||||
sendMessage('width')
|
||||
break
|
||||
case '2':
|
||||
ok(3000 < parseInt(messageData.width, 10), 'iFrame width<3000')
|
||||
start()
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
82
iframe-resizer-master/test/resize.width.html
Executable file
82
iframe-resizer-master/test/resize.width.html
Executable file
@ -0,0 +1,82 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>QUnit LoadHide</title>
|
||||
<link rel="stylesheet" href="resources/qunit.css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="qunit"></div>
|
||||
<div id="qunit-fixture">
|
||||
<div style="width:600px;">
|
||||
<iframe
|
||||
src="resources/frame.content.html"
|
||||
width="100%"
|
||||
scrolling="no"
|
||||
></iframe>
|
||||
</div>
|
||||
</div>
|
||||
<script src="resources/qunit.js"></script>
|
||||
<script src="resources/jquery.js"></script>
|
||||
<script src="../js/iframeResizer.min.js"></script>
|
||||
<script>
|
||||
'use strict'
|
||||
var msgId = '[iFrameSizerTest]:'
|
||||
|
||||
function resize(size) {
|
||||
console.info('Size width:' + size)
|
||||
$('#qunit-fixture > div').width(size)
|
||||
}
|
||||
|
||||
asyncTest('iFrame Resize Event', function() {
|
||||
var evtCounter = 0
|
||||
|
||||
$('iframe').iFrameResize({
|
||||
//log:true,
|
||||
interval: 1000,
|
||||
heightCalculationMethod: 'max',
|
||||
resizeFrom: 'child',
|
||||
onResized: function(messageData) {
|
||||
switch ('' + ++evtCounter) {
|
||||
case '1':
|
||||
setTimeout(function() {
|
||||
resize(300)
|
||||
}, 150)
|
||||
break
|
||||
case '2':
|
||||
setTimeout(function() {
|
||||
resize(600)
|
||||
}, 150)
|
||||
ok(
|
||||
'resize' === messageData.type,
|
||||
'1 Received ' +
|
||||
messageData.type +
|
||||
' message back from iFrame. Expected resize'
|
||||
)
|
||||
ok(
|
||||
'300' === messageData.width,
|
||||
'2 iFrame width = ' + messageData.width + '. Expected 300.'
|
||||
)
|
||||
break
|
||||
default:
|
||||
ok(
|
||||
'resetPage' === messageData.type,
|
||||
'3 Received ' +
|
||||
messageData.type +
|
||||
' message back from iFrame. Expected resetPage'
|
||||
)
|
||||
if ('600' === messageData.width) {
|
||||
ok(
|
||||
'600' === messageData.width,
|
||||
'4 iFrame width = ' + messageData.width + '. Expected 600.'
|
||||
)
|
||||
start()
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
BIN
iframe-resizer-master/test/resources/djb.jpg
Executable file
BIN
iframe-resizer-master/test/resources/djb.jpg
Executable file
Binary file not shown.
After Width: | Height: | Size: 56 KiB |
270
iframe-resizer-master/test/resources/frame.content.html
Executable file
270
iframe-resizer-master/test/resources/frame.content.html
Executable file
@ -0,0 +1,270 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>iFrame message passing test</title>
|
||||
<meta name="description" content="iFrame message passing test">
|
||||
<script src="jquery.js"></script>
|
||||
<style>
|
||||
a { float:right; }
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<b>iFrame</b>
|
||||
|
||||
<div>Some content to be replaced</div>
|
||||
|
||||
<p>
|
||||
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
|
||||
aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
|
||||
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint
|
||||
occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
|
||||
</p>
|
||||
<p>
|
||||
But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will
|
||||
give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the
|
||||
master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but
|
||||
because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful.
|
||||
Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because
|
||||
occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial
|
||||
example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who
|
||||
has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who
|
||||
avoids a pain that produces no resultant pleasure?
|
||||
</p>
|
||||
<p>
|
||||
On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the
|
||||
charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound
|
||||
to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as
|
||||
saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free
|
||||
hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best,
|
||||
every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty
|
||||
or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted.
|
||||
The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure
|
||||
other greater pleasures, or else he endures pains to avoid worse pains.
|
||||
</p>
|
||||
<p>
|
||||
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
|
||||
aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
|
||||
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint
|
||||
occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
|
||||
</p>
|
||||
<p>
|
||||
But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will
|
||||
give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the
|
||||
master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but
|
||||
because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful.
|
||||
Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because
|
||||
occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial
|
||||
example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who
|
||||
has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who
|
||||
avoids a pain that produces no resultant pleasure?
|
||||
</p>
|
||||
<p>
|
||||
On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the
|
||||
charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound
|
||||
to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as
|
||||
saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free
|
||||
hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best,
|
||||
every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty
|
||||
or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted.
|
||||
The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure
|
||||
other greater pleasures, or else he endures pains to avoid worse pains.
|
||||
</p>
|
||||
<p>
|
||||
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
|
||||
aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
|
||||
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint
|
||||
occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
|
||||
</p>
|
||||
<p>
|
||||
But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will
|
||||
give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the
|
||||
master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but
|
||||
because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful.
|
||||
Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because
|
||||
occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial
|
||||
example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who
|
||||
has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who
|
||||
avoids a pain that produces no resultant pleasure?
|
||||
</p>
|
||||
<p>
|
||||
On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the
|
||||
charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound
|
||||
to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as
|
||||
saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free
|
||||
hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best,
|
||||
every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty
|
||||
or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted.
|
||||
The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure
|
||||
other greater pleasures, or else he endures pains to avoid worse pains.
|
||||
</p>
|
||||
<p>
|
||||
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
|
||||
aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
|
||||
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint
|
||||
occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
|
||||
</p>
|
||||
<p>
|
||||
But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will
|
||||
give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the
|
||||
master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but
|
||||
because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful.
|
||||
Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because
|
||||
occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial
|
||||
example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who
|
||||
has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who
|
||||
avoids a pain that produces no resultant pleasure?
|
||||
</p>
|
||||
<p>
|
||||
On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the
|
||||
charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound
|
||||
to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as
|
||||
saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free
|
||||
hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best,
|
||||
every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty
|
||||
or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted.
|
||||
The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure
|
||||
other greater pleasures, or else he endures pains to avoid worse pains.
|
||||
</p>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
(function () {
|
||||
|
||||
var logging = true;
|
||||
|
||||
try {
|
||||
|
||||
function addEventListener(e, func) {
|
||||
if (window.addEventListener) {
|
||||
window.addEventListener(e, func, false);
|
||||
} else if (window.attachEvent) {
|
||||
window.attachEvent('on' + e, func);
|
||||
}
|
||||
}
|
||||
|
||||
function log(msg) {
|
||||
if (logging && window.console) {
|
||||
console.info('[Test] ' + msg);
|
||||
}
|
||||
}
|
||||
|
||||
function warn(msg) {
|
||||
if (window.console) {
|
||||
console.warn('[Test] ' + msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function init(test) {
|
||||
|
||||
function changeContent() {
|
||||
$('p').eq(0).remove();
|
||||
}
|
||||
|
||||
function callMethod(methodName, val1, val2) {
|
||||
if ('parentIFrame' in window)
|
||||
window.parentIFrame[methodName](val1, val2);
|
||||
else
|
||||
warn('window.parentIFrame methods not enabled.')
|
||||
}
|
||||
|
||||
|
||||
//console.info(test);
|
||||
|
||||
switch (test) {
|
||||
case 'changeContent':
|
||||
setInterval(function () { changeContent(); }, 2);
|
||||
break;
|
||||
case 'close':
|
||||
init('imageAsSecondMutation');
|
||||
setTimeout(function () {
|
||||
callMethod('close');
|
||||
}, 2000);
|
||||
break;
|
||||
case 'pageChange':
|
||||
location.href = '../../example/frame.hover.html';
|
||||
break;
|
||||
case 'nested':
|
||||
location.href = 'frame.nested.html';
|
||||
break;
|
||||
case 'size':
|
||||
changeContent();
|
||||
callMethod('size');
|
||||
break;
|
||||
case 'autoResize':
|
||||
callMethod('setAutoResize', true);
|
||||
setTimeout(function () {
|
||||
changeContent();
|
||||
}, 500);
|
||||
break;
|
||||
case 'size100':
|
||||
callMethod('size', 100);
|
||||
break;
|
||||
case 'size200300':
|
||||
callMethod('size', 200, 300);
|
||||
break;
|
||||
case 'jsTrigger':
|
||||
changeContent();
|
||||
callMethod('trigger');
|
||||
break;
|
||||
case 'chkHeight':
|
||||
callMethod('sendMessage', document.body.offsetHeight);
|
||||
break;
|
||||
case 'chkBackground':
|
||||
callMethod('sendMessage', document.body.style.background);
|
||||
break;
|
||||
case 'chkSendMsg':
|
||||
callMethod('sendMessage', 'message: test string');
|
||||
break;
|
||||
case 'chkSendObj':
|
||||
callMethod('sendMessage', { message: 'test object' });
|
||||
break;
|
||||
case 'chkGetId':
|
||||
if ('parentIFrame' in window)
|
||||
callMethod('sendMessage', window.parentIFrame.getId());
|
||||
break;
|
||||
case 'setHeightCalculationMethod':
|
||||
if ('parentIFrame' in window) {
|
||||
parentIFrame.setHeightCalculationMethod('max');
|
||||
callMethod('size');
|
||||
}
|
||||
break;
|
||||
case 'width':
|
||||
$('p').width(3000);
|
||||
break;
|
||||
case 'image':
|
||||
$('p').html('<img src="djb.jpg">');
|
||||
break;
|
||||
case 'imageAsSecondMutation':
|
||||
$('div').html('How now brown cow');
|
||||
$('p').html('<img src="djb.jpg">');
|
||||
$('b').html('<img src="djb2.jpg">');
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
window.iFrameResizer = {
|
||||
onMessage: init
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
warn(e);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
})();
|
||||
</script>
|
||||
|
||||
|
||||
<script type="text/javascript" src="../../js/iframeResizer.contentWindow.min.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
46
iframe-resizer-master/test/resources/frame.lateload.html
Executable file
46
iframe-resizer-master/test/resources/frame.lateload.html
Executable file
@ -0,0 +1,46 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>iFrame message passing test</title>
|
||||
<meta name="description" content="iFrame message passing test">
|
||||
<meta name="viewport" content="width=device-width">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<style>
|
||||
*,
|
||||
*:before,
|
||||
*:after {
|
||||
box-model: border-box;
|
||||
}
|
||||
|
||||
a {
|
||||
float: right;
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
h2 {
|
||||
margin-top: 0;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h2>Late load JS test</h2>
|
||||
<p>Load JS with require after load event has fired.</p>
|
||||
<div style="margin:20px;">
|
||||
</div>
|
||||
|
||||
<script src="jquery.js"></script>
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
setTimeout(function () {
|
||||
console.log('Load Script');
|
||||
$.getScript('../../js/iframeResizer.contentWindow.min.js');
|
||||
}, 500);
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
45
iframe-resizer-master/test/resources/frame.nested.html
Executable file
45
iframe-resizer-master/test/resources/frame.nested.html
Executable file
@ -0,0 +1,45 @@
|
||||
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>iFrame message passing test</title>
|
||||
<meta name="description" content="iFrame message passing test">
|
||||
<meta name="viewport" content="width=device-width">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<style>
|
||||
*, *:before, *:after {box-model: border-box;}
|
||||
a { float:right; margin-left:10px;}
|
||||
h2 {margin-top: 0;}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h2>Nested iFrame</h2>
|
||||
<p>Resize window or click one of the links in the nested iFrame to watch it resize.</p>
|
||||
<div style="margin:20px;">
|
||||
<iframe id="nestedIFrame" src="frame.content.html" width="100%" scrolling="no"></iframe>
|
||||
</div>
|
||||
<p id="callback">
|
||||
</p>
|
||||
|
||||
<script type="text/javascript" src="../../js/iframeResizer.contentWindow.min.js"></script>
|
||||
<script src="jquery.js"></script>
|
||||
<script type="text/javascript" src="../../src/iframeResizer.js"></script>
|
||||
<script type="text/javascript" src="../../js/ie8.polyfils.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
iFrameResize({
|
||||
//log : true, // Enable console logging
|
||||
onResized: function (messageData) { // Callback fn when message is received
|
||||
setTimeout(function () { parentIFrame.sendMessage('nested') }, 50);
|
||||
}
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
6
iframe-resizer-master/test/resources/jquery.js
vendored
Executable file
6
iframe-resizer-master/test/resources/jquery.js
vendored
Executable file
File diff suppressed because one or more lines are too long
244
iframe-resizer-master/test/resources/qunit.css
Executable file
244
iframe-resizer-master/test/resources/qunit.css
Executable file
@ -0,0 +1,244 @@
|
||||
/**
|
||||
* QUnit v1.12.0 - A JavaScript Unit Testing Framework
|
||||
*
|
||||
* https://qunitjs.com
|
||||
*
|
||||
* Copyright 2012 jQuery Foundation and other contributors
|
||||
* Released under the MIT license.
|
||||
* https://jquery.org/license
|
||||
*/
|
||||
|
||||
/** Font Family and Sizes */
|
||||
|
||||
#qunit-tests, #qunit-header, #qunit-banner, #qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult {
|
||||
font-family: "Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial, sans-serif;
|
||||
}
|
||||
|
||||
#qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult, #qunit-tests li { font-size: small; }
|
||||
#qunit-tests { font-size: smaller; }
|
||||
|
||||
|
||||
/** Resets */
|
||||
|
||||
#qunit-tests, #qunit-header, #qunit-banner, #qunit-userAgent, #qunit-testresult, #qunit-modulefilter {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
|
||||
/** Header */
|
||||
|
||||
#qunit-header {
|
||||
padding: 0.5em 0 0.5em 1em;
|
||||
|
||||
color: #8699a4;
|
||||
background-color: #0d3349;
|
||||
|
||||
font-size: 1.5em;
|
||||
line-height: 1em;
|
||||
font-weight: normal;
|
||||
|
||||
border-radius: 5px 5px 0 0;
|
||||
-moz-border-radius: 5px 5px 0 0;
|
||||
-webkit-border-top-right-radius: 5px;
|
||||
-webkit-border-top-left-radius: 5px;
|
||||
}
|
||||
|
||||
#qunit-header a {
|
||||
text-decoration: none;
|
||||
color: #c2ccd1;
|
||||
}
|
||||
|
||||
#qunit-header a:hover,
|
||||
#qunit-header a:focus {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
#qunit-testrunner-toolbar label {
|
||||
display: inline-block;
|
||||
padding: 0 .5em 0 .1em;
|
||||
}
|
||||
|
||||
#qunit-banner {
|
||||
height: 5px;
|
||||
}
|
||||
|
||||
#qunit-testrunner-toolbar {
|
||||
padding: 0.5em 0 0.5em 2em;
|
||||
color: #5E740B;
|
||||
background-color: #eee;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
#qunit-userAgent {
|
||||
padding: 0.5em 0 0.5em 2.5em;
|
||||
background-color: #2b81af;
|
||||
color: #fff;
|
||||
text-shadow: rgba(0, 0, 0, 0.5) 2px 2px 1px;
|
||||
}
|
||||
|
||||
#qunit-modulefilter-container {
|
||||
float: right;
|
||||
}
|
||||
|
||||
/** Tests: Pass/Fail */
|
||||
|
||||
#qunit-tests {
|
||||
list-style-position: inside;
|
||||
}
|
||||
|
||||
#qunit-tests li {
|
||||
padding: 0.4em 0.5em 0.4em 2.5em;
|
||||
border-bottom: 1px solid #fff;
|
||||
list-style-position: inside;
|
||||
}
|
||||
|
||||
#qunit-tests.hidepass li.pass, #qunit-tests.hidepass li.running {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#qunit-tests li strong {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#qunit-tests li a {
|
||||
padding: 0.5em;
|
||||
color: #c2ccd1;
|
||||
text-decoration: none;
|
||||
}
|
||||
#qunit-tests li a:hover,
|
||||
#qunit-tests li a:focus {
|
||||
color: #000;
|
||||
}
|
||||
|
||||
#qunit-tests li .runtime {
|
||||
float: right;
|
||||
font-size: smaller;
|
||||
}
|
||||
|
||||
.qunit-assert-list {
|
||||
margin-top: 0.5em;
|
||||
padding: 0.5em;
|
||||
|
||||
background-color: #fff;
|
||||
|
||||
border-radius: 5px;
|
||||
-moz-border-radius: 5px;
|
||||
-webkit-border-radius: 5px;
|
||||
}
|
||||
|
||||
.qunit-collapsed {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#qunit-tests table {
|
||||
border-collapse: collapse;
|
||||
margin-top: .2em;
|
||||
}
|
||||
|
||||
#qunit-tests th {
|
||||
text-align: right;
|
||||
vertical-align: top;
|
||||
padding: 0 .5em 0 0;
|
||||
}
|
||||
|
||||
#qunit-tests td {
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
#qunit-tests pre {
|
||||
margin: 0;
|
||||
white-space: pre-wrap;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
#qunit-tests del {
|
||||
background-color: #e0f2be;
|
||||
color: #374e0c;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
#qunit-tests ins {
|
||||
background-color: #ffcaca;
|
||||
color: #500;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
/*** Test Counts */
|
||||
|
||||
#qunit-tests b.counts { color: black; }
|
||||
#qunit-tests b.passed { color: #5E740B; }
|
||||
#qunit-tests b.failed { color: #710909; }
|
||||
|
||||
#qunit-tests li li {
|
||||
padding: 5px;
|
||||
background-color: #fff;
|
||||
border-bottom: none;
|
||||
list-style-position: inside;
|
||||
}
|
||||
|
||||
/*** Passing Styles */
|
||||
|
||||
#qunit-tests li li.pass {
|
||||
color: #3c510c;
|
||||
background-color: #fff;
|
||||
border-left: 10px solid #C6E746;
|
||||
}
|
||||
|
||||
#qunit-tests .pass { color: #528CE0; background-color: #D2E0E6; }
|
||||
#qunit-tests .pass .test-name { color: #366097; }
|
||||
|
||||
#qunit-tests .pass .test-actual,
|
||||
#qunit-tests .pass .test-expected { color: #999999; }
|
||||
|
||||
#qunit-banner.qunit-pass { background-color: #C6E746; }
|
||||
|
||||
/*** Failing Styles */
|
||||
|
||||
#qunit-tests li li.fail {
|
||||
color: #710909;
|
||||
background-color: #fff;
|
||||
border-left: 10px solid #EE5757;
|
||||
white-space: pre;
|
||||
}
|
||||
|
||||
#qunit-tests > li:last-child {
|
||||
border-radius: 0 0 5px 5px;
|
||||
-moz-border-radius: 0 0 5px 5px;
|
||||
-webkit-border-bottom-right-radius: 5px;
|
||||
-webkit-border-bottom-left-radius: 5px;
|
||||
}
|
||||
|
||||
#qunit-tests .fail { color: #000000; background-color: #EE5757; }
|
||||
#qunit-tests .fail .test-name,
|
||||
#qunit-tests .fail .module-name { color: #000000; }
|
||||
|
||||
#qunit-tests .fail .test-actual { color: #EE5757; }
|
||||
#qunit-tests .fail .test-expected { color: green; }
|
||||
|
||||
#qunit-banner.qunit-fail { background-color: #EE5757; }
|
||||
|
||||
|
||||
/** Result */
|
||||
|
||||
#qunit-testresult {
|
||||
padding: 0.5em 0.5em 0.5em 2.5em;
|
||||
|
||||
color: #2b81af;
|
||||
background-color: #D2E0E6;
|
||||
|
||||
border-bottom: 1px solid white;
|
||||
}
|
||||
#qunit-testresult .module-name {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/** Fixture */
|
||||
|
||||
#qunit-fixture {
|
||||
position: absolute;
|
||||
top: -10000px;
|
||||
left: -10000px;
|
||||
width: 1000px;
|
||||
height: 1000px;
|
||||
}
|
2212
iframe-resizer-master/test/resources/qunit.js
Executable file
2212
iframe-resizer-master/test/resources/qunit.js
Executable file
File diff suppressed because it is too large
Load Diff
2103
iframe-resizer-master/test/resources/require.js
Executable file
2103
iframe-resizer-master/test/resources/require.js
Executable file
File diff suppressed because it is too large
Load Diff
9
iframe-resizer-master/test/resources/testLib.js
Executable file
9
iframe-resizer-master/test/resources/testLib.js
Executable file
@ -0,0 +1,9 @@
|
||||
function sendMessage(msg) {
|
||||
'use strict';
|
||||
//var msgId = '[iFrameSizerTest]:';
|
||||
|
||||
//document.getElementsByTagName('iframe')[0].contentWindow.postMessage( msgId + msg, '*' );
|
||||
|
||||
//console.log('Sending '+msg);
|
||||
document.getElementsByTagName('iframe')[0].iFrameResizer.sendMessage(msg);
|
||||
}
|
133
iframe-resizer-master/test/scrolling.html
Executable file
133
iframe-resizer-master/test/scrolling.html
Executable file
@ -0,0 +1,133 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>QUnit LoadHide</title>
|
||||
<link rel="stylesheet" href="resources/qunit.css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="qunit"></div>
|
||||
<div id="qunit-fixture">
|
||||
<div style="width:600px;">
|
||||
<iframe
|
||||
src="resources/frame.content.html"
|
||||
width="100%"
|
||||
scrolling="no"
|
||||
></iframe>
|
||||
</div>
|
||||
</div>
|
||||
<script src="resources/qunit.js"></script>
|
||||
<script src="resources/jquery.js"></script>
|
||||
<script src="../js/iframeResizer.min.js"></script>
|
||||
<script>
|
||||
'use strict'
|
||||
var msgId = '[iFrameSizerTest]:'
|
||||
|
||||
asyncTest('scrolling not set', function() {
|
||||
$('iframe').iFrameResize({
|
||||
//log:true,
|
||||
onResized: function(messageData) {
|
||||
ok(true, 'Receive message back from iFrame.')
|
||||
ok(
|
||||
'hidden' === messageData.iframe.style.overflow,
|
||||
'iFrame overflow = ' +
|
||||
messageData.iframe.style.overflow +
|
||||
". Expected 'hidden'."
|
||||
)
|
||||
ok(
|
||||
'no' === messageData.iframe.scrolling,
|
||||
'iFrame scrolling = ' +
|
||||
messageData.iframe.scrolling +
|
||||
". Expected 'no'."
|
||||
)
|
||||
start()
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
asyncTest('scrolling = false', function() {
|
||||
$('iframe').iFrameResize({
|
||||
//log:true,
|
||||
scrolling: false,
|
||||
onResized: function(messageData) {
|
||||
ok(true, 'Receive message back from iFrame.')
|
||||
ok(
|
||||
'hidden' === messageData.iframe.style.overflow,
|
||||
'iFrame overflow = ' +
|
||||
messageData.iframe.style.overflow +
|
||||
". Expected 'hidden'."
|
||||
)
|
||||
ok(
|
||||
'no' === messageData.iframe.scrolling,
|
||||
'iFrame scrolling = ' +
|
||||
messageData.iframe.scrolling +
|
||||
". Expected 'no'."
|
||||
)
|
||||
start()
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
asyncTest('scrolling = true', function() {
|
||||
$('iframe').iFrameResize({
|
||||
//log:true,
|
||||
scrolling: true,
|
||||
onResized: function(messageData) {
|
||||
ok(true, 'Receive message back from iFrame.')
|
||||
ok(
|
||||
'auto' === messageData.iframe.style.overflow,
|
||||
'iFrame overflow = ' +
|
||||
messageData.iframe.style.overflow +
|
||||
". Expected 'auto'."
|
||||
)
|
||||
ok(
|
||||
'yes' === messageData.iframe.scrolling,
|
||||
'iFrame scrolling = ' +
|
||||
messageData.iframe.scrolling +
|
||||
". Expected 'yes'."
|
||||
)
|
||||
start()
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
asyncTest('scrolling = auto', function() {
|
||||
$('iframe').iFrameResize({
|
||||
//log:true,
|
||||
scrolling: 'auto',
|
||||
onResized: function(messageData) {
|
||||
ok(true, 'Receive message back from iFrame.')
|
||||
ok(
|
||||
'auto' === messageData.iframe.style.overflow,
|
||||
'iFrame overflow = ' +
|
||||
messageData.iframe.style.overflow +
|
||||
". Expected 'auto'."
|
||||
)
|
||||
ok(
|
||||
'auto' === messageData.iframe.scrolling,
|
||||
'iFrame scrolling = ' +
|
||||
messageData.iframe.scrolling +
|
||||
". Expected 'auto'."
|
||||
)
|
||||
start()
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
// asyncTest( "scrolling = omit", function() {
|
||||
// $('iframe').removeAttr('scrolling');
|
||||
// $('iframe').iFrameResize({
|
||||
// //log:true,
|
||||
// scrolling:'omit',
|
||||
// onResized:function(messageData){
|
||||
// ok( true, 'Receive message back from iFrame.' );
|
||||
// ok( 'auto' === messageData.iframe.style.overflow, 'iFrame overflow = ' + messageData.iframe.style.overflow + '. Expected \'auto\'.' );
|
||||
// ok( false === ('scrolling' in messageData.iframe), 'iFrame scrolling attribute exists. Expected to be omitted.' );
|
||||
// start();
|
||||
// }
|
||||
// });
|
||||
// });
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
65
iframe-resizer-master/test/sendMessage.html
Executable file
65
iframe-resizer-master/test/sendMessage.html
Executable file
@ -0,0 +1,65 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>QUnit LoadHide</title>
|
||||
<link rel="stylesheet" href="resources/qunit.css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="qunit"></div>
|
||||
<div id="qunit-fixture">
|
||||
<div style="width:600px;">
|
||||
<iframe
|
||||
src="resources/frame.content.html"
|
||||
width="100%"
|
||||
scrolling="no"
|
||||
></iframe>
|
||||
</div>
|
||||
</div>
|
||||
<script src="resources/qunit.js"></script>
|
||||
<script src="resources/jquery.js"></script>
|
||||
<script src="resources/testLib.js"></script>
|
||||
<script src="../js/ie8.polyfils.min.js"></script>
|
||||
<script src="../js/iframeResizer.min.js"></script>
|
||||
<script>
|
||||
'use strict'
|
||||
var count = 0,
|
||||
msgId = '[iFrameSizerTest]:'
|
||||
|
||||
asyncTest('sendMessage (string)', function() {
|
||||
iFrameResize({
|
||||
//log:true,
|
||||
onResized: function(messageData) {
|
||||
ok(true, 'Receive init message back from iFrame.')
|
||||
sendMessage('chkSendMsg')
|
||||
},
|
||||
onMessage: function(messageData) {
|
||||
ok(
|
||||
'message: test string' === messageData.message,
|
||||
'Receive string message back from iFrame via sendMessage function.'
|
||||
)
|
||||
start()
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
asyncTest('sendMessage (object)', function() {
|
||||
iFrameResize({
|
||||
//log:true,
|
||||
onResized: function(messageData) {
|
||||
ok(true, 'Receive init message back from iFrame.')
|
||||
sendMessage('chkSendObj')
|
||||
},
|
||||
onMessage: function(messageData) {
|
||||
ok(
|
||||
'test object' === messageData.message.message,
|
||||
'Receive object message back from iFrame via sendMessage function.'
|
||||
)
|
||||
start()
|
||||
}
|
||||
})
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
48
iframe-resizer-master/test/setHeightCalculationMethod.html
Executable file
48
iframe-resizer-master/test/setHeightCalculationMethod.html
Executable file
@ -0,0 +1,48 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>QUnit LoadHide</title>
|
||||
<link rel="stylesheet" href="resources/qunit.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="qunit"></div>
|
||||
<div id="qunit-fixture">
|
||||
<div style="width:600px;">
|
||||
<iframe
|
||||
src="resources/frame.content.html"
|
||||
width="100%"
|
||||
scrolling="no"
|
||||
></iframe>
|
||||
</div>
|
||||
</div>
|
||||
<script src="resources/qunit.js"></script>
|
||||
<script src="resources/jquery.js"></script>
|
||||
<script src="resources/testLib.js"></script>
|
||||
<script src="../js/ie8.polyfils.min.js"></script>
|
||||
<script src="../js/iframeResizer.min.js"></script>
|
||||
<script>
|
||||
'use strict'
|
||||
var msgId = '[iFrameSizerTest]:'
|
||||
|
||||
asyncTest('setHeightCalculationMethod', function() {
|
||||
var evtCounter = 0
|
||||
|
||||
iFrameResize({
|
||||
//log:true,
|
||||
interval: 0,
|
||||
onResized: function(messageData) {
|
||||
switch ('' + ++evtCounter) {
|
||||
case '1':
|
||||
sendMessage('setHeightCalculationMethod')
|
||||
break
|
||||
default:
|
||||
ok(true, 'iFrame detected content change')
|
||||
start()
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
74
iframe-resizer-master/test/size.html
Executable file
74
iframe-resizer-master/test/size.html
Executable file
@ -0,0 +1,74 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>QUnit LoadHide</title>
|
||||
<link rel="stylesheet" href="resources/qunit.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="qunit"></div>
|
||||
<div id="qunit-fixture">
|
||||
<div style="width:400px;">
|
||||
<iframe
|
||||
src="resources/frame.content.html"
|
||||
width="100%"
|
||||
scrolling="no"
|
||||
></iframe>
|
||||
</div>
|
||||
</div>
|
||||
<script src="resources/qunit.js"></script>
|
||||
<script src="resources/jquery.js"></script>
|
||||
<script src="../js/ie8.polyfils.min.js"></script>
|
||||
<script src="../js/iframeResizer.min.js"></script>
|
||||
<script src="resources/testLib.js"></script>
|
||||
<script>
|
||||
'use strict'
|
||||
var msgId = '[iFrameSizerTest]:'
|
||||
|
||||
asyncTest('iFrame size Event', function() {
|
||||
var evtCounter = 0
|
||||
|
||||
$('iframe').iFrameResize({
|
||||
//log:true,
|
||||
interval: 0,
|
||||
onResized: function(messageData) {
|
||||
var msgType = 'size'
|
||||
|
||||
switch ('' + ++evtCounter) {
|
||||
case '1':
|
||||
sendMessage(msgType)
|
||||
break
|
||||
case '2':
|
||||
// ok( msgType === messageData.type, 'Received '+messageData.type+' message back from iFrame. Expected '+msgType);
|
||||
sendMessage('size100')
|
||||
break
|
||||
case '3':
|
||||
ok(
|
||||
msgType === messageData.type,
|
||||
'Received ' +
|
||||
messageData.type +
|
||||
' message back from iFrame. Expected ' +
|
||||
msgType
|
||||
)
|
||||
ok('100' === messageData.height, 'Height received = 100')
|
||||
//ok( 100 === $('iframe').height(), 'IFrame height = 100'); Works in phaatomJS, but not chrome!
|
||||
sendMessage('size200300')
|
||||
break
|
||||
case '4':
|
||||
ok(
|
||||
msgType === messageData.type,
|
||||
'Received ' +
|
||||
messageData.type +
|
||||
' message back from iFrame. Expected ' +
|
||||
msgType
|
||||
)
|
||||
ok('200' === messageData.height, 'Height received = 200')
|
||||
ok('300' === messageData.width, 'Width received = 300')
|
||||
start()
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
203
iframe-resizer-master/test/v1.html
Executable file
203
iframe-resizer-master/test/v1.html
Executable file
@ -0,0 +1,203 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>QUnit LoadHide</title>
|
||||
<link rel="stylesheet" href="resources/qunit.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="qunit"></div>
|
||||
<div id="qunit-fixture">
|
||||
<div style="width:600px;">
|
||||
<iframe
|
||||
src="resources/frame.content.html"
|
||||
width="100%"
|
||||
scrolling="no"
|
||||
></iframe>
|
||||
</div>
|
||||
</div>
|
||||
<script src="resources/qunit.js"></script>
|
||||
<script src="resources/jquery.js"></script>
|
||||
<script>
|
||||
/*
|
||||
* File: jquery.iframeSizer.js
|
||||
* Desc: Force cross domain iframes to size to content.
|
||||
* Requires: iframeSizer.contentWindow.js to be loaded into the target frame.
|
||||
* Author: David J. Bradshaw - dave@bradshaw.net
|
||||
* Date: 2013-06-14
|
||||
*/
|
||||
|
||||
;(function($) {
|
||||
var msgId = '[iFrameSizer]', //Must match iframe msg ID
|
||||
msgIdLen = msgId.length,
|
||||
count = 0,
|
||||
settings,
|
||||
defaults = {
|
||||
log: false,
|
||||
contentWindowBodyMargin: 8,
|
||||
doHeight: true,
|
||||
doWidth: false,
|
||||
interval: 0,
|
||||
enablePublicMethods: false,
|
||||
callback: function() {}
|
||||
}
|
||||
|
||||
function setupRAF() {
|
||||
var vendors = ['moz', 'webkit', 'o', 'ms'],
|
||||
x
|
||||
|
||||
// Remove vendor prefixing if prefixed and break early if not
|
||||
for (
|
||||
x = 0;
|
||||
x < vendors.length && !window.requestAnimationFrame;
|
||||
x += 1
|
||||
) {
|
||||
window.requestAnimationFrame =
|
||||
window[vendors[x] + 'RequestAnimationFrame']
|
||||
}
|
||||
|
||||
// If not supported then just call callback
|
||||
if (!window.requestAnimationFrame) {
|
||||
log(' RequestAnimationFrame not supported')
|
||||
window.requestAnimationFrame = function(callback) {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function log(msg) {
|
||||
if (window.console) {
|
||||
console.log(msgId + '[Host page]' + msg)
|
||||
}
|
||||
}
|
||||
|
||||
setupRAF()
|
||||
|
||||
$(window).on('message', function(event) {
|
||||
function receiver(msg) {
|
||||
function resize() {
|
||||
function setDimension(dimension) {
|
||||
window.requestAnimationFrame(function() {
|
||||
messageData.iframe.style[dimension] =
|
||||
messageData[dimension] + 'px'
|
||||
log(
|
||||
' ' +
|
||||
messageData.iframe.id +
|
||||
' ' +
|
||||
dimension +
|
||||
' set to ' +
|
||||
messageData[dimension] +
|
||||
'px'
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
if (settings.doHeight) {
|
||||
setDimension('height')
|
||||
}
|
||||
|
||||
if (settings.doWidth) {
|
||||
setDimension('width')
|
||||
}
|
||||
}
|
||||
|
||||
function processMsg() {
|
||||
var data = msg.slice(msgIdLen).split(':')
|
||||
|
||||
messageData = {
|
||||
iframe: document.getElementById(data[0]),
|
||||
height: data[1],
|
||||
width: data[2]
|
||||
}
|
||||
}
|
||||
|
||||
var messageData = {}
|
||||
|
||||
//check message is for us.
|
||||
if (msgId === msg.slice(0, msgIdLen)) {
|
||||
processMsg()
|
||||
resize()
|
||||
settings.callback(messageData, settings)
|
||||
}
|
||||
}
|
||||
|
||||
receiver(event.originalEvent.data)
|
||||
})
|
||||
|
||||
$.fn.iFrameSizer = function(options) {
|
||||
settings = $.extend({}, defaults, options)
|
||||
|
||||
return this.each(function() {
|
||||
function isIframe() {
|
||||
return iframe.contentWindow ? true : false
|
||||
}
|
||||
|
||||
//We have to call trigger twice, as we can not be sure if all
|
||||
//iframes have completed loading when this code runs.
|
||||
function init() {
|
||||
iframe.style.overflow = 'hidden'
|
||||
iframe.scrolling = 'no'
|
||||
|
||||
$(iframe).on('load', function() {
|
||||
trigger('iFrame.onload')
|
||||
})
|
||||
trigger('init')
|
||||
}
|
||||
|
||||
function trigger(calleeMsg) {
|
||||
function ensureHasId() {
|
||||
if ('' === iframe.id) {
|
||||
iframe.id = 'iFrameSizer' + count++
|
||||
log(' Added missing iframe ID: ' + iframe.id)
|
||||
}
|
||||
}
|
||||
|
||||
function postMessageToIframe() {
|
||||
var msg =
|
||||
iframe.id +
|
||||
':' +
|
||||
settings.contentWindowBodyMargin +
|
||||
':' +
|
||||
settings.doWidth +
|
||||
':' +
|
||||
settings.log +
|
||||
':' +
|
||||
settings.interval +
|
||||
':' +
|
||||
settings.enablePublicMethods
|
||||
log(
|
||||
'[' + calleeMsg + '] Sending init msg to iframe (' + msg + ')'
|
||||
)
|
||||
iframe.contentWindow.postMessage(msgId + msg, '*')
|
||||
}
|
||||
|
||||
ensureHasId()
|
||||
postMessageToIframe()
|
||||
}
|
||||
|
||||
var iframe = this
|
||||
|
||||
if (isIframe()) {
|
||||
init()
|
||||
}
|
||||
})
|
||||
}
|
||||
})(window.jQuery)
|
||||
</script>
|
||||
<script>
|
||||
'use strict'
|
||||
var msgId = '[iFrameSizerTest]:'
|
||||
|
||||
asyncTest('postMessage Response', function() {
|
||||
$('iframe').iFrameSizer({
|
||||
callback: function(messageData) {
|
||||
//console.log('Receive message back from iFrame.')
|
||||
ok(true, 'Receive message back from iFrame.')
|
||||
ok('600' === messageData.width, 'iFrame width = 600.')
|
||||
start()
|
||||
}
|
||||
})
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user