Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(101)

Side by Side Diff: packages/polymer/test/inject_bound_html_test.dart

Issue 2312183003: Removed Polymer from Observatory deps (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 import 'dart:async';
6 import 'dart:html';
7 import 'package:unittest/unittest.dart';
8 import 'package:unittest/html_config.dart';
9 import 'package:polymer/polymer.dart';
10
11 @CustomTag('x-foo')
12 class XFoo extends PolymerElement {
13 @observable String bar = "baz";
14
15 XFoo.created() : super.created();
16
17 @ComputedProperty('bar')
18 String get ignore => readValue(#bar);
19 }
20
21 class NullTreeSanitizer implements NodeTreeSanitizer {
22 const NullTreeSanitizer();
23 void sanitizeTree(Node node) {}
24 }
25 final nullSanitizer = const NullTreeSanitizer();
26
27 class NullNodeValidator implements NodeValidator {
28 const NullNodeValidator();
29 bool allowsAttribute(Element e, String a, String v) => true;
30 bool allowsElement(Element element) => true;
31 }
32 final nullValidator = const NullNodeValidator();
33
34 main() => initPolymer().then((zone) => zone.run(() {
35 useHtmlConfiguration();
36
37 XFoo xFoo;
38 DivElement injectDiv;
39
40 setUp(() => Polymer.onReady.then((_) {
41 xFoo = querySelector('x-foo');
42 injectDiv = xFoo.$['inject'];
43 }));
44
45 tearDown(() {
46 injectDiv.innerHtml = '';
47 });
48
49 test('can inject bound html fragments', () {
50 xFoo.injectBoundHtml('<span>{{bar}}</span>', element: injectDiv);
51 expect(injectDiv.innerHtml, '<span>baz</span>');
52
53 xFoo.bar = 'bat';
54 return new Future(() {}).then((_) {
55 expect(injectDiv.innerHtml, '<span>bat</span>');
56 });
57 });
58
59 test('custom sanitizer and validator', () {
60 var html = '<span style="color: black;"></span>';
61 var sanitizedHtml = '<span></span>';
62
63 // Expect it to sanitize by default.
64 xFoo.injectBoundHtml(html, element: injectDiv);
65 expect(injectDiv.innerHtml, sanitizedHtml);
66
67 // Don't sanitize if we give it a dummy validator
68 xFoo.injectBoundHtml(html, element: injectDiv, validator: nullValidator);
69 expect(injectDiv.innerHtml, html);
70
71 // Don't sanitize if we give it a dummy sanitizer
72 xFoo.injectBoundHtml(html,
73 element: injectDiv, treeSanitizer: nullSanitizer);
74 expect(injectDiv.innerHtml, html);
75 });
76 }));
OLDNEW
« no previous file with comments | « packages/polymer/test/import_test.html ('k') | packages/polymer/test/inject_bound_html_test.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698