"use strict"; // Form submissions triggered by the Javascript 'submit' event listener are // deferred until the event listener finishes. However, changes to specific // attributes ("action" and "target" attributes) need to cause an immediate // flush of any pending submission to prevent the form submission from using the // wrong action or target. This test ensures that such flushes happen properly. const kTestPage = "https://example.org/browser/dom/html/test/submission_flush.html"; // This is the page pointed to by the form action in the test HTML page. const kPostActionPage = "https://example.org/browser/dom/html/test/post_action_page.html"; const kFormId = "test_form"; const kFrameId = "test_frame"; const kSubmitButtonId = "submit_button"; // Take in a variety of actions (in the form of setting and unsetting form // attributes). Then submit the form in the submit event listener to cause a // deferred form submission. Then perform the test actions and ensure that the // form used the correct attribute values rather than the changed ones. async function runTest(aTestActions) { let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, kTestPage); registerCleanupFunction(() => BrowserTestUtils.removeTab(tab)); /* eslint-disable no-shadow */ let frame_url = await SpecialPowers.spawn( gBrowser.selectedBrowser, [{ kFormId, kFrameId, kSubmitButtonId, aTestActions }], async function ({ kFormId, kFrameId, kSubmitButtonId, aTestActions }) { let form = content.document.getElementById(kFormId); form.addEventListener( "submit", event => { // Need to trigger the deferred submission by submitting in the submit // event handler. To prevent the form from being submitted twice, the //