| OLD | NEW |
| (Empty) |
| 1 <!DOCTYPE html> | |
| 2 <html> | |
| 3 <head> | |
| 4 <script src="../../../resources/js-test.js"></script> | |
| 5 <script src="../../forms/resources/common.js"></script> | |
| 6 <script> | |
| 7 description('Tests autofocus is run every time a dialog is opened.'); | |
| 8 | |
| 9 function test() { | |
| 10 shouldBe('document.activeElement', 'document.getElementById("outer-button")'
); | |
| 11 | |
| 12 var focusCount = 0; | |
| 13 input2.onfocus = function() { focusCount += 1 }; | |
| 14 | |
| 15 var expectedFocusCount = 3; | |
| 16 for (i = 0; i < expectedFocusCount; i++) { | |
| 17 dlg.show(); | |
| 18 shouldBe('document.activeElement', 'document.getElementById("input2")'); | |
| 19 input1.focus(); | |
| 20 shouldBe('document.activeElement', 'document.getElementById("input1")'); | |
| 21 dlg.close(); | |
| 22 } | |
| 23 | |
| 24 shouldBe(focusCount.toString(), expectedFocusCount.toString()); | |
| 25 | |
| 26 finishJSTest(); | |
| 27 } | |
| 28 | |
| 29 jsTestIsAsync = true; | |
| 30 waitUntilLoadedAndAutofocused(test); | |
| 31 </script> | |
| 32 </head> | |
| 33 <body> | |
| 34 <button id="outer-button" autofocus></button> | |
| 35 <dialog id="dlg"> | |
| 36 <!-- Unfocusable elements with [autofocus] should be ignored. --> | |
| 37 <input autofocus disabled> | |
| 38 <textarea autofocus hidden></textarea> | |
| 39 <input id="input1"></input> | |
| 40 <input id="input2" autofocus></input> | |
| 41 </dialog> | |
| 42 </body> | |
| 43 </html> | |
| OLD | NEW |