Bug 748803. Don't autofocus the Try Again button in error pages if the error page is not a toplevel page. r=mounir

This commit is contained in:
Boris Zbarsky 2012-04-30 21:57:16 -04:00
parent c96eedd250
commit 6908ac2ac3
4 changed files with 33 additions and 1 deletions

View File

@ -394,7 +394,22 @@
</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>

View File

@ -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>

View File

@ -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>

View File

@ -1700,3 +1700,4 @@ fuzzy-if(d2d,1,19) fuzzy-if(cocoaWidget,1,170) == 718521.html 718521-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