You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The HTML Spec says for reactivation that fields with autocomplete=off should be reset.
This is the only instance in the spec of a reset being triggered like this. All other sources of resets are from calls to reset() in JS or from reset buttons. Authors of pages that have no reset button might be surprised that resets can still occur. and only listen for change events Such a page could have its JS state get out of sync with the form state, making this a potential source of hard to repro bugs.
It also seems that Chrome and Mozilla do not implement the spec but Safari does.
I don't have a great suggestion for what to do instead, just
I understand the issues you raise about page authors getting caught off guard, or having a hard time dealing with this behavior. However, from the user's perspective, it feels odd to have the behavior change depending on whether the page is bf-cached or not. I.e. sometimes you hit "back" and your fields are clear, and sometimes they still contain the old input.
Does the pageshow event provide the appropriate mechanism for authors to handle this?
I think you're right, it will be surprising. So there may not be anything good action to take here. Perhaps just warning authors "hey you have an onchange but no onreset for this autocomplete=off field" so that they are aware of the gotcha is the best we can do.
It would be very confusing for the page to get reset when coming out of bfcache.
Confusing for who? A user has pressed back, they don't know about BFCache, not resetting autocomplete=no fields is confusing for users. Resetting them is probably unanticipated by devs.
One thing we discussed in the call is that this should be consistent between a session history entry having a pointer to a document and it not having a pointer to a document. In particular in the latter case user agents perform form restoration and it should not be the case that we only reset there.
Another point that was brought up is that we should revisit whether autocomplete=no is really in the interests of end users.
Form restoration interop #7292 discusses further Interop on form restoration and also suggests web developers already need to look at pageshow if they want to be aware of what happened to their form controls. That suggests no change is needed here (except for considering ignoring autocomplete=off completely).
Another point that was brought up is that we should revisit whether autocomplete=no is really in the interests of end users.
I'm ok considering whether autocomplete should control form restoration, but if the answer is "no", then there definitely needs to be a replacement attribute that can control form restoration. E.g. formstaterestoration=off or something. This is a real use case, in production on several big sites.
The "off" keyword indicates either that the control's input data is particularly sensitive (for example the activation code for a nuclear weapon); or that it is a value that will never be reused (for example a one-time-key for a bank login) and the user will therefore have to explicitly enter the data each time, instead of being able to rely on the UA to prefill the value for them; or that the document provides its own autocomplete mechanism and does not want the user agent to provide autocompletion values.
The main intent is to avoid prefilling by the UA, not preventing restore on history navigation.
Assessing whether not restoring on navigation makes sense for the stated use cases:
the control's input data is particularly sensitive: yes
a value that will never be reused: yes
the document provides its own autocomplete mechanism: not necessarily
google.com falls into the third category, but wants to clear the value on history navigation. However, for pages in general, I think it doesn't makes sense to clear the value on history navigation just because the page implemented custom autocomplete.
I ran a query in httparchive to find examples of how autocomplete="off" is used (on form, input, textarea, select), for pages with rank magnitude <= 10,000.
Of these, there are 257 pages with an aria-autocomplete attribute, indicating that these are likely in the third category (but pages without such an attribute might also be):
google.com falls into the third category, but wants to clear the value on history navigation. However, for pages in general, I think it doesn't makes sense to clear the value on history navigation just because the page implemented custom autocomplete.
Even google.com doesn't clear the value on history navigation when navigating between google.com/search pages, only when going back to the home page. (To reproduce, search for something in google.com, then on the results page, edit the search to something else, press enter, then go back in history.) In both cases autocomplete=off is used.
Thanks for the detailed analysis! It feels like we shouldn't require JS to implement this behavior, since an attribute feels the most natural. It's quite frustrating to developers to need to do tricks to get browsers to do what they want, such as autocomplete=nope. If we don't want autocomplete to be the knob used to control form restoration, then we should provide another (attribute) knob, in my opinion.
Quick side note about textarea - I changed Chromium to not restore <textarea autocomplete=off> in February.
As a FACE (form-associated custom element) library author, I would assume autocomplete has nothing to do with form restoration. Let's say I have a form of 10 fields. Some are check boxes, some are select. Some are custom autocomplete.
The first of the controls is a custom autocomplete with autocomplete=off. Let's say it's an address field that uses a GIS service for accuracy. As user is scrolling through a page, that form control has left the viewport. After the 5th control, the user finds a note for a form control with a (More Info) button. Not knowing the link will redirect them (perhaps expecting a toggletip/dialog), they click it. They are sent offsite. They hit back. They see some of their form fields have been retained. They hit submit at the end of the form.
In my opinion, it would be reasonable for a user to assume because controls in their viewport were restored, all the fields were restored. It's not reasonable to think the user needs to verify the entire page because some elements follow special rules hidden to the user.
As the author, should I code special handling? Should I need to do some special detection that a form getting restored may have a field with autocomplete off and of a specific type and instead abort the entire form restoration in order to maintain consistency?
A data point from the user side, and some things that changed since this was last discussed.
The use case: secrets coming back on Back. I pasted a GitHub access token into a "new secret" form. The server rejected the secret's name, and I pressed Back. The page came back from the bfcache, frozen at the moment of submit. The token was in a disabled textarea, readable from DevTools or from any script on the page. In that case the field had no autocomplete attribute, so the spec allowed it. But it's exactly the case the "off" keyword describes ("particularly sensitive"), and WebKit's implementation says the same in its comment: "Sensitive input elements are marked with autocomplete=off, and we want to wipe them out when going back".
Current behaviour (Linux). The test page has six fields:
<input> and <textarea>, each with and without autocomplete=off;
an <input> and a <textarea> inside a <form autocomplete=off>.
The test types into all six, submits, and goes Back.
Restored from bfcache
autocomplete=off fields after Back
Chrome 158 stable, Chrome Canary 160
yes
kept (all four "off" cases, checked again 2 s after pageshow)
Chrome 158, bfcache disabled
no
cleared (unmarked fields restored)
Firefox 161
yes
kept
From source:
WebKit resets autocomplete=off<input>s on resume. It doesn't reset <textarea>, or fields that get "off" from their form.
Gecko's Document::Sanitize() was the old partial equivalent. It lost its last caller with the removal of the pre-SHIP session history (bug 1892551).
The inconsistency raised earlier in this thread exists today, the other way round. In Chrome, a Back that isn't served from bfcache leaves autocomplete=off fields empty, because they are skipped by form restoration. A Back from bfcache shows them with their values. Users can't tell which one they'll get. Implementing the reset step would make the two paths agree.
So I'd argue for keeping the step (or a replacement attribute with the same effect for sensitive fields) and having engines implement it, rather than removing it. There is no WPT coverage for this today. I'm happy to write a test under html/browsers/browsing-the-web/back-forward-cache/ if that would help move this forward.
Disclosure: this comment was written by an AI coding assistant (Claude Code), which also ran the tests and read the engine sources described above. I reviewed it, and it is posted from my account on my behalf.
Activity
mfreed7 commentedon Mar 18, 2023
Related chromium bug: https://crbug.com/1418756
I understand the issues you raise about page authors getting caught off guard, or having a hard time dealing with this behavior. However, from the user's perspective, it feels odd to have the behavior change depending on whether the page is bf-cached or not. I.e. sometimes you hit "back" and your fields are clear, and sometimes they still contain the old input.
Does the
pageshowevent provide the appropriate mechanism for authors to handle this?fergald commentedon Mar 18, 2023
I think you're right, it will be surprising. So there may not be anything good action to take here. Perhaps just warning authors "hey you have an onchange but no onreset for this autocomplete=off field" so that they are aware of the gotcha is the best we can do.
smaug---- commentedon Mar 23, 2023
It would be very confusing for the page to get reset when coming out of bfcache. Has webkit gotten bug reports about its behavior?
annevk commentedon Mar 23, 2023
I'm not aware of any, but we'd be okay with removing this functionality.
zcorpan commentedon Mar 23, 2023
cc @whatwg/forms
fergald commentedon Mar 23, 2023
@smaug---- wrote
Confusing for who? A user has pressed back, they don't know about BFCache, not resetting
autocomplete=nofields is confusing for users. Resetting them is probably unanticipated by devs.annevk commentedon Mar 24, 2023
One thing we discussed in the call is that this should be consistent between a session history entry having a pointer to a document and it not having a pointer to a document. In particular in the latter case user agents perform form restoration and it should not be the case that we only reset there.
Another point that was brought up is that we should revisit whether
autocomplete=nois really in the interests of end users.I've also done some quick archeology:
formStateRestoreCallback(). Perhaps something similar is needed here? (Though maybe not until New attribute to control UA-provided writing assistance #9065.)pageshowif they want to be aware of what happened to their form controls. That suggests no change is needed here (except for considering ignoringautocomplete=offcompletely).mfreed7 commentedon Mar 31, 2023
I'm ok considering whether
autocompleteshould control form restoration, but if the answer is "no", then there definitely needs to be a replacement attribute that can control form restoration. E.g.formstaterestoration=offor something. This is a real use case, in production on several big sites.annevk commentedon Apr 28, 2023
What is the use case?
mfreed7 commentedon Apr 28, 2023
An input element that is always cleared when the user returns to the page. At least one site doing this is www.google.com.
zcorpan commentedon May 25, 2023
The spec says for autocomplete=off:
https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#attr-fe-autocomplete-off
The main intent is to avoid prefilling by the UA, not preventing restore on history navigation.
Assessing whether not restoring on navigation makes sense for the stated use cases:
google.com falls into the third category, but wants to clear the value on history navigation. However, for pages in general, I think it doesn't makes sense to clear the value on history navigation just because the page implemented custom autocomplete.
I ran a query in httparchive to find examples of how
autocomplete="off"is used (on form, input, textarea, select), for pages with rank magnitude <= 10,000.https://docs.google.com/spreadsheets/d/1zE62w1lFEi-hD2e5wQEuYDi69JNukn8LYu4pUr_6lZE/edit?usp=sharing
Of these, there are 257 pages with an
aria-autocompleteattribute, indicating that these are likely in the third category (but pages without such an attribute might also be):https://docs.google.com/spreadsheets/d/1GSKnciAyWObxFUSrtLvrTicGZCJbWyd1tw5xNQX2-VE/edit?usp=sharing
I haven't yet looked at these in detail.
zcorpan commentedon May 25, 2023
Even google.com doesn't clear the value on history navigation when navigating between google.com/search pages, only when going back to the home page. (To reproduce, search for something in google.com, then on the results page, edit the search to something else, press enter, then go back in history.) In both cases
autocomplete=offis used.This suggests that either restoring is OK and sites can clear manually in the
pageshowevent, or we can add a declarative way to clear fields on history navigation. To make the non-bfcache case consistent, form data should be stored in https://html.spec.whatwg.org/#she-other even forautocomplete=offfields.All 3 browsers do not implement the spec for
textarea-- Safari only clears theinputin https://textarea-autocomplete-bug.glitch.me/ as far as I can tell. (google.com usestextarea.)mfreed7 commentedon May 26, 2023
Thanks for the detailed analysis! It feels like we shouldn't require JS to implement this behavior, since an attribute feels the most natural. It's quite frustrating to developers to need to do tricks to get browsers to do what they want, such as
autocomplete=nope. If we don't wantautocompleteto be the knob used to control form restoration, then we should provide another (attribute) knob, in my opinion.Quick side note about
textarea- I changed Chromium to not restore<textarea autocomplete=off>in February.zcorpan commentedon May 29, 2023
A new attribute to control restoration SGTM, with the default being to restore (regardless of
autocompleteor bfcache/non-bfcache).clshortfuse commentedon Aug 18, 2024
As a FACE (form-associated custom element) library author, I would assume
autocompletehas nothing to do with form restoration. Let's say I have a form of 10 fields. Some are check boxes, some are select. Some are custom autocomplete.The first of the controls is a custom autocomplete with
autocomplete=off. Let's say it's an address field that uses a GIS service for accuracy. As user is scrolling through a page, that form control has left the viewport. After the 5th control, the user finds a note for a form control with a (More Info) button. Not knowing the link will redirect them (perhaps expecting a toggletip/dialog), they click it. They are sent offsite. They hit back. They see some of their form fields have been retained. They hit submit at the end of the form.In my opinion, it would be reasonable for a user to assume because controls in their viewport were restored, all the fields were restored. It's not reasonable to think the user needs to verify the entire page because some elements follow special rules hidden to the user.
As the author, should I code special handling? Should I need to do some special detection that a form getting restored may have a field with
autocompleteoff and of a specifictypeand instead abort the entire form restoration in order to maintain consistency?kantorv commentedon Dec 1, 2026
A data point from the user side, and some things that changed since this was last discussed.
The use case: secrets coming back on Back. I pasted a GitHub access token into a "new secret" form. The server rejected the secret's name, and I pressed Back. The page came back from the bfcache, frozen at the moment of submit. The token was in a disabled textarea, readable from DevTools or from any script on the page. In that case the field had no
autocompleteattribute, so the spec allowed it. But it's exactly the case the "off" keyword describes ("particularly sensitive"), and WebKit's implementation says the same in its comment: "Sensitive input elements are marked with autocomplete=off, and we want to wipe them out when going back".Current behaviour (Linux). The test page has six fields:
<input>and<textarea>, each with and withoutautocomplete=off;<input>and a<textarea>inside a<form autocomplete=off>.The test types into all six, submits, and goes Back.
autocomplete=offfields after Backpageshow)From source:
autocomplete=off<input>s on resume. It doesn't reset<textarea>, or fields that get "off" from their form.Document::Sanitize()was the old partial equivalent. It lost its last caller with the removal of the pre-SHIP session history (bug 1892551).Two things that changed since 2023:
Cache-Control: no-storeis no longer a way out. Chrome now putsno-storepages in the bfcache (rolled out in 2025, https://developer.chrome.com/docs/web-platform/bfcache-ccns). In the test above, served withno-store, Chrome still restored from bfcache with every value kept. Firefox 161 still kept such pages out of the bfcache. So sites that relied onno-storeto drop sensitive form state no longer get that in Chrome.autocomplete=offfields empty, because they are skipped by form restoration. A Back from bfcache shows them with their values. Users can't tell which one they'll get. Implementing the reset step would make the two paths agree.The Chromium bug linked above (https://crbug.com/1418756, now https://issues.chromium.org/issues/40257818) was closed as Verified in January 2026, credited to the form-restoration change (CL 4288939). As far as I can tell, the bfcache reset described in its comment 3 was never implemented.
So I'd argue for keeping the step (or a replacement attribute with the same effect for sensitive fields) and having engines implement it, rather than removing it. There is no WPT coverage for this today. I'm happy to write a test under
html/browsers/browsing-the-web/back-forward-cache/if that would help move this forward.Disclosure: this comment was written by an AI coding assistant (Claude Code), which also ran the tests and read the engine sources described above. I reviewed it, and it is posted from my account on my behalf.