зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1652699 - Fix a null pointer crash while doing dialog form submission r=smaug
It's possible that the dialog is closed while we are processing the request, and we'd deferencing a null pointer for such case. Differential Revision: https://phabricator.services.mozilla.com/D83531
This commit is contained in:
Родитель
8695ba2c43
Коммит
9cb69ecf75
|
@ -830,7 +830,7 @@ nsresult HTMLFormSubmission::GetFromForm(HTMLFormElement* aForm,
|
|||
// If there isn't one, or if it does not have an open attribute, do
|
||||
// nothing.
|
||||
if (!dialog || !dialog->Open()) {
|
||||
return NS_OK;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsAutoString result;
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
<body>
|
||||
<dialog id="favDialog">
|
||||
<form method="dialog">
|
||||
<form id="dialogForm" method="dialog">
|
||||
<button id="confirmBtn" value="default">Confirm</button>
|
||||
<input id="confirmImgBtn" src="./resources/submit.jpg" width="41"
|
||||
height="41" type="image" alt="Hello">
|
||||
|
@ -78,5 +78,25 @@ promise_test(async () => {
|
|||
assert_false(dialog.open, "dialog should be closed now");
|
||||
}, "formmethod attribute should use dialog form submission");
|
||||
|
||||
promise_test(async () => {
|
||||
const dialog = document.querySelector('dialog');
|
||||
dialog.returnValue = "";
|
||||
dialog.showModal();
|
||||
|
||||
const button = document.querySelector('button');
|
||||
button.value = "sushi";
|
||||
|
||||
const dialogForm = document.getElementById('dialogForm');
|
||||
dialogForm.onsubmit = function() {
|
||||
dialog.close();
|
||||
}
|
||||
|
||||
button.click();
|
||||
assert_false(dialog.open, "dialog should be closed now");
|
||||
// If the submission request got processed, the returnValue should change
|
||||
// to "sushi" because that's the value of the submitter
|
||||
assert_equals(dialog.returnValue, "", "dialog's returnValue remains the same");
|
||||
}, "closing the dialog while submitting should stop the submission");
|
||||
|
||||
</script>
|
||||
</body>
|
||||
|
|
Загрузка…
Ссылка в новой задаче