| 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 <script> | 5 <script> |
| 6 test(function () { | 6 test(function () { |
| 7 var createdInvocations = 0; | 7 var createdInvocations = 0; |
| 8 function created() { | 8 function created() { |
| 9 createdInvocations++; | 9 createdInvocations++; |
| 10 } | 10 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 var element = new ctor(); | 31 var element = new ctor(); |
| 32 assert_equals(createdInvocations, 1, 'the created callback retrieved at regi
stration must be invoked'); | 32 assert_equals(createdInvocations, 1, 'the created callback retrieved at regi
stration must be invoked'); |
| 33 }, 'transfer created callback'); | 33 }, 'transfer created callback'); |
| 34 | 34 |
| 35 t = async_test('__proto__, :unresolved and created callback timing'); | 35 t = async_test('__proto__, :unresolved and created callback timing'); |
| 36 t.step(function () { | 36 t.step(function () { |
| 37 var createdInvocations = 0; | 37 var createdInvocations = 0; |
| 38 function created() { | 38 function created() { |
| 39 createdInvocations++; | 39 createdInvocations++; |
| 40 | 40 |
| 41 if (this.id != 'v') | 41 if (this.id != 'u') |
| 42 return; | 42 return; |
| 43 | 43 |
| 44 t.step(function () { | 44 t.step(function () { |
| 45 var t = div.querySelector('#t'); | 45 var t = div.querySelector('#t'); |
| 46 var u = div.querySelector('#u'); | 46 var v = div.querySelector('#v'); |
| 47 var w = div.querySelector('#w'); | 47 var w = div.querySelector('#w'); |
| 48 | 48 |
| 49 assert_equals(div.querySelector('x-c:not(:unresolved)'), this, 'the
:unresolved pseudoclass should cease to apply when the created callback is invok
ed'); | 49 assert_equals(div.querySelector('x-b:not(:unresolved)'), this, 'the
:unresolved pseudoclass should cease to apply when the created callback is invok
ed'); |
| 50 assert_array_equals(div.querySelectorAll(':unresolved'), [t, u], 'th
e :unresolved pseudoclass should be processed in order'); | 50 assert_array_equals(div.querySelectorAll(':unresolved'), [v, w], 'th
e :unresolved pseudoclass should be processed in order'); |
| 51 | 51 |
| 52 assert_false(t instanceof C, 'prototype upgrade should happen in ord
er (#t)'); | 52 assert_true(t instanceof C, 'prototype upgrade should happen in orde
r (#t)'); |
| 53 assert_false(u instanceof B, 'prototype upgrade should happen in ord
er (#u)'); | 53 assert_false(v instanceof C, 'prototype upgrade should happen in ord
er (#v)'); |
| 54 }, this); | 54 }, this); |
| 55 } | 55 } |
| 56 | 56 |
| 57 var protoB = Object.create(HTMLElement.prototype); | 57 var protoB = Object.create(HTMLElement.prototype); |
| 58 var B = document.register('x-b', {prototype: protoB}); | 58 var B = document.register('x-b', {prototype: protoB}); |
| 59 | 59 |
| 60 var protoC = Object.create(HTMLElement.prototype); | 60 var protoC = Object.create(HTMLElement.prototype); |
| 61 protoC.createdCallback = created; | 61 protoC.createdCallback = created; |
| 62 var C = document.register('x-c', {prototype: protoC}); | 62 var C = document.register('x-c', {prototype: protoC}); |
| 63 | 63 |
| 64 var div = document.createElement('div'); | 64 var div = document.createElement('div'); |
| 65 div.innerHTML = '<x-c id="t"></x-c>' + | 65 div.innerHTML = '<x-c id="t"></x-c>' + |
| 66 '<x-b id="u"></x-b>' + | 66 '<x-b id="u"></x-b>' + |
| 67 '<x-c id="v"></x-c>' + | 67 '<x-c id="v"></x-c>' + |
| 68 '<x-b id="w"></x-b>'; | 68 '<x-b id="w"></x-b>'; |
| 69 assert_equals(createdInvocations, 2, 'the created callback should have been
invoked once for each x-c element'); | 69 assert_equals(createdInvocations, 2, 'the created callback should have been
invoked once for each x-c element'); |
| 70 assert_true(div.querySelector('#t') instanceof C, '#t\'s prototype should ha
ve ultimately been upgraded'); | 70 assert_true(div.querySelector('#w') instanceof B, '#w\'s prototype should ha
ve ultimately been upgraded'); |
| 71 t.done(); | 71 t.done(); |
| 72 }); | 72 }); |
| 73 </script> | 73 </script> |
| OLD | NEW |