Closed Bug 947262 Opened 8 years ago Closed 8 years ago

Don't dispatch a change event when trying to restore an invalid <select> value

Categories

(Firefox :: Session Restore, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
Firefox 29

People

(Reporter: ttaubert, Assigned: ttaubert)

References

Details

Attachments

(1 file)

DocumentUtils.restoreFormValue() fires a change event when trying to restore the value of a <select> field even if it doesn't find a matching <option> element. No event should be fired when we end up with the default value selected.

I discovered this while working on bug 947212. That will also fix a test that in turn relies on this fix here.
Comment on attachment 8343771 [details] [diff] [review]
0001-Bug-947262-Don-t-dispatch-a-change-event-when-trying.patch

Review of attachment 8343771 [details] [diff] [review]:
-----------------------------------------------------------------

Just one change I'd make, but r+ either way.

::: browser/components/sessionstore/src/DocumentUtils.jsm
@@ +203,4 @@
>        for (let i = 0; i < aNode.options.length; i++) {
>          if (aNode.options[i].value == aValue.value) {
>            aNode.selectedIndex = i;
> +          shouldFireEvent = true;

I think I'd prefer to just set the eventType here instead of introducing a flag variable, but I don't feel too strongly about it.
Attachment #8343771 - Flags: review?(smacleod) → review+
(In reply to Steven MacLeod [:smacleod] from comment #2)
> I think I'd prefer to just set the eventType here instead of introducing a
> flag variable, but I don't feel too strongly about it.

Yeah, that's a great idea. I should have thought of that, thanks :)
https://hg.mozilla.org/mozilla-central/rev/b88706b9f724
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 29
Flags: in-testsuite?
You need to log in before you can comment on or make changes to this bug.