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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/fast/dom/mutation-event-for-fragment-insertion.html
diff --git a/third_party/WebKit/LayoutTests/fast/dom/mutation-event-for-fragment-insertion.html b/third_party/WebKit/LayoutTests/fast/dom/mutation-event-for-fragment-insertion.html
new file mode 100644
index 0000000000000000000000000000000000000000..5f2cb905f0823d084e7d6e2ebeb37f0d26bcf972
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/dom/mutation-event-for-fragment-insertion.html
@@ -0,0 +1,43 @@
+<!DOCTYPE html>
+<body>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<script>
+function createContainerNode(test, expectedLength) {
+ var div = document.createElement('div');
+ var oldChild = document.createElement('span');
+ div.appendChild(oldChild);
+ document.body.appendChild(div);
+ div.dispatchCount = 0;
+ div.addEventListener('DOMNodeInserted', () => {
+ assert_equals(div.childNodes.length, expectedLength);
+ if (++div.dispatchCount == 2)
+ test.done();
+ }, false);
+ return div;
+}
+
+function createFragment() {
+ var fragment = document.createDocumentFragment();
+ fragment.appendChild(document.createElement('span'));
+ fragment.appendChild(document.createElement('span'));
+ return fragment;
+}
+
+var test1 = async_test('appendChild: DOMNodeInserted event should be dispatched after all nodes in a DocumentFragment were inserted.');
+test1.step(() => {
+ createContainerNode(test1, 3).appendChild(createFragment());
+});
+
+var test2 = async_test('insertBefore: DOMNodeInserted event should be dispatched after all nodes in a DocumentFragment were inserted.');
+test2.step(() => {
+ createContainerNode(test2, 3).insertBefore(createFragment(), null);
+});
+
+var test3 = async_test('replaceChild: DOMNodeInserted event should be dispatched after all nodes in a DocumentFragment were inserted.');
+test3.step(() => {
+ var div = createContainerNode(test3, 2);
+ div.replaceChild(createFragment(), div.firstChild);
+});
+</script>
+</body>

Powered by Google App Engine
This is Rietveld 408576698