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 validator_test; | 5 library validator_test; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:html'; | 8 import 'dart:html'; |
9 import 'dart:svg' as svg; | 9 import 'dart:svg' as svg; |
10 import 'package:unittest/unittest.dart'; | 10 import 'package:unittest/unittest.dart'; |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 validator, | 333 validator, |
334 '<div template repeat="{{}}"></div>'); | 334 '<div template repeat="{{}}"></div>'); |
335 | 335 |
336 testHtml('blocks illegal template attribute', | 336 testHtml('blocks illegal template attribute', |
337 validator, | 337 validator, |
338 '<div template="foo" repeat="{{}}"></div>', | 338 '<div template="foo" repeat="{{}}"></div>', |
339 '<div></div>'); | 339 '<div></div>'); |
340 }); | 340 }); |
341 | 341 |
342 group('allowSvg', () { | 342 group('allowSvg', () { |
343 var validator = new NodeValidatorBuilder()..allowSvg(); | 343 var validator = new NodeValidatorBuilder() |
| 344 ..allowSvg() |
| 345 ..allowTextElements(); |
344 | 346 |
345 testHtml('allows basic SVG', | 347 testHtml('allows basic SVG', |
346 validator, | 348 validator, |
347 '<svg xmlns="http://www.w3.org/2000/svg' | 349 '<svg xmlns="http://www.w3.org/2000/svg' |
348 'xmlns:xlink="http://www.w3.org/1999/xlink">' | 350 'xmlns:xlink="http://www.w3.org/1999/xlink">' |
349 '<image xlink:href="foo" data-foo="bar"/>' | 351 '<image xlink:href="foo" data-foo="bar"/>' |
350 '</svg>'); | 352 '</svg>'); |
351 | 353 |
352 testHtml('blocks script elements', | 354 testHtml('blocks script elements', |
353 validator, | 355 validator, |
(...skipping 14 matching lines...) Expand all Loading... |
368 '</svg>'); | 370 '</svg>'); |
369 | 371 |
370 testHtml('blocks foreignObject content', | 372 testHtml('blocks foreignObject content', |
371 validator, | 373 validator, |
372 '<svg xmlns="http://www.w3.org/2000/svg">' | 374 '<svg xmlns="http://www.w3.org/2000/svg">' |
373 '<foreignobject width="100" height="150">' | 375 '<foreignobject width="100" height="150">' |
374 '<body xmlns="http://www.w3.org/1999/xhtml">' | 376 '<body xmlns="http://www.w3.org/1999/xhtml">' |
375 '<div>Some content</div>' | 377 '<div>Some content</div>' |
376 '</body>' | 378 '</body>' |
377 '</foreignobject>' | 379 '</foreignobject>' |
378 '<number>42</number>' | 380 '<b>42</b>' |
379 '</svg>', | 381 '</svg>', |
380 '<svg xmlns="http://www.w3.org/2000/svg">' | 382 '<svg xmlns="http://www.w3.org/2000/svg">' |
381 '<number>42</number>' | 383 '<b>42</b>' |
382 '</svg>'); | 384 '</svg>'); |
383 }); | 385 }); |
384 | 386 |
385 group('allowInlineStyles', () { | 387 group('allowInlineStyles', () { |
386 var validator = new NodeValidatorBuilder() | 388 var validator = new NodeValidatorBuilder() |
387 ..allowTextElements() | 389 ..allowTextElements() |
388 ..allowInlineStyles(); | 390 ..allowInlineStyles(); |
389 | 391 |
390 testHtml('allows inline styles', | 392 testHtml('allows inline styles', |
391 validator, | 393 validator, |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 '<image xlink:href="foo" data-foo="bar"/>' | 453 '<image xlink:href="foo" data-foo="bar"/>' |
452 '</svg>'; | 454 '</svg>'; |
453 | 455 |
454 var fragment = new DocumentFragment.svg(svgText); | 456 var fragment = new DocumentFragment.svg(svgText); |
455 var element = fragment.nodes.first; | 457 var element = fragment.nodes.first; |
456 expect(element is svg.SvgSvgElement, isTrue); | 458 expect(element is svg.SvgSvgElement, isTrue); |
457 expect(element.children[0] is svg.ImageElement, isTrue); | 459 expect(element.children[0] is svg.ImageElement, isTrue); |
458 }); | 460 }); |
459 }); | 461 }); |
460 } | 462 } |
OLD | NEW |