| 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 | |
| 52 main() { | 40 main() { |
| 53 useHtmlConfiguration(); | 41 useHtmlConfiguration(); |
| 54 | 42 |
| 55 // Adapted from Blink's fast/dom/custom/document-register-basic test. | 43 // Adapted from Blink's fast/dom/custom/document-register-basic test. |
| 56 | 44 |
| 57 setUp(loadPolyfills); | 45 setUp(loadPolyfills); |
| 58 | 46 |
| 59 test('Testing document.register() basic behaviors', () { | 47 test('Testing document.register() basic behaviors', () { |
| 60 document.register(Foo.tag, Foo); | 48 document.register(Foo.tag, Foo); |
| 61 | 49 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 expect(container.firstChild.tagName, "X-BAR"); | 129 expect(container.firstChild.tagName, "X-BAR"); |
| 142 expect(container.lastChild is Bar, isTrue); | 130 expect(container.lastChild is Bar, isTrue); |
| 143 expect(container.lastChild.tagName, "X-BAR"); | 131 expect(container.lastChild.tagName, "X-BAR"); |
| 144 | 132 |
| 145 // Constructors shouldn't interfere with each other | 133 // Constructors shouldn't interfere with each other |
| 146 expect((new Foo()).tagName, "X-FOO"); | 134 expect((new Foo()).tagName, "X-FOO"); |
| 147 expect((new Bar()).tagName, "X-BAR"); | 135 expect((new Bar()).tagName, "X-BAR"); |
| 148 expect((new Baz()).tagName, "X-BAZ"); | 136 expect((new Baz()).tagName, "X-BAZ"); |
| 149 }); | 137 }); |
| 150 } | 138 } |
| OLD | NEW |