Logged out warnings:

- Close the iframe immediately on successful login.
- Catch iframe origin exceptions in WebKit when there is a server error or another page is loaded in the iframe.
See #23295.

git-svn-id: http://core.svn.wordpress.org/trunk@24655 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Ozz 2013-07-11 00:44:37 +00:00
parent 9602a29c5d
commit 682de58eb5
1 changed files with 16 additions and 14 deletions

View File

@ -1,6 +1,6 @@
// Interim login dialog // Interim login dialog
(function($){ (function($){
var wrap, check, scheduleTimeout, hideTimeout; var wrap, check, scheduleTimeout;
function show() { function show() {
var parent = $('#wp-auth-check'), form = $('#wp-auth-check-form'), noframe = wrap.find('.wp-auth-fallback-expired'), frame, loaded = false; var parent = $('#wp-auth-check'), form = $('#wp-auth-check-form'), noframe = wrap.find('.wp-auth-fallback-expired'), frame, loaded = false;
@ -22,20 +22,23 @@
height = body.height(); height = body.height();
} catch(e) { } catch(e) {
wrap.addClass('fallback'); wrap.addClass('fallback');
parent.css( 'max-height', '' );
form.remove(); form.remove();
noframe.focus(); noframe.focus();
return; return;
} }
if ( height ) { if ( height ) {
if ( body && body.hasClass('interim-login-success') ) { if ( body && body.hasClass('interim-login-success') )
height += 35; hide();
parent.find('.wp-auth-check-close').show(); else
wrap.data('logged-in', 1); parent.css( 'max-height', height + 60 + 'px' );
hideTimeout = setTimeout( function() { hide(); }, 3000 ); } else if ( ! body || ! body.length ) {
} // Catch "silent" iframe origin exceptions in WebKit after another page is loaded in the iframe
wrap.addClass('fallback');
parent.css( 'max-height', height + 60 + 'px' ); parent.css( 'max-height', '' );
form.remove();
noframe.focus();
} }
}).attr( 'src', form.data('src') ); }).attr( 'src', form.data('src') );
@ -47,14 +50,14 @@
if ( frame ) { if ( frame ) {
frame.focus(); frame.focus();
// WebKit doesn't throw an error if the iframe fails to load because of "X-Frame-Options: DENY" header. // WebKit doesn't throw an error if the iframe fails to load because of "X-Frame-Options: DENY" header.
// Wait for 5 sec. and switch to the fallback text. // Wait for 10 sec. and switch to the fallback text.
setTimeout( function() { setTimeout( function() {
if ( ! loaded ) { if ( ! loaded ) {
wrap.addClass('fallback'); wrap.addClass('fallback');
form.remove(); form.remove();
noframe.focus(); noframe.focus();
} }
}, 5000 ); }, 10000 );
} else { } else {
noframe.focus(); noframe.focus();
} }
@ -62,7 +65,6 @@
function hide() { function hide() {
$(window).off( 'beforeunload.wp-auth-check' ); $(window).off( 'beforeunload.wp-auth-check' );
window.clearTimeout( hideTimeout );
// When on the Edit Post screen, speed up heartbeat after the user logs in to quickly refresh nonces // When on the Edit Post screen, speed up heartbeat after the user logs in to quickly refresh nonces
if ( typeof adminpage != 'undefined' && ( adminpage == 'post-php' || adminpage == 'post-new-php' ) if ( typeof adminpage != 'undefined' && ( adminpage == 'post-php' || adminpage == 'post-new-php' )
@ -89,12 +91,12 @@
if ( data['wp-auth-check'] && wrap.hasClass('hidden') ) { if ( data['wp-auth-check'] && wrap.hasClass('hidden') ) {
show(); show();
} else if ( ! data['wp-auth-check'] && ! wrap.hasClass('hidden') && ! wrap.data('logged-in') ) { } else if ( ! data['wp-auth-check'] && ! wrap.hasClass('hidden') ) {
hide(); hide();
} }
}).ready( function() { }).ready( function() {
schedule(); schedule();
wrap = $('#wp-auth-check-wrap').data( 'logged-in', 0 ); wrap = $('#wp-auth-check-wrap');
wrap.find('.wp-auth-check-close').on( 'click', function(e) { wrap.find('.wp-auth-check-close').on( 'click', function(e) {
hide(); hide();
}); });