B2G/gecko/browser/base/content/test/browser_bug561636.js
/**
 * In this test, we check that nothing happen (no focus nor popup) if the
 * invalid form is submitted in another tab than the current focused one
 * (submitted in background).
 */
In this test, we check that nothing happen (no focus nor popup) if the
invalid form is submitted in another tab than the current focused one
(submitted in background).
In this test we check that nothing happen ( no focus nor popup ) if the invalid form is submitted in another tab than the current focused one ( submitted in background ) .
function test8()
{
  let uri = "data:text/html,<iframe name='t'></iframe><form target='t' action='data:text/html,'><input id='i' required><input id='s' type='submit'></form>";
  let tab = gBrowser.addTab();
  gObserver.notifyInvalidSubmit = function() {
    executeSoon(function() {
      let doc = tab.linkedBrowser.contentDocument;
      isnot(doc.activeElement, doc.getElementById('i'),
            "We should not focus the invalid element when the form is submitted in background");
      checkPopupHide();
      Services.obs.removeObserver(gObserver, "invalidformsubmit");
      gObserver.notifyInvalidSubmit = function () {};
      gBrowser.removeTab(tab);
      executeSoon(test9);
    });
  };
  Services.obs.addObserver(gObserver, "invalidformsubmit", false);
  tab.linkedBrowser.addEventListener("load", function(aEvent) {
    tab.linkedBrowser.removeEventListener("load", arguments.callee, true);
    isnot(gBrowser.selectedTab, tab,
          "This tab should have been loaded in background");
    tab.linkedBrowser.contentDocument.getElementById('s').click();
  }, true);
  tab.linkedBrowser.loadURI(uri);
}
function test8 ( ) { let uri = "data:text/html,<iframe name='t'></iframe><form target='t' action='data:text/html,'><input id='i' required><input id='s' type='submit'></form>" ; let tab = gBrowser . addTab ( ) ; gObserver . notifyInvalidSubmit = function ( ) { executeSoon ( function ( ) { let doc = tab . linkedBrowser . contentDocument ; isnot ( doc . activeElement , doc . getElementById ( 'i' ) , "We should not focus the invalid element when the form is submitted in background" ) ; checkPopupHide ( ) ; Services . obs . removeObserver ( gObserver , "invalidformsubmit" ) ; gObserver . notifyInvalidSubmit = function ( ) { } ; gBrowser . removeTab ( tab ) ; executeSoon ( test9 ) ; } ) ; } ; Services . obs . addObserver ( gObserver , "invalidformsubmit" , false ) ; tab . linkedBrowser . addEventListener ( "load" , function ( aEvent ) { tab . linkedBrowser . removeEventListener ( "load" , arguments . callee , true ) ; isnot ( gBrowser . selectedTab , tab , "This tab should have been loaded in background" ) ; tab . linkedBrowser . contentDocument . getElementById ( 's' ) . click ( ) ; } , true ) ; tab . linkedBrowser . loadURI ( uri ) ; }
In this test, we check that nothing happen (no focus nor popup) if the
 invalid form is submitted in another tab than the current focused one
 (submitted in background).
In this test we check that nothing happen ( no focus nor popup ) if the invalid form is submitted in another tab than the current focused one ( submitted in background ) .
// Clean-up // Next test