OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <script src="../../../resources/testharness.js"></script> |
| 3 <script src="../../../resources/testharnessreport.js"></script> |
| 4 <body> |
| 5 <script> |
| 6 t = async_test('transfer callbacks'); |
| 7 t.gets = []; |
| 8 t.calls = []; |
| 9 |
| 10 t.step(function () { |
| 11 function getter(name) { |
| 12 return function () { |
| 13 t.gets.push(name); |
| 14 return function () { |
| 15 t.calls.push(name); |
| 16 }; |
| 17 }; |
| 18 } |
| 19 |
| 20 var proto = Object.create(HTMLElement.prototype, { |
| 21 insertedCallback: { |
| 22 get: getter('inserted') |
| 23 }, |
| 24 readyCallback: { |
| 25 get: getter('ready') |
| 26 }, |
| 27 removedCallback: { |
| 28 get: getter('removed') |
| 29 } |
| 30 }); |
| 31 |
| 32 var ctor = document.register('x-a', {prototype: proto}); |
| 33 assert_array_equals(t.gets, ['ready', 'inserted', 'removed'], 'the callbacks
must have been retrieved in the correct order'); |
| 34 |
| 35 function failer() { |
| 36 assert_unreached('the callbacks must not be retrieved after registration
'); |
| 37 } |
| 38 proto.readyCallback = proto.insertedCallback = proto.removedCallback = faile
r; |
| 39 |
| 40 var element = new ctor(); |
| 41 document.body.appendChild(element); |
| 42 element.remove(); |
| 43 }); |
| 44 </script> |
| 45 <script> |
| 46 t.step(function () { |
| 47 assert_array_equals(t.calls, ['ready', 'inserted', 'removed'], 'the retrieve
d callbacks should have been invoked'); |
| 48 t.done(); |
| 49 t = null; |
| 50 }); |
| 51 </script> |
OLD | NEW |