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

Unified Diff: packages/polymer/test/inject_bound_html_test.dart

Issue 1400473008: Roll Observatory packages and add a roll script (Closed) Base URL: git@github.com:dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years, 2 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: packages/polymer/test/inject_bound_html_test.dart
diff --git a/packages/polymer/test/inject_bound_html_test.dart b/packages/polymer/test/inject_bound_html_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..2f8910e5a87143e852e55f84bd049e300a419098
--- /dev/null
+++ b/packages/polymer/test/inject_bound_html_test.dart
@@ -0,0 +1,76 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'dart:async';
+import 'dart:html';
+import 'package:unittest/unittest.dart';
+import 'package:unittest/html_config.dart';
+import 'package:polymer/polymer.dart';
+
+@CustomTag('x-foo')
+class XFoo extends PolymerElement {
+ @observable String bar = "baz";
+
+ XFoo.created() : super.created();
+
+ @ComputedProperty('bar')
+ String get ignore => readValue(#bar);
+}
+
+class NullTreeSanitizer implements NodeTreeSanitizer {
+ const NullTreeSanitizer();
+ void sanitizeTree(Node node) {}
+}
+final nullSanitizer = const NullTreeSanitizer();
+
+class NullNodeValidator implements NodeValidator {
+ const NullNodeValidator();
+ bool allowsAttribute(Element e, String a, String v) => true;
+ bool allowsElement(Element element) => true;
+}
+final nullValidator = const NullNodeValidator();
+
+main() => initPolymer().then((zone) => zone.run(() {
+ useHtmlConfiguration();
+
+ XFoo xFoo;
+ DivElement injectDiv;
+
+ setUp(() => Polymer.onReady.then((_) {
+ xFoo = querySelector('x-foo');
+ injectDiv = xFoo.$['inject'];
+ }));
+
+ tearDown(() {
+ injectDiv.innerHtml = '';
+ });
+
+ test('can inject bound html fragments', () {
+ xFoo.injectBoundHtml('<span>{{bar}}</span>', element: injectDiv);
+ expect(injectDiv.innerHtml, '<span>baz</span>');
+
+ xFoo.bar = 'bat';
+ return new Future(() {}).then((_) {
+ expect(injectDiv.innerHtml, '<span>bat</span>');
+ });
+ });
+
+ test('custom sanitizer and validator', () {
+ var html = '<span style="color: black;"></span>';
+ var sanitizedHtml = '<span></span>';
+
+ // Expect it to sanitize by default.
+ xFoo.injectBoundHtml(html, element: injectDiv);
+ expect(injectDiv.innerHtml, sanitizedHtml);
+
+ // Don't sanitize if we give it a dummy validator
+ xFoo.injectBoundHtml(html, element: injectDiv, validator: nullValidator);
+ expect(injectDiv.innerHtml, html);
+
+ // Don't sanitize if we give it a dummy sanitizer
+ xFoo.injectBoundHtml(html,
+ element: injectDiv, treeSanitizer: nullSanitizer);
+ expect(injectDiv.innerHtml, html);
+ });
+}));
« 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