Skip to content
This repository has been archived by the owner on Jun 29, 2018. It is now read-only.

Commit

Permalink
Use postMessage to give iframe focus [#1045]
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher De Cairos committed May 16, 2012
1 parent ab073cc commit d465282
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions test/popcorn.inject.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@
});
// Fail tests that don't complete in 60s
QUnit.config.testTimeout = 60000;

window.addEventListener( "message", function( e ) {
if ( e.data === "getFocus" ) {
window.focus();
}
}, false );
}

})( window );
7 changes: 7 additions & 0 deletions test/popcorn.testrunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ $(function() {
create = function( type ) {
return document.createElement( type );
},
sendGetFocus = function( event ) {
event.target &&
event.target.contentWindow &&
event.target.contentWindow.postMessage( "getFocus", "*" );
},
index = 0,
testFrame = id( "test-frame" )
results = id( "qunit-tests" ),
Expand All @@ -19,6 +24,8 @@ $(function() {
results_arr = [],
userAgent = id( "qunit-userAgent" );

testFrame.addEventListener( "load", sendGetFocus, false );

if ( userAgent ) {
userAgent.innerHTML = navigator.userAgent;
};
Expand Down

0 comments on commit d465282

Please sign in to comment.