From 065bcee37184f0c070c75a1fa4b3a27f4921fc71 Mon Sep 17 00:00:00 2001 From: Patrick Shaughnessy Date: Tue, 31 Dec 2019 21:02:27 -0500 Subject: [PATCH] CustomElementRegistry.upgrade works by current spec --- components/script/dom/customelementregistry.rs | 11 +++++++++++ .../script/dom/webidls/CustomElementRegistry.webidl | 2 ++ .../custom-element-registry/upgrade.html.ini | 12 ------------ .../wpt/metadata/html/dom/idlharness.https.html.ini | 3 --- 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/components/script/dom/customelementregistry.rs b/components/script/dom/customelementregistry.rs index dbeacdc7ebb..392cf49cce5 100644 --- a/components/script/dom/customelementregistry.rs +++ b/components/script/dom/customelementregistry.rs @@ -448,6 +448,17 @@ impl CustomElementRegistryMethods for CustomElementRegistry { // Step 6 promise } + /// https://html.spec.whatwg.org/multipage/#dom-customelementregistry-upgrade + fn Upgrade(&self, node: &Node) { + // Spec says to make a list first and then iterate the list, but + // try-to-upgrade only queues upgrade reactions and doesn't itself + // modify the tree, so that's not an observable distinction. + node.traverse_preorder(ShadowIncluding::Yes).for_each(|n| { + if let Some(element) = n.downcast::() { + try_upgrade_element(element); + } + }); + } } #[derive(Clone, JSTraceable, MallocSizeOf)] diff --git a/components/script/dom/webidls/CustomElementRegistry.webidl b/components/script/dom/webidls/CustomElementRegistry.webidl index 6d3a7b436de..3ba49a2082c 100644 --- a/components/script/dom/webidls/CustomElementRegistry.webidl +++ b/components/script/dom/webidls/CustomElementRegistry.webidl @@ -11,6 +11,8 @@ interface CustomElementRegistry { any get(DOMString name); Promise whenDefined(DOMString name); + + [CEReactions] void upgrade(Node root); }; callback CustomElementConstructor = HTMLElement(); diff --git a/tests/wpt/metadata/custom-elements/custom-element-registry/upgrade.html.ini b/tests/wpt/metadata/custom-elements/custom-element-registry/upgrade.html.ini index 3c538145973..f38f6bafb44 100644 --- a/tests/wpt/metadata/custom-elements/custom-element-registry/upgrade.html.ini +++ b/tests/wpt/metadata/custom-elements/custom-element-registry/upgrade.html.ini @@ -1,16 +1,4 @@ [upgrade.html] - [Upgrading an element directly (example from the spec)] - expected: FAIL - - [Two elements as children of the upgraded node] - expected: FAIL - - [Two elements as descendants of the upgraded node] - expected: FAIL - [Two elements as shadow-including descendants (and not descendants) of the upgraded node] expected: FAIL - [Elements inside a template contents DocumentFragment node] - expected: FAIL - diff --git a/tests/wpt/metadata/html/dom/idlharness.https.html.ini b/tests/wpt/metadata/html/dom/idlharness.https.html.ini index c026f0614c0..acb8acc08a7 100644 --- a/tests/wpt/metadata/html/dom/idlharness.https.html.ini +++ b/tests/wpt/metadata/html/dom/idlharness.https.html.ini @@ -62,9 +62,6 @@ [CanvasRenderingContext2D interface: document.createElement("canvas").getContext("2d") must inherit property "getTransform()" with the proper type] expected: FAIL - [CustomElementRegistry interface: operation upgrade(Node)] - expected: FAIL - [OffscreenCanvasRenderingContext2D interface: attribute imageSmoothingEnabled] expected: FAIL