| 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 document_register_basic_test; | 5 library document_register_basic_test; |
| 6 import 'package:unittest/unittest.dart'; | 6 import 'package:unittest/unittest.dart'; |
| 7 import 'package:unittest/html_config.dart'; | 7 import 'package:unittest/html_config.dart'; |
| 8 import 'dart:html'; | 8 import 'dart:html'; |
| 9 import '../utils.dart'; | 9 import '../utils.dart'; |
| 10 | 10 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 } | 30 } |
| 31 | 31 |
| 32 class BadB { | 32 class BadB { |
| 33 } | 33 } |
| 34 | 34 |
| 35 class BadE implements HtmlElement { | 35 class BadE implements HtmlElement { |
| 36 static final tag = 'x-tag-e'; | 36 static final tag = 'x-tag-e'; |
| 37 factory BadE() => new Element.tag(tag); | 37 factory BadE() => new Element.tag(tag); |
| 38 } | 38 } |
| 39 | 39 |
| 40 loadPolyfills() { |
| 41 if (!document.supportsRegister) { |
| 42 // Cache blocker is a workaround for: |
| 43 // https://code.google.com/p/dart/issues/detail?id=11834 |
| 44 var cacheBlocker = new DateTime.now().millisecondsSinceEpoch; |
| 45 return HttpRequest.getString('/root_dart/pkg/custom_element/lib/' |
| 46 'custom-elements.debug.js?cacheBlock=$cacheBlocker').then((code) { |
| 47 document.head.children.add(new ScriptElement()..text = code); |
| 48 }); |
| 49 } |
| 50 } |
| 51 |
| 40 main() { | 52 main() { |
| 41 useHtmlConfiguration(); | 53 useHtmlConfiguration(); |
| 42 | 54 |
| 43 // Adapted from Blink's fast/dom/custom/document-register-basic test. | 55 // Adapted from Blink's fast/dom/custom/document-register-basic test. |
| 44 | 56 |
| 45 setUp(loadPolyfills); | 57 setUp(loadPolyfills); |
| 46 | 58 |
| 47 test('Testing document.register() basic behaviors', () { | 59 test('Testing document.register() basic behaviors', () { |
| 48 document.register(Foo.tag, Foo); | 60 document.register(Foo.tag, Foo); |
| 49 | 61 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 expect(container.firstChild.tagName, "X-BAR"); | 141 expect(container.firstChild.tagName, "X-BAR"); |
| 130 expect(container.lastChild is Bar, isTrue); | 142 expect(container.lastChild is Bar, isTrue); |
| 131 expect(container.lastChild.tagName, "X-BAR"); | 143 expect(container.lastChild.tagName, "X-BAR"); |
| 132 | 144 |
| 133 // Constructors shouldn't interfere with each other | 145 // Constructors shouldn't interfere with each other |
| 134 expect((new Foo()).tagName, "X-FOO"); | 146 expect((new Foo()).tagName, "X-FOO"); |
| 135 expect((new Bar()).tagName, "X-BAR"); | 147 expect((new Bar()).tagName, "X-BAR"); |
| 136 expect((new Baz()).tagName, "X-BAZ"); | 148 expect((new Baz()).tagName, "X-BAZ"); |
| 137 }); | 149 }); |
| 138 } | 150 } |
| OLD | NEW |