Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(146)

Side by Side Diff: third_party/WebKit/LayoutTests/fast/dom/mutation-event-for-fragment-insertion.html

Issue 2306323002: Change the timing of event dispatching and <script> execution in Node::appendChild, insertBefore,... (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <body>
3 <script src="../../resources/testharness.js"></script>
4 <script src="../../resources/testharnessreport.js"></script>
5 <script>
6 function createContainerNode(test, expectedLength) {
7 var div = document.createElement('div');
8 var oldChild = document.createElement('span');
9 div.appendChild(oldChild);
10 document.body.appendChild(div);
11 div.dispatchCount = 0;
12 div.addEventListener('DOMNodeInserted', () => {
13 assert_equals(div.childNodes.length, expectedLength);
14 if (++div.dispatchCount == 2)
15 test.done();
16 }, false);
17 return div;
18 }
19
20 function createFragment() {
21 var fragment = document.createDocumentFragment();
22 fragment.appendChild(document.createElement('span'));
23 fragment.appendChild(document.createElement('span'));
24 return fragment;
25 }
26
27 var test1 = async_test('appendChild: DOMNodeInserted event should be dispatched after all nodes in a DocumentFragment were inserted.');
28 test1.step(() => {
29 createContainerNode(test1, 3).appendChild(createFragment());
30 });
31
32 var test2 = async_test('insertBefore: DOMNodeInserted event should be dispatched after all nodes in a DocumentFragment were inserted.');
33 test2.step(() => {
34 createContainerNode(test2, 3).insertBefore(createFragment(), null);
35 });
36
37 var test3 = async_test('replaceChild: DOMNodeInserted event should be dispatched after all nodes in a DocumentFragment were inserted.');
38 test3.step(() => {
39 var div = createContainerNode(test3, 2);
40 div.replaceChild(createFragment(), div.firstChild);
41 });
42 </script>
43 </body>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698