diff --git a/components/script/dom/bindings/htmlconstructor.rs b/components/script/dom/bindings/htmlconstructor.rs
index 08323e1e8cd..d984c687c16 100644
--- a/components/script/dom/bindings/htmlconstructor.rs
+++ b/components/script/dom/bindings/htmlconstructor.rs
@@ -182,7 +182,12 @@ where
DomRoot::downcast(element).ok_or(Error::InvalidState)
},
// Step 10
- Some(ConstructionStackEntry::AlreadyConstructedMarker) => Err(Error::InvalidState),
+ Some(ConstructionStackEntry::AlreadyConstructedMarker) => {
+ let s = "Top of construction stack marked AlreadyConstructed due to \
+ a custom element constructor constructing itself after super()"
+ .to_string();
+ Err(Error::Type(s))
+ },
}
}
diff --git a/components/script/dom/customelementregistry.rs b/components/script/dom/customelementregistry.rs
index 20ce633be5a..2613f722d41 100644
--- a/components/script/dom/customelementregistry.rs
+++ b/components/script/dom/customelementregistry.rs
@@ -680,7 +680,9 @@ fn run_upgrade_constructor(
return Err(Error::JSFailed);
}
if !same {
- return Err(Error::InvalidState);
+ return Err(Error::Type(
+ "Returned element is not SameValue as the upgraded element".to_string(),
+ ));
}
}
Ok(())
diff --git a/components/script/dom/webidls/CustomElementRegistry.webidl b/components/script/dom/webidls/CustomElementRegistry.webidl
index a888a3c1bf0..1072eed0031 100644
--- a/components/script/dom/webidls/CustomElementRegistry.webidl
+++ b/components/script/dom/webidls/CustomElementRegistry.webidl
@@ -13,7 +13,7 @@ interface CustomElementRegistry {
Promise whenDefined(DOMString name);
};
-callback CustomElementConstructor = any();
+callback CustomElementConstructor = HTMLElement();
dictionary ElementDefinitionOptions {
DOMString extends;
diff --git a/tests/wpt/metadata/custom-elements/upgrading/Node-cloneNode.html.ini b/tests/wpt/metadata/custom-elements/upgrading/Node-cloneNode.html.ini
index 4ef8083287b..503570bcb71 100644
--- a/tests/wpt/metadata/custom-elements/upgrading/Node-cloneNode.html.ini
+++ b/tests/wpt/metadata/custom-elements/upgrading/Node-cloneNode.html.ini
@@ -1,13 +1,3 @@
[Node-cloneNode.html]
[Node.prototype.cloneNode(false) must be able to clone as a customized built-in element when it has an inconsistent "is" attribute]
expected: FAIL
-
- [HTMLElement constructor must throw an TypeError when the top of the construction stack is marked AlreadyConstructed due to a custom element constructor constructing itself before super() call]
- expected: FAIL
-
- [Upgrading a custom element must throw TypeError when the custom element's constructor returns another element]
- expected: FAIL
-
- [HTMLElement constructor must throw an TypeError when the top of the construction stack is marked AlreadyConstructed due to a custom element constructor constructing itself after super() call]
- expected: FAIL
-
diff --git a/tests/wpt/metadata/custom-elements/upgrading/upgrading-parser-created-element.html.ini b/tests/wpt/metadata/custom-elements/upgrading/upgrading-parser-created-element.html.ini
deleted file mode 100644
index 84e2a61bc0b..00000000000
--- a/tests/wpt/metadata/custom-elements/upgrading/upgrading-parser-created-element.html.ini
+++ /dev/null
@@ -1,16 +0,0 @@
-[upgrading-parser-created-element.html]
- [Upgrading a custom element whose constructor returns a Text node must throw]
- expected: FAIL
-
- [HTMLElement constructor must throw an TypeError when the top of the construction stack is marked AlreadyConstructed due to a custom element constructor constructing itself after super() call]
- expected: FAIL
-
- [Upgrading a custom element whose constructor returns an Element must throw]
- expected: FAIL
-
- [Upgrading a custom element must throw an TypeError when the returned element is not SameValue as the upgraded element]
- expected: FAIL
-
- [HTMLElement constructor must throw an TypeError when the top of the construction stack is marked AlreadyConstructed due to a custom element constructor constructing itself before super() call]
- expected: FAIL
-