|
1 var gInvalidFormPopup = document.getElementById('invalid-form-popup'); |
|
2 ok(gInvalidFormPopup, |
|
3 "The browser should have a popup to show when a form is invalid"); |
|
4 |
|
5 /** |
|
6 * Make sure that the form validation error message shows even if the form is in an iframe. |
|
7 */ |
|
8 function test() |
|
9 { |
|
10 waitForExplicitFinish(); |
|
11 |
|
12 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>"; |
|
13 let tab = gBrowser.addTab(); |
|
14 |
|
15 gInvalidFormPopup.addEventListener("popupshown", function() { |
|
16 gInvalidFormPopup.removeEventListener("popupshown", arguments.callee, false); |
|
17 |
|
18 let doc = gBrowser.contentDocument.getElementsByTagName('iframe')[0].contentDocument; |
|
19 is(doc.activeElement, doc.getElementById('i'), |
|
20 "First invalid element should be focused"); |
|
21 |
|
22 ok(gInvalidFormPopup.state == 'showing' || gInvalidFormPopup.state == 'open', |
|
23 "The invalid form popup should be shown"); |
|
24 |
|
25 // Clean-up and next test. |
|
26 gBrowser.removeTab(gBrowser.selectedTab, {animate: false}); |
|
27 executeSoon(finish); |
|
28 }, false); |
|
29 |
|
30 tab.linkedBrowser.addEventListener("load", function(aEvent) { |
|
31 tab.linkedBrowser.removeEventListener("load", arguments.callee, true); |
|
32 |
|
33 gBrowser.contentDocument.getElementsByTagName('iframe')[0].contentDocument |
|
34 .getElementById('s').click(); |
|
35 }, true); |
|
36 |
|
37 gBrowser.selectedTab = tab; |
|
38 gBrowser.selectedTab.linkedBrowser.loadURI(uri); |
|
39 } |