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 <template id="expected">A entered | 5 <template id="expected">A entered |
6 A removing parent node | 6 A removing parent node |
7 A left | 7 A left |
8 A inserting parent node | 8 A inserting parent node |
9 A entered | 9 A entered |
10 A removing parent node | 10 A removing parent node |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 // yet. | 84 // yet. |
85 // | 85 // |
86 // x-c turns around and sets and attribute on x-b. This tests case | 86 // x-c turns around and sets and attribute on x-b. This tests case |
87 // (2) because x-b is half way through processing its queue. | 87 // (2) because x-b is half way through processing its queue. |
88 // | 88 // |
89 // x-b turns around and sets an attribute on x-a. This tests case | 89 // x-b turns around and sets an attribute on x-a. This tests case |
90 // (3) because x-a has finished processing its queue. | 90 // (3) because x-a has finished processing its queue. |
91 | 91 |
92 var protoA = Object.create(HTMLElement.prototype); | 92 var protoA = Object.create(HTMLElement.prototype); |
93 var n = 0; | 93 var n = 0; |
94 protoA.enteredViewCallback = function () { | 94 protoA.attachedCallback = function () { |
95 log('A entered'); | 95 log('A entered'); |
96 n++; | 96 n++; |
97 if (n < 3) { | 97 if (n < 3) { |
98 indented('A removing parent node'); | 98 indented('A removing parent node'); |
99 this.parentNode.remove(); | 99 this.parentNode.remove(); |
100 unindent(); | 100 unindent(); |
101 } | 101 } |
102 }; | 102 }; |
103 protoA.leftViewCallback = function () { | 103 protoA.detachedCallback = function () { |
104 log('A left'); | 104 log('A left'); |
105 indented('A inserting parent node'); | 105 indented('A inserting parent node'); |
106 document.body.appendChild(this.parentNode); | 106 document.body.appendChild(this.parentNode); |
107 unindent(); | 107 unindent(); |
108 }; | 108 }; |
109 protoA.attributeChangedCallback = function (name, oldValue, newValue) { | 109 protoA.attributeChangedCallback = function (name, oldValue, newValue) { |
110 log('A@' + name + ' ' + oldValue + '->' + newValue); | 110 log('A@' + name + ' ' + oldValue + '->' + newValue); |
111 }; | 111 }; |
112 var A = document.register('x-a', {prototype: protoA}); | 112 var A = document.registerElement('x-a', {prototype: protoA}); |
113 | 113 |
114 var protoB = Object.create(HTMLElement.prototype); | 114 var protoB = Object.create(HTMLElement.prototype); |
115 var m = 0; | 115 var m = 0; |
116 protoB.enteredViewCallback = function () { | 116 protoB.attachedCallback = function () { |
117 log('B entered'); | 117 log('B entered'); |
118 m++; | 118 m++; |
119 if (m == 2) { | 119 if (m == 2) { |
120 indented('B setting attribute on C'); | 120 indented('B setting attribute on C'); |
121 this.parentNode.querySelector('x-c').setAttribute('by', 'b'); | 121 this.parentNode.querySelector('x-c').setAttribute('by', 'b'); |
122 unindent(); | 122 unindent(); |
123 } | 123 } |
124 }; | 124 }; |
125 protoB.leftViewCallback = function () { | 125 protoB.detachedCallback = function () { |
126 log('B left'); | 126 log('B left'); |
127 }; | 127 }; |
128 protoB.attributeChangedCallback = function (name, oldValue, newValue) { | 128 protoB.attributeChangedCallback = function (name, oldValue, newValue) { |
129 log('B@' + name + ' ' + oldValue + '->' + newValue); | 129 log('B@' + name + ' ' + oldValue + '->' + newValue); |
130 indented('B setting attribute on A'); | 130 indented('B setting attribute on A'); |
131 this.parentNode.querySelector('x-a').setAttribute('by', 'b'); | 131 this.parentNode.querySelector('x-a').setAttribute('by', 'b'); |
132 unindent(); | 132 unindent(); |
133 }; | 133 }; |
134 var B = document.register('x-b', {prototype: protoB}); | 134 var B = document.registerElement('x-b', {prototype: protoB}); |
135 | 135 |
136 var protoC = Object.create(HTMLElement.prototype); | 136 var protoC = Object.create(HTMLElement.prototype); |
137 protoC.enteredViewCallback = function () { | 137 protoC.attachedCallback = function () { |
138 log('C entered'); | 138 log('C entered'); |
139 }; | 139 }; |
140 protoC.leftViewCallback = function () { | 140 protoC.detachedCallback = function () { |
141 log('C left'); | 141 log('C left'); |
142 }; | 142 }; |
143 protoC.attributeChangedCallback = function (name, oldValue, newValue) { | 143 protoC.attributeChangedCallback = function (name, oldValue, newValue) { |
144 log('C@' + name + ' ' + oldValue + '->' + newValue); | 144 log('C@' + name + ' ' + oldValue + '->' + newValue); |
145 indented('C setting attribute on B'); | 145 indented('C setting attribute on B'); |
146 this.parentNode.querySelector('x-b').setAttribute('by', 'c'); | 146 this.parentNode.querySelector('x-b').setAttribute('by', 'c'); |
147 unindent(); | 147 unindent(); |
148 }; | 148 }; |
149 var C = document.register('x-c', {prototype: protoC}); | 149 var C = document.registerElement('x-c', {prototype: protoC}); |
150 | 150 |
151 var div = document.createElement('div'); | 151 var div = document.createElement('div'); |
152 div.innerHTML = '<div><x-a></x-a><x-b></x-b><x-c></x-c></div>'; | 152 div.innerHTML = '<div><x-a></x-a><x-b></x-b><x-c></x-c></div>'; |
153 document.body.appendChild(div); | 153 document.body.appendChild(div); |
154 | 154 |
155 assert_equals(buffer.join('\n'), expected.content.textContent, 'should have
generated an identical log'); | 155 assert_equals(buffer.join('\n'), expected.content.textContent, 'should have
generated an identical log'); |
156 }, 'recursively scheduled callbacks'); | 156 }, 'recursively scheduled callbacks'); |
157 </script> | 157 </script> |
OLD | NEW |