| OLD | NEW |
| 1 library TestUtils; | 1 library TestUtils; |
| 2 | 2 |
| 3 import 'dart:async'; | 3 import 'dart:async'; |
| 4 import 'dart:html'; | 4 import 'dart:html'; |
| 5 import 'dart:js' as js; | 5 import 'dart:js' as js; |
| 6 import 'dart:typed_data'; | 6 import 'dart:typed_data'; |
| 7 import 'package:unittest/unittest.dart'; | 7 import 'package:unittest/unittest.dart'; |
| 8 export 'package:web_components/polyfill.dart'; |
| 8 | 9 |
| 9 /** | 10 /** |
| 10 * Verifies that [actual] has the same graph structure as [expected]. | 11 * Verifies that [actual] has the same graph structure as [expected]. |
| 11 * Detects cycles and DAG structure in Maps and Lists. | 12 * Detects cycles and DAG structure in Maps and Lists. |
| 12 */ | 13 */ |
| 13 verifyGraph(expected, actual) { | 14 verifyGraph(expected, actual) { |
| 14 var eItems = []; | 15 var eItems = []; |
| 15 var aItems = []; | 16 var aItems = []; |
| 16 | 17 |
| 17 message(path, reason) => path == '' | 18 message(path, reason) => path == '' |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 for (var key in aE.attributes.keys) { | 155 for (var key in aE.attributes.keys) { |
| 155 expect(aE.attributes[key], bE.attributes[key], | 156 expect(aE.attributes[key], bE.attributes[key], |
| 156 reason: '$path attribute [$key] values differ'); | 157 reason: '$path attribute [$key] values differ'); |
| 157 } | 158 } |
| 158 } | 159 } |
| 159 for (var i = 0; i < a.nodes.length; ++i) { | 160 for (var i = 0; i < a.nodes.length; ++i) { |
| 160 validateNodeTree(a.nodes[i], b.nodes[i], '$path[$i].'); | 161 validateNodeTree(a.nodes[i], b.nodes[i], '$path[$i].'); |
| 161 } | 162 } |
| 162 } | 163 } |
| 163 | 164 |
| 164 Future loadCustomElementPolyfill() { | |
| 165 if (!document.supportsRegister) { | |
| 166 var script = new ScriptElement() | |
| 167 ..src = '/packages/custom_element/custom-elements.debug.js'; | |
| 168 document.head.append(script); | |
| 169 return document.on['WebComponentsReady'].first; | |
| 170 } | |
| 171 return new Future.value(); | |
| 172 } | |
| 173 | |
| 174 Future loadPolyfills() { | |
| 175 return loadCustomElementPolyfill(); | |
| 176 } | |
| 177 | |
| 178 /** | 165 /** |
| 179 * Upgrade all custom elements in the subtree which have not been upgraded. | 166 * Upgrade all custom elements in the subtree which have not been upgraded. |
| 180 * | 167 * |
| 181 * This is needed to cover timing scenarios which the custom element polyfill | 168 * This is needed to cover timing scenarios which the custom element polyfill |
| 182 * does not cover. | 169 * does not cover. |
| 183 */ | 170 */ |
| 184 void upgradeCustomElements(Node node) { | 171 void upgradeCustomElements(Node node) { |
| 185 if (js.context.hasProperty('CustomElements') && | 172 if (js.context.hasProperty('CustomElements') && |
| 186 js.context['CustomElements'].hasProperty('upgradeAll')) { | 173 js.context['CustomElements'].hasProperty('upgradeAll')) { |
| 187 js.context['CustomElements'].callMethod('upgradeAll', [node]); | 174 js.context['CustomElements'].callMethod('upgradeAll', [node]); |
| 188 } | 175 } |
| 189 } | 176 } |
| OLD | NEW |