Commit 0aa272d8 authored by Noemi Erli's avatar Noemi Erli
Browse files

Backed out 2 changesets (bug 1781434) for causing failures in test_bug398289.html CLOSED TREE

Backed out changeset d6a154ada951 (bug 1781434)
Backed out changeset 0ddeff2468d8 (bug 1781434)
parent f0790c2c
Loading
Loading
Loading
Loading
+10 −7
Original line number Diff line number Diff line
@@ -6,8 +6,10 @@
  <script src="chrome://mochikit/content/tests/SimpleTest/WindowSnapshot.js"></script>
  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
</head>
<body style="height: 100%; overflow: hidden; margin: 0" onload="setTimeout(onBodyLoad, 0);">
  <iframe frmeborder=0 scrolling=no id="test" src="398289-resource.xhtml" width="100%" height="100%"></iframe>
<body style="height: 100%" onload="setTimeout(onBodyLoad, 0);">
  <iframe id="test" src="398289-resource.xhtml" width="100%" height="100%">
  </iframe>

  <script class="testbody" type="text/javascript">
    var snap1, snap2;
  
@@ -30,6 +32,7 @@
      [equal, str1, str2] = compareSnapshots(snap1, snap2, true);

      ok(equal, "persistent attribute in tab box broken, expected: "+str1+" got: "+str2);
          
      SimpleTest.finish();
    }
  </script>
+1 −7
Original line number Diff line number Diff line
@@ -1063,19 +1063,13 @@ async function runTests(util) {
    passValue: "",
    checkMsg: "",
    checked: false,
    focused: null, // Nothing focused until the delay triggers.
    focused: "infoBody",
    defButton: "button0",
    butt0Label: "OK",
    butt1Label: "Cancel",
    butt0Disabled: true,
  };

  if (isOSX) {
    // OS X doesn't initially focus the button, but rather the infoBody.
    // The focus stays there even after the button-enable delay has fired.
    state.focused = "infoBody";
  }

  action = {
    buttonClick: "pollOK",
  };
+31 −29
Original line number Diff line number Diff line
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>

<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
<window onload="loaded()"
        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
        xmlns:html="http://www.w3.org/1999/xhtml">
<dialog id="dialog-focus"
        buttons="extra2,accept,cancel">
@@ -23,6 +24,8 @@
<button id="two" label="Two" hidden="true"/>

<script>
function loaded()
{
  if (window.arguments) {
    var step = window.arguments[0];
    switch (step) {
@@ -42,11 +45,9 @@ if (window.arguments) {
        document.getElementById("tabbox").hidden = false;
        break;
      case 7:
      window.addEventListener("load", function() {
        var two = document.getElementById("two");
        two.hidden = false;
        two.focus();
      });
        break;
      case 8:
        document.getElementById("textbox-yes").hidden = false;
@@ -56,6 +57,7 @@ if (window.arguments) {
        break;
    }
  }
}
</script>

</dialog>
+59 −66
Original line number Diff line number Diff line
@@ -240,14 +240,13 @@
      window.moveTo(xOffset, yOffset);
    }

    // Give focus to the first focusable element in the dialog
    _setInitialFocusIfNeeded() {
      let focusedElt = document.commandDispatcher.focusedElement;
      if (focusedElt) {
        return;
      }

    postLoadInit(aEvent) {
      let focusInit = () => {
        const defaultButton = this.getButton(this.defaultButton);

        // give focus to the first focusable element in the dialog
        let focusedElt = document.commandDispatcher.focusedElement;
        if (!focusedElt) {
          Services.focus.moveFocus(
            window,
            null,
@@ -256,11 +255,8 @@
          );

          focusedElt = document.commandDispatcher.focusedElement;
      if (!focusedElt) {
        return; // No focusable element?
      }

      let firstFocusedElt = focusedElt;
          if (focusedElt) {
            var initialFocusedElt = focusedElt;
            while (
              focusedElt.localName == "tab" ||
              focusedElt.getAttribute("noinitialfocus") == "true"
@@ -272,48 +268,45 @@
                Services.focus.FLAG_NOPARENTFRAME
              );
              focusedElt = document.commandDispatcher.focusedElement;
        if (focusedElt == firstFocusedElt) {
              if (focusedElt) {
                if (focusedElt == initialFocusedElt) {
                  if (focusedElt.getAttribute("noinitialfocus") == "true") {
                    focusedElt.blur();
                  }
          // Didn't find anything else to focus, we're done.
          return;
                  break;
                }
              }
            }

      if (firstFocusedElt.localName == "tab") {
            if (initialFocusedElt.localName == "tab") {
              if (focusedElt.hasAttribute("dlgtype")) {
                // We don't want to focus on anonymous OK, Cancel, etc. buttons,
                // so return focus to the tab itself
          firstFocusedElt.focus();
                initialFocusedElt.focus();
              }
            } else if (
              AppConstants.platform != "macosx" &&
              focusedElt.hasAttribute("dlgtype") &&
              focusedElt != defaultButton
            ) {
              // If the default button is not focusable, then return focus.
              defaultButton.focus();
              if (document.commandDispatcher.focusedElement != defaultButton) {
          // If the default button is not focusable, then return focus to the
          // initial element if possible, or blur otherwise.
          if (firstFocusedElt.getAttribute("noinitialfocus") == "true") {
            focusedElt.blur();
          } else {
            firstFocusedElt.focus();
                initialFocusedElt.focus();
              }
            }
          }
        }

    postLoadInit(aEvent) {
      this._setInitialFocusIfNeeded();

        try {
        const defaultButton = this.getButton(this.defaultButton);
          if (defaultButton) {
            window.notifyDefaultButtonLoaded(defaultButton);
          }
        } catch (e) {}
      };

      // Give focus after onload completes, see bug 103197.
      setTimeout(focusInit, 0);

      if (this._l10nButtons.length) {
        document.l10n.translateElements(this._l10nButtons).then(() => {