@@ -167,4 +167,72 @@ public void textContentCdata() throws Exception {
167167 loadPageVerifyTitle2 (content );
168168 }
169169
170+ @ Test
171+ @ Alerts ({"before:new,old" , "after:old,new" ,
172+ "prepend:new,old" , "append:old,new" , "appendChild:old,new" ,
173+ "insertBefore:new,old" ,
174+ "replaceWith:new" , "replaceChild:new" , "replaceChildren:new" })
175+ public void documentFragment_dissolution () throws Exception {
176+ final String html = DOCTYPE_HTML
177+ + "<html><head>\n "
178+ + "<script>\n "
179+ + LOG_TITLE_FUNCTION
180+ + "function createFragment() {\n "
181+ + " var f = document.createDocumentFragment();\n "
182+ + " var s = document.createElement('span'); s.textContent = 'new';\n "
183+ + " f.appendChild(s);\n "
184+ + " return f;\n "
185+ + "}\n "
186+ + "function texts(id) {\n "
187+ + " var el = document.getElementById(id);\n "
188+ + " var r = [];\n "
189+ + " for (var i = 0; i < el.children.length; i++) r.push(el.children[i].textContent);\n "
190+ + " return r.join(',');\n "
191+ + "}\n "
192+ + "function test() {\n "
193+ + " document.getElementById('beforeRef').before(createFragment());\n "
194+ + " log('before:' + texts('before'));\n "
195+ + "\n "
196+ + " document.getElementById('afterRef').after(createFragment());\n "
197+ + " log('after:' + texts('after'));\n "
198+ + "\n "
199+ + " document.getElementById('prepend').prepend(createFragment());\n "
200+ + " log('prepend:' + texts('prepend'));\n "
201+ + "\n "
202+ + " document.getElementById('append').append(createFragment());\n "
203+ + " log('append:' + texts('append'));\n "
204+ + "\n "
205+ + " document.getElementById('appendChild').appendChild(createFragment());\n "
206+ + " log('appendChild:' + texts('appendChild'));\n "
207+ + "\n "
208+ + " document.getElementById('insertBefore')\n "
209+ + " .insertBefore(createFragment(), document.getElementById('insertBeforeRef'));\n "
210+ + " log('insertBefore:' + texts('insertBefore'));\n "
211+ + "\n "
212+ + " document.getElementById('replaceWithRef').replaceWith(createFragment());\n "
213+ + " log('replaceWith:' + texts('replaceWith'));\n "
214+ + "\n "
215+ + " document.getElementById('replaceChild')\n "
216+ + " .replaceChild(createFragment(), document.getElementById('replaceChildRef'));\n "
217+ + " log('replaceChild:' + texts('replaceChild'));\n "
218+ + "\n "
219+ + " document.getElementById('replaceChildren').replaceChildren(createFragment());\n "
220+ + " log('replaceChildren:' + texts('replaceChildren'));\n "
221+ + "}\n "
222+ + "</script>\n "
223+ + "</head><body onload='test()'>\n "
224+ + "<div id='before'><span id='beforeRef'>old</span></div>\n "
225+ + "<div id='after'><span id='afterRef'>old</span></div>\n "
226+ + "<div id='prepend'><span>old</span></div>\n "
227+ + "<div id='append'><span>old</span></div>\n "
228+ + "<div id='appendChild'><span>old</span></div>\n "
229+ + "<div id='insertBefore'><span id='insertBeforeRef'>old</span></div>\n "
230+ + "<div id='replaceWith'><span id='replaceWithRef'>old</span></div>\n "
231+ + "<div id='replaceChild'><span id='replaceChildRef'>old</span></div>\n "
232+ + "<div id='replaceChildren'><span>old</span></div>\n "
233+ + "</body></html>" ;
234+
235+ loadPageVerifyTitle2 (html );
236+ }
237+
170238}
0 commit comments