B2G/gecko/browser/base/content/test/newtab/browser_newtab_focus.js
/**
 * Focus the urlbar and count how many focus stops to return again to the urlbar.
 */
Focus the urlbar and count how many focus stops to return again to the urlbar.
Focus the urlbar and count how many focus stops to return again to the urlbar .
function countFocus(aExpectedCount) {
  let focusCount = 0;
  let contentDoc = getContentDocument();
  window.addEventListener("focus", function onFocus() {
    let focusedElement = document.commandDispatcher.focusedElement;
    if (focusedElement && focusedElement.classList.contains("urlbar-input")) {
      window.removeEventListener("focus", onFocus, true);
      is(focusCount, aExpectedCount, "Validate focus count in the new tab page.");
      executeSoon(TestRunner.next);
    } else {
      if (focusedElement && focusedElement.ownerDocument == contentDoc &&
          focusedElement instanceof HTMLElement) {
        focusCount++;
      }
      document.commandDispatcher.advanceFocus();
    }
  }, true);
  document.commandDispatcher.advanceFocus();
}
function countFocus ( aExpectedCount ) { let focusCount = 0 ; let contentDoc = getContentDocument ( ) ; window . addEventListener ( "focus" , function onFocus ( ) { let focusedElement = document . commandDispatcher . focusedElement ; if ( focusedElement && focusedElement . classList . contains ( "urlbar-input" ) ) { window . removeEventListener ( "focus" , onFocus , true ) ; is ( focusCount , aExpectedCount , "Validate focus count in the new tab page." ) ; executeSoon ( TestRunner . next ) ; } else { if ( focusedElement && focusedElement . ownerDocument == contentDoc && focusedElement instanceof HTMLElement ) { focusCount ++ ; } document . commandDispatcher . advanceFocus ( ) ; } } , true ) ; document . commandDispatcher . advanceFocus ( ) ; }
Focus the urlbar and count how many focus stops to return again to the urlbar.
Focus the urlbar and count how many focus stops to return again to the urlbar .