diff --git a/testing/web-platform/tests/html/semantics/interactive-elements/the-details-element/name-attribute.tentative.html b/testing/web-platform/tests/html/semantics/interactive-elements/the-details-element/name-attribute.tentative.html index 2276b2d36d61b..22cecfe4dc018 100644 --- a/testing/web-platform/tests/html/semantics/interactive-elements/the-details-element/name-attribute.tentative.html +++ b/testing/web-platform/tests/html/semantics/interactive-elements/the-details-element/name-attribute.tentative.html @@ -1004,133 +1004,6 @@ " ) ; -/ -/ -The -next -two -tests -test -characteristics -of -the -design -that -are -only -/ -/ -exposed -via -mutation -events -. -If -mutation -events -( -for -attribute -/ -/ -addition -/ -removal -) -are -removed -from -the -web -these -tests -could -be -/ -/ -removed -and -some -small -simplifications -could -be -made -to -the -code -/ -/ -implementing -this -feature -. -function -mutation_events_for_attribute_removal_supported -( -) -{ -container -. -innerHTML -= -< -div -id -= -" -event -- -removal -- -test -" -> -< -/ -div -> -; -let -element -= -container -. -firstChild -; -let -event_fired -= -false -; -element -. -addEventListener -( -" -DOMSubtreeModified -" -event -= -> -event_fired -= -true -) -; -element -. -removeAttribute -( -" -id -" -) -; -return -event_fired -; -} promise_test ( async @@ -1138,17 +1011,6 @@ = > { -if -( -! -mutation_events_for_attribute_removal_supported -( -) -) -{ -return -; -} container . innerHTML @@ -1284,13 +1146,13 @@ ) ; let -received_ids +mutation_event_received_ids = [ ] ; let -listener +mutation_listener = event = @@ -1335,7 +1197,7 @@ " ) ; -received_ids +mutation_event_received_ids . push ( @@ -1346,6 +1208,18 @@ ; } ; +let +toggle_event_received_ids += +[ +] +; +let +toggle_event_promises += +[ +] +; for ( let @@ -1361,13 +1235,77 @@ " DOMSubtreeModified " -listener +mutation_listener +) +; +toggle_event_promises +. +push +( +new +Promise +( +( +resolve +reject +) += +> +{ +element +. +addEventListener +( +" +toggle +" +event += +> +{ +assert_equals +( +event +. +type +" +toggle +" +) +; +assert_equals +( +event +. +target +element +) +; +toggle_event_received_ids +. +push +( +element +. +id +) +; +resolve +( +undefined +) +; +} +) +; +} +) ) ; } assert_array_equals ( -received_ids +mutation_event_received_ids [ ] ) @@ -1397,9 +1335,31 @@ = true ; +if +( +mutation_event_received_ids +. +length += += +0 +) +{ +/ +/ +ok +if +mutation +events +are +not +supported +} +else +{ assert_array_equals ( -received_ids +mutation_event_received_ids [ " e0 @@ -1429,6 +1389,7 @@ " ) ; +} assert_element_states ( elements @@ -1445,10 +1406,63 @@ " ) ; +assert_array_equals +( +toggle_event_received_ids +[ +] +" +toggle +events +received +before +awaiting +promises +" +) +; +await +Promise +. +all +( +toggle_event_promises +) +; +assert_array_equals +( +toggle_event_received_ids +[ +" +e1 +" +" +e0 +" +" +e3 +" +" +e2 +" +] +" +toggle +events +received +after +awaiting +promises +" +) +; } " mutation event +and +toggle +event order matches order @@ -1462,6 +1476,139 @@ " ) ; +/ +/ +This +function +is +used +to +guard +tests +that +test +behavior +that +is +/ +/ +relevant +only +because +of +Mutation +Events +. +If +mutation +events +( +for +/ +/ +attribute +addition +/ +removal +) +are +removed +from +the +web +the +tests +using +/ +/ +this +function +can +be +removed +. +function +mutation_events_for_attribute_removal_supported +( +) +{ +if +( +! +( +" +MutationEvent +" +in +window +) +) +{ +return +false +; +} +container +. +innerHTML += +< +div +id += +" +event +- +removal +- +test +" +> +< +/ +div +> +; +let +element += +container +. +firstChild +; +let +event_fired += +false +; +element +. +addEventListener +( +" +DOMSubtreeModified +" +event += +> +event_fired += +true +) +; +element +. +removeAttribute +( +" +id +" +) +; +return +event_fired +; +} promise_test ( async