OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <script src="../../../resources/testharness.js"></script> |
| 3 <script src="../../../resources/testharnessreport.js"></script> |
| 4 <body> |
| 5 <div id="containsQ"> |
| 6 <x-a id="q"></x-a> |
| 7 </div> |
| 8 <script> |
| 9 t = async_test('inserted callback'); |
| 10 t.calls = []; |
| 11 |
| 12 t.step(function () { |
| 13 function inserted() { |
| 14 t.calls.push(this.id); |
| 15 } |
| 16 |
| 17 var proto = Object.create(HTMLElement.prototype); |
| 18 proto.insertedCallback = inserted; |
| 19 var ctor = document.register('x-a', {prototype: proto}); |
| 20 assert_array_equals(t.calls, ['q'], 'register must invoke inserted'); |
| 21 t.calls = []; |
| 22 |
| 23 var contains_q = document.querySelector('#containsQ'); |
| 24 contains_q.remove(); |
| 25 document.body.appendChild(contains_q); |
| 26 assert_array_equals(t.calls, [], 'inserted must be queued, not called'); |
| 27 |
| 28 var r = new ctor(); |
| 29 r.id = 'r'; |
| 30 document.body.appendChild(r); |
| 31 assert_array_equals(t.calls, [], 'inserted must be queued, not called'); |
| 32 }); |
| 33 </script> |
| 34 <script> |
| 35 t.step(function () { |
| 36 assert_array_equals(t.calls, ['q', 'r'], 'callbacks should be delivered in t
he order that they were queued'); |
| 37 t.done(); |
| 38 }); |
| 39 </script> |
OLD | NEW |