Bug 748803. Don't autofocus the Try Again button in error pages if the error page is not a toplevel page. r=mounir
authorBoris Zbarsky <bzbarsky@mit.edu>
Mon, 30 Apr 2012 21:57:16 -0400
changeset 92855 80ece0284245dde3ea5967a105df1bfcaa989632
parent 92854 0831ce6ba72ffdb1d020e7ecbd5468ac076950d4
child 92856 f031b89c104ef17a9c9fd35925b8c70e48829743
push id22595
push usereakhgari@mozilla.com
push dateThu, 03 May 2012 04:00:15 +0000
treeherdermozilla-central@807403a04a6a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmounir
bugs748803
milestone15.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 748803. Don't autofocus the Try Again button in error pages if the error page is not a toplevel page. r=mounir
docshell/resources/content/netError.xhtml
layout/reftests/bugs/748803-1-ref.html
layout/reftests/bugs/748803-1.html
layout/reftests/bugs/reftest.list
--- a/docshell/resources/content/netError.xhtml
+++ b/docshell/resources/content/netError.xhtml
@@ -389,17 +389,32 @@
              error types.  -->
         <div id="securityOverrideDiv">
           <a id="securityOverrideLink" href="javascript:showSecuritySection();" >&securityOverride.linkText;</a>
           <div id="securityOverrideContent" style="display: none;">&securityOverride.warningContent;</div>
         </div>
       </div>
 
       <!-- Retry Button -->
-      <button id="errorTryAgain" autocomplete="off" onclick="retryThis(this);" autofocus="true">&retry.label;</button>
+      <button id="errorTryAgain" autocomplete="off" onclick="retryThis(this);">&retry.label;</button>
+      <script>
+        // Only do autofocus if we're the toplevel frame; otherwise we
+        // don't want to call attention to ourselves!  The key part is
+        // that autofocus happens on insertion into the tree, so we
+        // can remove the button, add @autofocus, and reinsert the
+        // button.
+        if (window.top == window) {
+            var button = document.getElementById("errorTryAgain");
+            var nextSibling = button.nextSibling;
+            var parent = button.parentNode;
+            parent.removeChild(button);
+            button.setAttribute("autofocus", "true");
+            parent.insertBefore(button, nextSibling);
+        }
+      </script>
 
     </div>
 
     <!--
     - Note: It is important to run the script this way, instead of using
     - an onload handler. This is because error pages are loaded as
     - LOAD_BACKGROUND, which means that onload handlers will not be executed.
     -->
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/748803-1-ref.html
@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<html style="height: 100%;">
+  <body style="height: 100%;">
+    <!-- Make sure the div forces the frame off the screen by default -->
+    <div style="height: 200%"></div>
+    <iframe></iframe>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/748803-1.html
@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<html style="height: 100%;">
+  <body style="height: 100%;">
+    <!-- Make sure the div forces the frame off the screen by default -->
+    <div style="height: 200%"></div>
+    <iframe src="about:neterror"></iframe>
+  </body>
+</html>
--- a/layout/reftests/bugs/reftest.list
+++ b/layout/reftests/bugs/reftest.list
@@ -1695,8 +1695,9 @@ fuzzy-if(d2d,1,19) fuzzy-if(cocoaWidget,
 == 722923-1.html 722923-1-ref.html
 == 723484-1.html 723484-1-ref.html
 == 728983-1.html 728983-1-ref.html
 == 729143-1.html 729143-1-ref.html
 == 731521-1.html 731521-1-ref.html
 needs-focus == 731726-1.html 731726-1-ref.html
 == 735481-1.html 735481-1-ref.html
 == 745934-1.html 745934-1-ref.html
+== 748803-1.html 748803-1-ref.html