| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 library SVGTest; | |
| 6 import '../../pkg/unittest/lib/unittest.dart'; | |
| 7 import '../../pkg/unittest/lib/html_config.dart'; | |
| 8 import 'dart:svg'; | |
| 9 | |
| 10 main() { | |
| 11 useHtmlConfiguration(); | |
| 12 | |
| 13 test('svg parsed attributes', () { | |
| 14 var content = """ | |
| 15 <svg version="1.1" | |
| 16 xmlns:xlink="http://www.w3.org/1999/xlink"> | |
| 17 <image xlink:href="foo.jpg"/> | |
| 18 </svg>"""; | |
| 19 | |
| 20 var svg = new SvgElement.svg(content); | |
| 21 var img = svg.children[0]; | |
| 22 expect(img is ImageElement, isTrue); | |
| 23 var attrs = img.attributes; | |
| 24 expect(attrs.length, 0); | |
| 25 | |
| 26 var xlinkAttrs = | |
| 27 img.getNamespacedAttributes('http://www.w3.org/1999/xlink'); | |
| 28 expect(xlinkAttrs.length, 1); | |
| 29 expect(xlinkAttrs['href'], 'foo.jpg'); | |
| 30 | |
| 31 // validate that the namespaced attr was set by waiting for the image | |
| 32 // to fail to load. | |
| 33 return img.onError.first; | |
| 34 }); | |
| 35 | |
| 36 test('svg explicit attributes', () { | |
| 37 | |
| 38 var img = new ImageElement(); | |
| 39 var xlinkAttrs = | |
| 40 img.getNamespacedAttributes('http://www.w3.org/1999/xlink'); | |
| 41 xlinkAttrs['href'] = 'foo.jpg'; | |
| 42 | |
| 43 // validate that the namespaced attr was set by waiting for the image | |
| 44 // to fail to load. | |
| 45 return img.onError.first; | |
| 46 }); | |
| 47 } | |
| OLD | NEW |