Skip to content

Commit

Permalink
Merge pull request Modernizr#1581 from patrickkettner/confirm-iframe-…
Browse files Browse the repository at this point in the history
…parsing

ensure modernizr can run inside an iframe
  • Loading branch information
patrickkettner committed Apr 21, 2015
2 parents 23fd2f3 + 2c98c24 commit 9e249d5
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions test/browser/integration/iframe.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
describe('iframe context', function() {

this.timeout(20000);
var iframeWindow;
var $iframe;

before(function(done) {
var url = './iframe.html?id=modernizrIframeContext';
$iframe = $('<iframe>');

$(document.body).append($iframe);

$iframe
.css({
'height':10,
'width':10,
'position':'absolute',
'top': 0,
'left': 0
})
.attr({
'src': url,
'id': 'modernizrIframeContext'
})
.on('lockedAndLoaded', function() {
iframeWindow = $(this)[0].contentWindow;
done();
});
});

it('is able to be loaded in an iframe', function(done) {
iframeWindow.$.getScript('http://localhost:9999/dist/modernizr-build.js')
.done(function(build, status) {
expect(status).to.equal('success');
expect(iframeWindow.Modernizr).to.not.be(undefined);
done();
})
.fail(function(ajaxResponse, errorType, err) {
if (err && err.message) {
expect(err.message).to.be(undefined);
} else {
expect(errorType).to.be(undefined);
}
done();
});
});

after(function() {
$iframe.remove();
iframeWindow = $iframe = undefined;
});
});

0 comments on commit 9e249d5

Please sign in to comment.