| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <script src="../../../resources/testharness.js"></script> | 2 <script src="../../../resources/testharness.js"></script> |
| 3 <script src="../../../resources/testharnessreport.js"></script> | 3 <script src="../../../resources/testharnessreport.js"></script> |
| 4 <body> | 4 <body> |
| 5 <x-a id="a"></x-a> |
| 6 <x-a id="b"></x-a> |
| 5 <script> | 7 <script> |
| 6 test(function () { | 8 t = async_test('ready callback'); |
| 7 var readyInvocations = 0; | 9 t.calls = []; |
| 8 function ready() { | |
| 9 readyInvocations++; | |
| 10 } | |
| 11 | 10 |
| 12 var getterInvocations = 0; | 11 t.step(function () { |
| 13 function getter() { | 12 var proto = Object.create(HTMLElement.prototype); |
| 14 getterInvocations++; | 13 proto.readyCallback = function () { |
| 15 return ready; | 14 t.calls.push(this.id + ' ready'); |
| 16 } | 15 }; |
| 17 | 16 |
| 18 function failer() { | 17 var ctor = document.register('x-a', {prototype: proto}); |
| 19 assert_unreached('the ready callback must not be retrieved after registr
ation'); | 18 var call_set = t.calls.slice(); |
| 20 } | 19 call_set.sort(); |
| 20 assert_array_equals(call_set, ['a ready', 'b ready'], 'document.register mus
t invoke the ready lifecycle callback for upgrade candidates'); |
| 21 | 21 |
| 22 var proto = Object.create(HTMLElement.prototype, { | 22 t.calls = []; |
| 23 readyCallback: { | 23 new ctor(); |
| 24 get: getter | 24 assert_array_equals(t.calls, [' ready'], 'invoking the generated constructor
must invoke the ready lifecycle callback'); |
| 25 } | |
| 26 }); | |
| 27 var ctor = document.register('x-a', {prototype: proto}); | |
| 28 assert_equals(getterInvocations, 1, 'the ready callback must have been retri
eved'); | |
| 29 | 25 |
| 30 proto.readyCallback = failer; | 26 t.calls = []; |
| 31 var element = new ctor(); | 27 var div = document.createElement('div'); |
| 32 assert_equals(readyInvocations, 1, 'the ready callback retrieved at registra
tion must be invoked'); | 28 div.innerHTML = '<x-a id="c"></x-a>'; |
| 33 }, 'transfer ready callback'); | 29 assert_array_equals(t.calls, [], 'parsing this fragment must not synchronous
ly invoke the ready lifecycle callback'); |
| 30 }); |
| 34 </script> | 31 </script> |
| 32 <script> |
| 33 t.step(function () { |
| 34 assert_array_equals(t.calls, ['c ready'], 'the ready callback should have be
en invoked at the microtask checkpoint'); |
| 35 t.done(); |
| 36 t = null; |
| 37 }); |
| 38 </script> |
| OLD | NEW |