@@ -134,6 +134,30 @@ export function installXmlHttpRequest() {
134134 } ;
135135}
136136
137+ /**
138+ * Fixtures this module attached to the document, in attachment order.
139+ *
140+ * Only what the harness appends is recorded: a detached `createToolbar()`
141+ * fixture stays out of it, so the lifecycle tests keep driving
142+ * `disconnectedCallback()` themselves.
143+ */
144+ var attached = [ ] ;
145+
146+ /**
147+ * Detaches every recorded fixture still in the document and forgets all of
148+ * them, so a thrown assertion cannot leave a connected toolbar registered in
149+ * `toolbars`, listening on the document or holding a theme observer.
150+ */
151+ export function teardownToolbars ( ) {
152+ for ( var i = attached . length - 1 ; i >= 0 ; i -- ) {
153+ if ( attached [ i ] . isConnected ) {
154+ attached [ i ] . remove ( ) ;
155+ }
156+ }
157+
158+ attached . length = 0 ;
159+ }
160+
137161export function defineToolbar ( ) {
138162 if ( ! window . customElements . get ( tagName ) ) {
139163 window . customElements . define ( tagName , YiiDebugToolbar ) ;
@@ -159,6 +183,7 @@ export function connectToolbar(attributes) {
159183 var element = createToolbar ( attributes ) ;
160184
161185 document . body . appendChild ( element ) ;
186+ attached . push ( element ) ;
162187
163188 return element ;
164189}
@@ -212,6 +237,7 @@ export function stubFrameWindow(frame) {
212237 var donor = document . createElement ( "iframe" ) ;
213238
214239 document . body . appendChild ( donor ) ;
240+ attached . push ( donor ) ;
215241 Object . defineProperty ( frame , "contentWindow" , {
216242 configurable : true ,
217243 value : donor . contentWindow ,
0 commit comments