1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/base/content/test/general/browser_bug595507.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,39 @@ 1.4 +var gInvalidFormPopup = document.getElementById('invalid-form-popup'); 1.5 +ok(gInvalidFormPopup, 1.6 + "The browser should have a popup to show when a form is invalid"); 1.7 + 1.8 +/** 1.9 + * Make sure that the form validation error message shows even if the form is in an iframe. 1.10 + */ 1.11 +function test() 1.12 +{ 1.13 + waitForExplicitFinish(); 1.14 + 1.15 + 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>"; 1.16 + let tab = gBrowser.addTab(); 1.17 + 1.18 + gInvalidFormPopup.addEventListener("popupshown", function() { 1.19 + gInvalidFormPopup.removeEventListener("popupshown", arguments.callee, false); 1.20 + 1.21 + let doc = gBrowser.contentDocument.getElementsByTagName('iframe')[0].contentDocument; 1.22 + is(doc.activeElement, doc.getElementById('i'), 1.23 + "First invalid element should be focused"); 1.24 + 1.25 + ok(gInvalidFormPopup.state == 'showing' || gInvalidFormPopup.state == 'open', 1.26 + "The invalid form popup should be shown"); 1.27 + 1.28 + // Clean-up and next test. 1.29 + gBrowser.removeTab(gBrowser.selectedTab, {animate: false}); 1.30 + executeSoon(finish); 1.31 + }, false); 1.32 + 1.33 + tab.linkedBrowser.addEventListener("load", function(aEvent) { 1.34 + tab.linkedBrowser.removeEventListener("load", arguments.callee, true); 1.35 + 1.36 + gBrowser.contentDocument.getElementsByTagName('iframe')[0].contentDocument 1.37 + .getElementById('s').click(); 1.38 + }, true); 1.39 + 1.40 + gBrowser.selectedTab = tab; 1.41 + gBrowser.selectedTab.linkedBrowser.loadURI(uri); 1.42 +}