Chromium Code Reviews| 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_element.test.custom_element_test; | 5 library custom_element.test.custom_element_test; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:html'; | 8 import 'dart:html'; |
| 9 import 'package:custom_element/custom_element.dart'; | 9 import 'package:custom_element/custom_element.dart'; |
| 10 import 'package:unittest/html_config.dart'; | 10 import 'package:unittest/html_config.dart'; |
| 11 import 'package:unittest/unittest.dart'; | 11 import 'package:unittest/unittest.dart'; |
| 12 | 12 |
| 13 main() { | 13 main() { |
| 14 useHtmlConfiguration(); | 14 useHtmlConfiguration(); |
| 15 | 15 |
| 16 // Load the MutationObserver polyfill. | |
| 17 HttpRequest.getString('/root_dart/pkg/mutation_observer/lib/' | |
| 18 'mutation_observer.js').then((code) { | |
| 19 document.head.children.add(new ScriptElement()..text = code); | |
|
blois
2013/07/30 17:11:09
Is this test run under CSP? If so, does it need an
Jennifer Messerly
2013/07/30 18:05:20
I think it will be okay because Chrome is the only
| |
| 20 | |
| 21 customElementTests(); | |
| 22 }); | |
| 23 } | |
| 24 | |
| 25 customElementTests() { | |
| 16 test('register creates the element and calls lifecycle methods', () { | 26 test('register creates the element and calls lifecycle methods', () { |
| 17 // Add element to the page. | 27 // Add element to the page. |
| 18 var element = new Element.html('<fancy-button>foo bar</fancy-button>'); | 28 var element = new Element.html('<fancy-button>foo bar</fancy-button>'); |
| 19 document.body.nodes.add(element); | 29 document.body.nodes.add(element); |
| 20 | 30 |
| 21 var xtag = null; | 31 var xtag = null; |
| 22 registerCustomElement('fancy-button', () => xtag = new FancyButton()); | 32 registerCustomElement('fancy-button', () => xtag = new FancyButton()); |
| 23 expect(xtag, isNotNull, reason: 'FancyButton was created'); | 33 expect(xtag, isNotNull, reason: 'FancyButton was created'); |
| 24 expect(element.xtag, xtag, reason: 'xtag pointer should be set'); | 34 expect(element.xtag, xtag, reason: 'xtag pointer should be set'); |
| 25 expect(xtag.host, element, reason: 'host pointer should be set'); | 35 expect(xtag.host, element, reason: 'host pointer should be set'); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 71 } | 81 } |
| 72 inserted() { | 82 inserted() { |
| 73 super.inserted(); | 83 super.inserted(); |
| 74 lifecycle.add('inserted'); | 84 lifecycle.add('inserted'); |
| 75 } | 85 } |
| 76 removed() { | 86 removed() { |
| 77 super.removed(); | 87 super.removed(); |
| 78 lifecycle.add('removed'); | 88 lifecycle.add('removed'); |
| 79 } | 89 } |
| 80 } | 90 } |
| OLD | NEW |