B2G/gecko/browser/base/content/test/browser_bug595507.js
/**
 * Make sure that the form validation error message shows even if the form is in an iframe.
 */
Make sure that the form validation error message shows even if the form is in an iframe.
Make sure that the form validation error message shows even if the form is in an iframe .
function test()
{
  waitForExplicitFinish();
  let uri = "data:text/html,<iframe src=\"data:text/html,<iframe name='t'></iframe><form target='t' action='data:text/html,'><input required id='i'><input id='s' type='submit'></form>\"</iframe>";
  let tab = gBrowser.addTab();
  gInvalidFormPopup.addEventListener("popupshown", function() {
    gInvalidFormPopup.removeEventListener("popupshown", arguments.callee, false);
    let doc = gBrowser.contentDocument.getElementsByTagName('iframe')[0].contentDocument;
    is(doc.activeElement, doc.getElementById('i'),
       "First invalid element should be focused");
    ok(gInvalidFormPopup.state == 'showing' || gInvalidFormPopup.state == 'open',
       "The invalid form popup should be shown");
    gBrowser.removeTab(gBrowser.selectedTab, {animate: false});
    executeSoon(finish);
  }, false);
  tab.linkedBrowser.addEventListener("load", function(aEvent) {
    tab.linkedBrowser.removeEventListener("load", arguments.callee, true);
    gBrowser.contentDocument.getElementsByTagName('iframe')[0].contentDocument
      .getElementById('s').click();
  }, true);
  gBrowser.selectedTab = tab;
  gBrowser.selectedTab.linkedBrowser.loadURI(uri);
}
function test ( ) { waitForExplicitFinish ( ) ; let uri = "data:text/html,<iframe src=\"data:text/html,<iframe name='t'></iframe><form target='t' action='data:text/html,'><input required id='i'><input id='s' type='submit'></form>\"</iframe>" ; let tab = gBrowser . addTab ( ) ; gInvalidFormPopup . addEventListener ( "popupshown" , function ( ) { gInvalidFormPopup . removeEventListener ( "popupshown" , arguments . callee , false ) ; let doc = gBrowser . contentDocument . getElementsByTagName ( 'iframe' ) [ 0 ] . contentDocument ; is ( doc . activeElement , doc . getElementById ( 'i' ) , "First invalid element should be focused" ) ; ok ( gInvalidFormPopup . state == 'showing' || gInvalidFormPopup . state == 'open' , "The invalid form popup should be shown" ) ; gBrowser . removeTab ( gBrowser . selectedTab , { animate : false } ) ; executeSoon ( finish ) ; } , false ) ; tab . linkedBrowser . addEventListener ( "load" , function ( aEvent ) { tab . linkedBrowser . removeEventListener ( "load" , arguments . callee , true ) ; gBrowser . contentDocument . getElementsByTagName ( 'iframe' ) [ 0 ] . contentDocument . getElementById ( 's' ) . click ( ) ; } , true ) ; gBrowser . selectedTab = tab ; gBrowser . selectedTab . linkedBrowser . loadURI ( uri ) ; }
Make sure that the form validation error message shows even if the form is in an iframe.
Make sure that the form validation error message shows even if the form is in an iframe .
// Clean-up and next test.