| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 DocumentFragmentTest; | 5 library DocumentFragmentTest; |
| 6 import '../../pkg/unittest/lib/unittest.dart'; | 6 import '../../pkg/unittest/lib/unittest.dart'; |
| 7 import '../../pkg/unittest/lib/html_config.dart'; | 7 import '../../pkg/unittest/lib/html_config.dart'; |
| 8 import 'dart:html'; | 8 import 'dart:html'; |
| 9 part 'util.dart'; | 9 part 'util.dart'; |
| 10 | 10 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 try { | 31 try { |
| 32 fn(); | 32 fn(); |
| 33 } catch (e) { | 33 } catch (e) { |
| 34 if (e is UnsupportedError) { | 34 if (e is UnsupportedError) { |
| 35 return; | 35 return; |
| 36 } | 36 } |
| 37 } | 37 } |
| 38 expect(true, isFalse, reason: 'Expected immutability error'); | 38 expect(true, isFalse, reason: 'Expected immutability error'); |
| 39 }; | 39 }; |
| 40 | 40 |
| 41 void expectEmptyStyleDeclaration(CSSStyleDeclaration style) { | 41 void expectEmptyStyleDeclaration(CssStyleDeclaration style) { |
| 42 expect(style.cssText, equals('')); | 42 expect(style.cssText, equals('')); |
| 43 expect(style.getPropertyPriority('color'), equals('')); | 43 expect(style.getPropertyPriority('color'), equals('')); |
| 44 expect(style.item(0), equals('')); | 44 expect(style.item(0), equals('')); |
| 45 expect(style.length, isZero); | 45 expect(style.length, isZero); |
| 46 // TODO(jacobr): these checks throw UnimplementedErrors in dartium. | 46 // TODO(jacobr): these checks throw UnimplementedErrors in dartium. |
| 47 // expect(style.parentRule, isNull); | 47 // expect(style.parentRule, isNull); |
| 48 // expect(style.getPropertyCssValue('color'), isNull); | 48 // expect(style.getPropertyCssValue('color'), isNull); |
| 49 // expect(style.getPropertyShorthand('color'), isNull); | 49 // expect(style.getPropertyShorthand('color'), isNull); |
| 50 // expect(style.isPropertyImplicit('color'), isFalse); | 50 // expect(style.isPropertyImplicit('color'), isFalse); |
| 51 | 51 |
| 52 // Ideally these would throw errors, but it's not possible to create a class | 52 // Ideally these would throw errors, but it's not possible to create a class |
| 53 // that'll intercept these calls without implementing the entire | 53 // that'll intercept these calls without implementing the entire |
| 54 // CSSStyleDeclaration interface, so we'll settle for them being no-ops. | 54 // CssStyleDeclaration interface, so we'll settle for them being no-ops. |
| 55 style.cssText = '* {color: blue}'; | 55 style.cssText = '* {color: blue}'; |
| 56 style.removeProperty('color'); | 56 style.removeProperty('color'); |
| 57 style.setProperty('color', 'blue'); | 57 style.setProperty('color', 'blue'); |
| 58 } | 58 } |
| 59 | 59 |
| 60 group('constructors', () { | 60 group('constructors', () { |
| 61 test('0-argument makes an empty fragment', () { | 61 test('0-argument makes an empty fragment', () { |
| 62 final fragment = new DocumentFragment(); | 62 final fragment = new DocumentFragment(); |
| 63 expect(fragment.children, equals([])); | 63 expect(fragment.children, equals([])); |
| 64 }); | 64 }); |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 // // assertConstError(() => fragment.classes.add('foo')); | 344 // // assertConstError(() => fragment.classes.add('foo')); |
| 345 // }); | 345 // }); |
| 346 | 346 |
| 347 test('query searches the fragment', () { | 347 test('query searches the fragment', () { |
| 348 var fragment = new DocumentFragment.html( | 348 var fragment = new DocumentFragment.html( |
| 349 "<div class='foo'><a>foo</a><b>bar</b></div>"); | 349 "<div class='foo'><a>foo</a><b>bar</b></div>"); |
| 350 expect(fragment.query(".foo a").tagName, "A"); | 350 expect(fragment.query(".foo a").tagName, "A"); |
| 351 expect(_nodeStrings(fragment.queryAll(".foo *")), equals(["A", "B"])); | 351 expect(_nodeStrings(fragment.queryAll(".foo *")), equals(["A", "B"])); |
| 352 }); | 352 }); |
| 353 } | 353 } |
| OLD | NEW |