Index: LayoutTests/fast/dom/custom/inserted-callback.html |
diff --git a/LayoutTests/fast/dom/custom/inserted-callback.html b/LayoutTests/fast/dom/custom/inserted-callback.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..1024bed5465948ee12c62cd27ea2ac33e166bddf |
--- /dev/null |
+++ b/LayoutTests/fast/dom/custom/inserted-callback.html |
@@ -0,0 +1,39 @@ |
+<!DOCTYPE html> |
+<script src="../../../resources/testharness.js"></script> |
+<script src="../../../resources/testharnessreport.js"></script> |
+<body> |
+<div id="containsQ"> |
+<x-a id="q"></x-a> |
+</div> |
+<script> |
+t = async_test('inserted callback'); |
+t.calls = []; |
+ |
+t.step(function () { |
+ function inserted() { |
+ t.calls.push(this.id); |
+ } |
+ |
+ var proto = Object.create(HTMLElement.prototype); |
+ proto.insertedCallback = inserted; |
+ var ctor = document.register('x-a', {prototype: proto}); |
+ assert_array_equals(t.calls, ['q'], 'register must invoke inserted'); |
+ t.calls = []; |
+ |
+ var contains_q = document.querySelector('#containsQ'); |
+ contains_q.remove(); |
+ document.body.appendChild(contains_q); |
+ assert_array_equals(t.calls, [], 'inserted must be queued, not called'); |
+ |
+ var r = new ctor(); |
+ r.id = 'r'; |
+ document.body.appendChild(r); |
+ assert_array_equals(t.calls, [], 'inserted must be queued, not called'); |
+}); |
+</script> |
+<script> |
+t.step(function () { |
+ assert_array_equals(t.calls, ['q', 'r'], 'callbacks should be delivered in the order that they were queued'); |
+ t.done(); |
+}); |
+</script> |