From 682de58eb5cd75c67a607666035d505e1529d141 Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Thu, 11 Jul 2013 00:44:37 +0000 Subject: [PATCH] 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 --- wp-includes/js/wp-auth-check.js | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/wp-includes/js/wp-auth-check.js b/wp-includes/js/wp-auth-check.js index 2a1731879b..aa2b1ddcb0 100644 --- a/wp-includes/js/wp-auth-check.js +++ b/wp-includes/js/wp-auth-check.js @@ -1,6 +1,6 @@ // Interim login dialog (function($){ - var wrap, check, scheduleTimeout, hideTimeout; + var wrap, check, scheduleTimeout; function show() { 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(); } catch(e) { wrap.addClass('fallback'); + parent.css( 'max-height', '' ); form.remove(); noframe.focus(); return; } if ( height ) { - if ( body && body.hasClass('interim-login-success') ) { - height += 35; - parent.find('.wp-auth-check-close').show(); - wrap.data('logged-in', 1); - hideTimeout = setTimeout( function() { hide(); }, 3000 ); - } - - parent.css( 'max-height', height + 60 + 'px' ); + if ( body && body.hasClass('interim-login-success') ) + hide(); + else + parent.css( 'max-height', height + 60 + 'px' ); + } 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', '' ); + form.remove(); + noframe.focus(); } }).attr( 'src', form.data('src') ); @@ -47,14 +50,14 @@ if ( frame ) { frame.focus(); // 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() { if ( ! loaded ) { wrap.addClass('fallback'); form.remove(); noframe.focus(); } - }, 5000 ); + }, 10000 ); } else { noframe.focus(); } @@ -62,7 +65,6 @@ function hide() { $(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 if ( typeof adminpage != 'undefined' && ( adminpage == 'post-php' || adminpage == 'post-new-php' ) @@ -89,12 +91,12 @@ if ( data['wp-auth-check'] && wrap.hasClass('hidden') ) { show(); - } else if ( ! data['wp-auth-check'] && ! wrap.hasClass('hidden') && ! wrap.data('logged-in') ) { + } else if ( ! data['wp-auth-check'] && ! wrap.hasClass('hidden') ) { hide(); } }).ready( function() { 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) { hide(); });