Loading browser/actors/FormValidationChild.jsm +0 −4 Original line number Diff line number Diff line Loading @@ -51,10 +51,6 @@ class FormValidationChild extends JSWindowActorChild { } } /* * nsIFormSubmitObserver */ notifyInvalidSubmit(aFormElement, aInvalidElements) { // Show a validation message on the first focusable element. for (let element of aInvalidElements) { Loading browser/modules/test/browser/formValidation/browser_form_validation.js +0 −53 Original line number Diff line number Diff line Loading @@ -68,12 +68,6 @@ function checkPopupHide() { ); } var gObserver = { QueryInterface: ChromeUtils.generateQI(["nsIFormSubmitObserver"]), notifyInvalidSubmit(aFormElement, aInvalidElements) {}, }; var testId = 0; function incrementTest() { Loading Loading @@ -440,53 +434,6 @@ add_task(async function() { gBrowser.removeCurrentTab(); }); /** * In this test, we check that nothing happen if the invalid form is * submitted in a background tab. */ add_task(async function() { // Observers don't propagate currently across processes. We may add support for this in the // future via the addon compat layer. if (gMultiProcessBrowser) { return; } incrementTest(); let uri = getDocHeader() + "<form target='t' action='data:text/html,'><input id='i' required><input id='s' type='submit'></form>" + getDocFooter(); let browser = await openNewTab(uri, true); isnot( gBrowser.selectedBrowser, browser, "This tab should have been loaded in background" ); let notifierPromise = new Promise((resolve, reject) => { gObserver.notifyInvalidSubmit = function() { executeSoon(function() { checkPopupHide(); // Clean-up Services.obs.removeObserver(gObserver, "invalidformsubmit"); gObserver.notifyInvalidSubmit = function() {}; resolve(); }); }; Services.obs.addObserver(gObserver, "invalidformsubmit"); executeSoon(function() { browser.contentDocument.getElementById("s").click(); }); }); await notifierPromise; gBrowser.removeTab(gBrowser.getTabForBrowser(browser)); }); /** * In this test, we check that the message is correctly updated when it changes. */ Loading dom/html/HTMLFormElement.cpp +7 −50 Original line number Diff line number Diff line Loading @@ -51,8 +51,6 @@ #include "mozilla/StaticPrefs_dom.h" #include "mozilla/StaticPrefs_prompts.h" #include "mozilla/StaticPrefs_signon.h" #include "nsIFormSubmitObserver.h" #include "nsIObserverService.h" #include "nsCategoryManagerUtils.h" #include "nsIContentInlines.h" #include "nsISimpleEnumerator.h" Loading Loading @@ -1876,27 +1874,18 @@ bool HTMLFormElement::CheckValidFormSubmission() { * invalid controls in the form. * This should not be done if the form has been submitted with .submit(). * * NOTE: for the moment, we are also checking that there is an observer for * NS_INVALIDFORMSUBMIT_SUBJECT so it will prevent blocking form submission * if the browser does not have implemented a UI yet. * NOTE: for the moment, we are also checking that whether the MozInvalidForm * event gets prevented default so it will prevent blocking form submission if * the browser does not have implemented a UI yet. * * TODO: the check for observer should be removed later when HTML5 Forms will * be spread enough and authors will assume forms can't be submitted when * invalid. See bug 587671. * TODO: the check for MozInvalidForm event should be removed later when HTML5 * Forms will be spread enough and authors will assume forms can't be * submitted when invalid. See bug 587671. */ NS_ASSERTION(!HasAttr(kNameSpaceID_None, nsGkAtoms::novalidate), "We shouldn't be there if novalidate is set!"); // When .submit() is called aEvent = nullptr so we can rely on that to know if // we have to check the validity of the form. nsCOMPtr<nsIObserverService> service = mozilla::services::GetObserverService(); if (!service) { NS_WARNING("No observer service available!"); return true; } AutoTArray<RefPtr<Element>, 32> invalidElements; if (CheckFormValidity(&invalidElements)) { return true; Loading Loading @@ -1962,39 +1951,7 @@ bool HTMLFormElement::CheckValidFormSubmission() { DispatchEvent(*event); bool result = !event->DefaultPrevented(); nsCOMPtr<nsISimpleEnumerator> theEnum; nsresult rv = service->EnumerateObservers(NS_INVALIDFORMSUBMIT_SUBJECT, getter_AddRefs(theEnum)); NS_ENSURE_SUCCESS(rv, result); bool hasObserver = false; rv = theEnum->HasMoreElements(&hasObserver); if (NS_SUCCEEDED(rv) && hasObserver) { result = false; nsCOMPtr<nsISupports> inst; nsCOMPtr<nsIFormSubmitObserver> observer; bool more = true; while (NS_SUCCEEDED(theEnum->HasMoreElements(&more)) && more) { theEnum->GetNext(getter_AddRefs(inst)); observer = do_QueryInterface(inst); if (observer) { observer->NotifyInvalidSubmit(this, invalidElements); } } } if (result) { NS_WARNING( "There is no observer for \"invalidformsubmit\". \ One should be implemented!"); } return result; return !event->DefaultPrevented(); } void HTMLFormElement::UpdateValidity(bool aElementValidity) { Loading dom/html/moz.build +0 −1 Original line number Diff line number Diff line Loading @@ -24,7 +24,6 @@ MOCHITEST_CHROME_MANIFESTS += [ BROWSER_CHROME_MANIFESTS += ["test/browser.ini"] XPIDL_SOURCES += [ "nsIFormSubmitObserver.idl", "nsIMenuBuilder.idl", ] Loading dom/html/nsIConstraintValidation.cpp +0 −33 Original line number Diff line number Diff line Loading @@ -16,9 +16,6 @@ #include "nsISimpleEnumerator.h" #include "nsContentUtils.h" #include "nsIFormSubmitObserver.h" #include "nsIObserverService.h" const uint16_t nsIConstraintValidation::sContentSpecifiedMaxLengthMessage = 256; using namespace mozilla; Loading Loading @@ -87,36 +84,6 @@ bool nsIConstraintValidation::ReportValidity() { element->DispatchEvent(*event); nsCOMPtr<nsIObserverService> service = mozilla::services::GetObserverService(); if (!service) { NS_WARNING("No observer service available!"); return true; } nsCOMPtr<nsISimpleEnumerator> theEnum; nsresult rv = service->EnumerateObservers(NS_INVALIDFORMSUBMIT_SUBJECT, getter_AddRefs(theEnum)); // Return true on error here because that's what we always did NS_ENSURE_SUCCESS(rv, true); bool hasObserver = false; rv = theEnum->HasMoreElements(&hasObserver); NS_ENSURE_SUCCESS(rv, true); nsCOMPtr<nsISupports> inst; nsCOMPtr<nsIFormSubmitObserver> observer; bool more = true; while (NS_SUCCEEDED(theEnum->HasMoreElements(&more)) && more) { theEnum->GetNext(getter_AddRefs(inst)); observer = do_QueryInterface(inst); if (observer) { observer->NotifyInvalidSubmit(nullptr, invalidElements); } } auto* inputElement = HTMLInputElement::FromNode(element); if (inputElement && inputElement->State().HasState(NS_EVENT_STATE_FOCUS)) { inputElement->UpdateValidityUIBits(true); Loading Loading
browser/actors/FormValidationChild.jsm +0 −4 Original line number Diff line number Diff line Loading @@ -51,10 +51,6 @@ class FormValidationChild extends JSWindowActorChild { } } /* * nsIFormSubmitObserver */ notifyInvalidSubmit(aFormElement, aInvalidElements) { // Show a validation message on the first focusable element. for (let element of aInvalidElements) { Loading
browser/modules/test/browser/formValidation/browser_form_validation.js +0 −53 Original line number Diff line number Diff line Loading @@ -68,12 +68,6 @@ function checkPopupHide() { ); } var gObserver = { QueryInterface: ChromeUtils.generateQI(["nsIFormSubmitObserver"]), notifyInvalidSubmit(aFormElement, aInvalidElements) {}, }; var testId = 0; function incrementTest() { Loading Loading @@ -440,53 +434,6 @@ add_task(async function() { gBrowser.removeCurrentTab(); }); /** * In this test, we check that nothing happen if the invalid form is * submitted in a background tab. */ add_task(async function() { // Observers don't propagate currently across processes. We may add support for this in the // future via the addon compat layer. if (gMultiProcessBrowser) { return; } incrementTest(); let uri = getDocHeader() + "<form target='t' action='data:text/html,'><input id='i' required><input id='s' type='submit'></form>" + getDocFooter(); let browser = await openNewTab(uri, true); isnot( gBrowser.selectedBrowser, browser, "This tab should have been loaded in background" ); let notifierPromise = new Promise((resolve, reject) => { gObserver.notifyInvalidSubmit = function() { executeSoon(function() { checkPopupHide(); // Clean-up Services.obs.removeObserver(gObserver, "invalidformsubmit"); gObserver.notifyInvalidSubmit = function() {}; resolve(); }); }; Services.obs.addObserver(gObserver, "invalidformsubmit"); executeSoon(function() { browser.contentDocument.getElementById("s").click(); }); }); await notifierPromise; gBrowser.removeTab(gBrowser.getTabForBrowser(browser)); }); /** * In this test, we check that the message is correctly updated when it changes. */ Loading
dom/html/HTMLFormElement.cpp +7 −50 Original line number Diff line number Diff line Loading @@ -51,8 +51,6 @@ #include "mozilla/StaticPrefs_dom.h" #include "mozilla/StaticPrefs_prompts.h" #include "mozilla/StaticPrefs_signon.h" #include "nsIFormSubmitObserver.h" #include "nsIObserverService.h" #include "nsCategoryManagerUtils.h" #include "nsIContentInlines.h" #include "nsISimpleEnumerator.h" Loading Loading @@ -1876,27 +1874,18 @@ bool HTMLFormElement::CheckValidFormSubmission() { * invalid controls in the form. * This should not be done if the form has been submitted with .submit(). * * NOTE: for the moment, we are also checking that there is an observer for * NS_INVALIDFORMSUBMIT_SUBJECT so it will prevent blocking form submission * if the browser does not have implemented a UI yet. * NOTE: for the moment, we are also checking that whether the MozInvalidForm * event gets prevented default so it will prevent blocking form submission if * the browser does not have implemented a UI yet. * * TODO: the check for observer should be removed later when HTML5 Forms will * be spread enough and authors will assume forms can't be submitted when * invalid. See bug 587671. * TODO: the check for MozInvalidForm event should be removed later when HTML5 * Forms will be spread enough and authors will assume forms can't be * submitted when invalid. See bug 587671. */ NS_ASSERTION(!HasAttr(kNameSpaceID_None, nsGkAtoms::novalidate), "We shouldn't be there if novalidate is set!"); // When .submit() is called aEvent = nullptr so we can rely on that to know if // we have to check the validity of the form. nsCOMPtr<nsIObserverService> service = mozilla::services::GetObserverService(); if (!service) { NS_WARNING("No observer service available!"); return true; } AutoTArray<RefPtr<Element>, 32> invalidElements; if (CheckFormValidity(&invalidElements)) { return true; Loading Loading @@ -1962,39 +1951,7 @@ bool HTMLFormElement::CheckValidFormSubmission() { DispatchEvent(*event); bool result = !event->DefaultPrevented(); nsCOMPtr<nsISimpleEnumerator> theEnum; nsresult rv = service->EnumerateObservers(NS_INVALIDFORMSUBMIT_SUBJECT, getter_AddRefs(theEnum)); NS_ENSURE_SUCCESS(rv, result); bool hasObserver = false; rv = theEnum->HasMoreElements(&hasObserver); if (NS_SUCCEEDED(rv) && hasObserver) { result = false; nsCOMPtr<nsISupports> inst; nsCOMPtr<nsIFormSubmitObserver> observer; bool more = true; while (NS_SUCCEEDED(theEnum->HasMoreElements(&more)) && more) { theEnum->GetNext(getter_AddRefs(inst)); observer = do_QueryInterface(inst); if (observer) { observer->NotifyInvalidSubmit(this, invalidElements); } } } if (result) { NS_WARNING( "There is no observer for \"invalidformsubmit\". \ One should be implemented!"); } return result; return !event->DefaultPrevented(); } void HTMLFormElement::UpdateValidity(bool aElementValidity) { Loading
dom/html/moz.build +0 −1 Original line number Diff line number Diff line Loading @@ -24,7 +24,6 @@ MOCHITEST_CHROME_MANIFESTS += [ BROWSER_CHROME_MANIFESTS += ["test/browser.ini"] XPIDL_SOURCES += [ "nsIFormSubmitObserver.idl", "nsIMenuBuilder.idl", ] Loading
dom/html/nsIConstraintValidation.cpp +0 −33 Original line number Diff line number Diff line Loading @@ -16,9 +16,6 @@ #include "nsISimpleEnumerator.h" #include "nsContentUtils.h" #include "nsIFormSubmitObserver.h" #include "nsIObserverService.h" const uint16_t nsIConstraintValidation::sContentSpecifiedMaxLengthMessage = 256; using namespace mozilla; Loading Loading @@ -87,36 +84,6 @@ bool nsIConstraintValidation::ReportValidity() { element->DispatchEvent(*event); nsCOMPtr<nsIObserverService> service = mozilla::services::GetObserverService(); if (!service) { NS_WARNING("No observer service available!"); return true; } nsCOMPtr<nsISimpleEnumerator> theEnum; nsresult rv = service->EnumerateObservers(NS_INVALIDFORMSUBMIT_SUBJECT, getter_AddRefs(theEnum)); // Return true on error here because that's what we always did NS_ENSURE_SUCCESS(rv, true); bool hasObserver = false; rv = theEnum->HasMoreElements(&hasObserver); NS_ENSURE_SUCCESS(rv, true); nsCOMPtr<nsISupports> inst; nsCOMPtr<nsIFormSubmitObserver> observer; bool more = true; while (NS_SUCCEEDED(theEnum->HasMoreElements(&more)) && more) { theEnum->GetNext(getter_AddRefs(inst)); observer = do_QueryInterface(inst); if (observer) { observer->NotifyInvalidSubmit(nullptr, invalidElements); } } auto* inputElement = HTMLInputElement::FromNode(element); if (inputElement && inputElement->State().HasState(NS_EVENT_STATE_FOCUS)) { inputElement->UpdateValidityUIBits(true); Loading