| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library custom_elements_test; | 5 library custom_elements_test; |
| 6 import 'dart:async'; | 6 import 'dart:async'; |
| 7 import 'dart:html'; | 7 import 'dart:html'; |
| 8 import 'package:unittest/html_individual_config.dart'; | 8 import 'package:unittest/html_individual_config.dart'; |
| 9 import 'package:unittest/unittest.dart'; | 9 import 'package:unittest/unittest.dart'; |
| 10 import 'utils.dart'; | 10 import 'utils.dart'; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 } | 31 } |
| 32 } | 32 } |
| 33 | 33 |
| 34 int customCreatedCount = 0; | 34 int customCreatedCount = 0; |
| 35 | 35 |
| 36 int nextTagId = 0; | 36 int nextTagId = 0; |
| 37 String get nextTag => 'x-type${nextTagId++}'; | 37 String get nextTag => 'x-type${nextTagId++}'; |
| 38 | 38 |
| 39 class NotAnElement {} | 39 class NotAnElement {} |
| 40 | 40 |
| 41 loadPolyfills() { | |
| 42 if (!document.supportsRegister) { | |
| 43 // Cache blocker is a workaround for: | |
| 44 // https://code.google.com/p/dart/issues/detail?id=11834 | |
| 45 var cacheBlocker = new DateTime.now().millisecondsSinceEpoch; | |
| 46 return HttpRequest.getString('/root_dart/pkg/custom_element/lib/' | |
| 47 'custom-elements.debug.js?cacheBlock=$cacheBlocker').then((code) { | |
| 48 document.head.children.add(new ScriptElement()..text = code); | |
| 49 }); | |
| 50 } | |
| 51 } | |
| 52 | |
| 53 main() { | 41 main() { |
| 54 useHtmlIndividualConfiguration(); | 42 useHtmlIndividualConfiguration(); |
| 55 | 43 |
| 56 setUp(loadPolyfills); | 44 setUp(loadPolyfills); |
| 57 | 45 |
| 58 group('register', () { | 46 group('register', () { |
| 59 test('register', () { | 47 test('register', () { |
| 60 var tag = nextTag; | 48 var tag = nextTag; |
| 61 document.register(tag, CustomType); | 49 document.register(tag, CustomType); |
| 62 | 50 |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 test('can invoke mixin methods', () { | 179 test('can invoke mixin methods', () { |
| 192 var tag = nextTag; | 180 var tag = nextTag; |
| 193 document.register(tag, CustomType); | 181 document.register(tag, CustomType); |
| 194 | 182 |
| 195 var element = new Element.tag(tag); | 183 var element = new Element.tag(tag); |
| 196 element.invokeMixinMethod(); | 184 element.invokeMixinMethod(); |
| 197 expect(element.mixinMethodCalled, isTrue); | 185 expect(element.mixinMethodCalled, isTrue); |
| 198 }); | 186 }); |
| 199 }); | 187 }); |
| 200 } | 188 } |
| OLD | NEW |