diff --git a/dom/base/nsDOMWindowUtils.cpp b/dom/base/nsDOMWindowUtils.cpp
index 6d611b4a8485..b2cc65940a8c 100644
--- a/dom/base/nsDOMWindowUtils.cpp
+++ b/dom/base/nsDOMWindowUtils.cpp
@@ -4287,61 +4287,6 @@ struct StateTableEntry {
ElementState mState;
};
-static constexpr StateTableEntry kManuallyManagedStates[] = {
- {"autofill", ElementState::AUTOFILL},
- // :-moz-autofill-preview implies :autofill.
- {"-moz-autofill-preview",
- ElementState::AUTOFILL_PREVIEW | ElementState::AUTOFILL},
- {nullptr, ElementState()},
-};
-
-static_assert(!kManuallyManagedStates[ArrayLength(kManuallyManagedStates) - 1]
- .mStateString,
- "last kManuallyManagedStates entry must be a sentinel with "
- "mStateString == nullptr");
-
-static ElementState GetEventStateForString(const nsAString& aStateString) {
- for (const StateTableEntry* entry = kManuallyManagedStates;
- entry->mStateString; ++entry) {
- if (aStateString.EqualsASCII(entry->mStateString)) {
- return entry->mState;
- }
- }
- return ElementState();
-}
-
-NS_IMETHODIMP
-nsDOMWindowUtils::AddManuallyManagedState(Element* aElement,
- const nsAString& aStateString) {
- if (!aElement) {
- return NS_ERROR_INVALID_ARG;
- }
-
- ElementState state = GetEventStateForString(aStateString);
- if (state.IsEmpty()) {
- return NS_ERROR_INVALID_ARG;
- }
-
- aElement->AddStates(state);
- return NS_OK;
-}
-
-NS_IMETHODIMP
-nsDOMWindowUtils::RemoveManuallyManagedState(Element* aElement,
- const nsAString& aStateString) {
- if (!aElement) {
- return NS_ERROR_INVALID_ARG;
- }
-
- ElementState state = GetEventStateForString(aStateString);
- if (state.IsEmpty()) {
- return NS_ERROR_INVALID_ARG;
- }
-
- aElement->RemoveStates(state);
- return NS_OK;
-}
-
NS_IMETHODIMP
nsDOMWindowUtils::GetStorageUsage(Storage* aStorage, int64_t* aRetval) {
if (!aStorage) {
diff --git a/dom/interfaces/base/nsIDOMWindowUtils.idl b/dom/interfaces/base/nsIDOMWindowUtils.idl
index 9d185e8e7edc..253ceb727259 100644
--- a/dom/interfaces/base/nsIDOMWindowUtils.idl
+++ b/dom/interfaces/base/nsIDOMWindowUtils.idl
@@ -2070,26 +2070,6 @@ interface nsIDOMWindowUtils : nsISupports {
*/
readonly attribute int32_t gpuProcessPid;
- /**
- * Adds an ElementState bit to the element.
- *
- * The state string must be one of the following:
- * * (none yet; but for example "higlighted" for ElementState::HIGHLIGHTED)
- *
- * The supported state strings are defined in kManuallyManagedStates
- * in nsDOMWindowUtils.cpp.
- */
- void addManuallyManagedState(in Element element,
- in AString state);
-
- /**
- * Removes the specified ElementState bits from the element.
- *
- * See above for the strings that can be passed for |state|.
- */
- void removeManuallyManagedState(in Element element,
- in AString state);
-
/**
* Returns usage data for a given storage object.
*
diff --git a/layout/reftests/forms/input/text/autofill-author-background.html b/layout/reftests/forms/input/text/autofill-author-background.html
index 73eb71ea7c3f..0e8fe408d227 100644
--- a/layout/reftests/forms/input/text/autofill-author-background.html
+++ b/layout/reftests/forms/input/text/autofill-author-background.html
@@ -5,5 +5,5 @@
SpecialPowers.Cc["@mozilla.org/satchel/form-fill-controller;1"].getService(SpecialPowers.Ci.nsIFormFillController).markAsAutoCompletableField(input);
input.getBoundingClientRect(); // previewValue setter depends on the reframe posted by markAsAutoCompletableField() having being processed...
input.previewValue = "Autofill";
- SpecialPowers.wrap(window).windowUtils.addManuallyManagedState(input, "-moz-autofill-preview");
+ input.autofillState = "preview";
diff --git a/layout/reftests/forms/input/text/autofill-blank.html b/layout/reftests/forms/input/text/autofill-blank.html
index 17919875eea4..6373dea1b2f3 100644
--- a/layout/reftests/forms/input/text/autofill-blank.html
+++ b/layout/reftests/forms/input/text/autofill-blank.html
@@ -4,5 +4,5 @@
let input = SpecialPowers.wrap(document.querySelector("input"));
SpecialPowers.Cc["@mozilla.org/satchel/form-fill-controller;1"].getService(SpecialPowers.Ci.nsIFormFillController).markAsAutoCompletableField(input);
input.getBoundingClientRect();
- SpecialPowers.wrap(window).windowUtils.addManuallyManagedState(input, "autofill");
+ input.autofillState = "autofill";
diff --git a/layout/reftests/forms/input/text/autofill-line-height.html b/layout/reftests/forms/input/text/autofill-line-height.html
index 7ef597089682..8176f8334cee 100644
--- a/layout/reftests/forms/input/text/autofill-line-height.html
+++ b/layout/reftests/forms/input/text/autofill-line-height.html
@@ -5,5 +5,5 @@
diff --git a/layout/reftests/forms/input/text/autofill-prefilled-value.html b/layout/reftests/forms/input/text/autofill-prefilled-value.html
index 07b4ce5310a3..0676fee4965f 100644
--- a/layout/reftests/forms/input/text/autofill-prefilled-value.html
+++ b/layout/reftests/forms/input/text/autofill-prefilled-value.html
@@ -5,5 +5,5 @@
SpecialPowers.Cc["@mozilla.org/satchel/form-fill-controller;1"].getService(SpecialPowers.Ci.nsIFormFillController).markAsAutoCompletableField(input);
input.getBoundingClientRect(); // previewValue setter depends on the reframe posted by markAsAutoCompletableField() having being processed...
input.previewValue = "Autofill";
- SpecialPowers.wrap(window).windowUtils.addManuallyManagedState(input, "-moz-autofill-preview");
+ input.autofillState = "preview";
diff --git a/layout/reftests/forms/input/text/autofill-preview-blank.html b/layout/reftests/forms/input/text/autofill-preview-blank.html
index e441b80700f2..be6414166db9 100644
--- a/layout/reftests/forms/input/text/autofill-preview-blank.html
+++ b/layout/reftests/forms/input/text/autofill-preview-blank.html
@@ -4,5 +4,5 @@
let input = SpecialPowers.wrap(document.querySelector("input"));
SpecialPowers.Cc["@mozilla.org/satchel/form-fill-controller;1"].getService(SpecialPowers.Ci.nsIFormFillController).markAsAutoCompletableField(input);
input.getBoundingClientRect();
- SpecialPowers.wrap(window).windowUtils.addManuallyManagedState(input, "-moz-autofill-preview");
+ input.autofillState = "preview";
diff --git a/layout/reftests/forms/input/text/autofill-preview-line-height.html b/layout/reftests/forms/input/text/autofill-preview-line-height.html
index 40b63e9ede66..71961121a03b 100644
--- a/layout/reftests/forms/input/text/autofill-preview-line-height.html
+++ b/layout/reftests/forms/input/text/autofill-preview-line-height.html
@@ -8,5 +8,5 @@
SpecialPowers.Cc["@mozilla.org/satchel/form-fill-controller;1"].getService(SpecialPowers.Ci.nsIFormFillController).markAsAutoCompletableField(input);
input.getBoundingClientRect(); // previewValue setter depends on the reframe posted by markAsAutoCompletableField() having being processed...
input.previewValue = "Autofill";
- SpecialPowers.wrap(window).windowUtils.addManuallyManagedState(input, "-moz-autofill-preview");
+ input.autofillState = "preview";
diff --git a/layout/reftests/forms/input/text/autofill-preview.html b/layout/reftests/forms/input/text/autofill-preview.html
index 540c07423f03..c73153731a24 100644
--- a/layout/reftests/forms/input/text/autofill-preview.html
+++ b/layout/reftests/forms/input/text/autofill-preview.html
@@ -5,5 +5,5 @@
SpecialPowers.Cc["@mozilla.org/satchel/form-fill-controller;1"].getService(SpecialPowers.Ci.nsIFormFillController).markAsAutoCompletableField(input);
input.getBoundingClientRect(); // previewValue setter depends on the reframe posted by markAsAutoCompletableField() having being processed...
input.previewValue = "Autofill";
- SpecialPowers.wrap(window).windowUtils.addManuallyManagedState(input, "-moz-autofill-preview");
+ input.autofillState = "preview";
diff --git a/layout/reftests/forms/input/text/autofill.html b/layout/reftests/forms/input/text/autofill.html
index 0d9c6a058824..934ccfb4956e 100644
--- a/layout/reftests/forms/input/text/autofill.html
+++ b/layout/reftests/forms/input/text/autofill.html
@@ -5,5 +5,5 @@
SpecialPowers.Cc["@mozilla.org/satchel/form-fill-controller;1"].getService(SpecialPowers.Ci.nsIFormFillController).markAsAutoCompletableField(input);
input.getBoundingClientRect(); // previewValue setter depends on the reframe posted by markAsAutoCompletableField() having being processed...
input.previewValue = "Autofill";
- SpecialPowers.wrap(window).windowUtils.addManuallyManagedState(input, "autofill");
+ input.autofillState = "autofill";
diff --git a/toolkit/modules/tests/modules/MockDocument.sys.mjs b/toolkit/modules/tests/modules/MockDocument.sys.mjs
index d4c2b0720539..a4061259551a 100644
--- a/toolkit/modules/tests/modules/MockDocument.sys.mjs
+++ b/toolkit/modules/tests/modules/MockDocument.sys.mjs
@@ -59,10 +59,6 @@ export const MockDocument = {
mockOwnerGlobalProperty(aElement) {
Object.defineProperty(aElement, "ownerGlobal", {
value: {
- windowUtils: {
- addManuallyManagedState() {},
- removeManuallyManagedState() {},
- },
UIEvent: Event,
Event,
},