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

Unified Diff: tests/html/element_add_test.dart

Issue 1221043003: appendHtml, when sanitizing, should create document fragment in the right context (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: One more try. Suppress invalid co19 tests. Slight code cleanup. Created 5 years, 5 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 | « tests/co19/co19-dartium.status ('k') | tools/dom/templates/html/impl/impl_Element.darttemplate » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/html/element_add_test.dart
diff --git a/tests/html/element_add_test.dart b/tests/html/element_add_test.dart
index 8346129a208dffb189d23df7811fa685d80fe73c..2c2ea01890149b3d52fb73f1b08d71c81d1ab585 100644
--- a/tests/html/element_add_test.dart
+++ b/tests/html/element_add_test.dart
@@ -62,6 +62,35 @@ main() {
expect(fragment.children.length, equals(1));
expect(fragment.children[0], isSpanElement);
});
+
+ test('html interpreted in correct context', () {
+ // appendHtml, in order to sanitize, needs to create a document fragment,
+ // but it needs to be created in the right context. If we try to append
+ // table components then the document fragment needs the table context
+ // or it will fail to create them.
+ var el = new TableElement();
+ el.appendHtml('<tr><td>foo</td></tr>');
+ expect(el.children.length, 1);
+ var section = el.children.first;
+ expect(section is TableSectionElement, isTrue);
+ var row = section.children.first;
+ expect(row is TableRowElement, isTrue);
+ var item = row.children.first;
+ expect(item is TableCellElement, isTrue);
+ expect(item.innerHtml, 'foo');
+ });
+
+ test("use body context for elements that are don't support it", () {
+ // Some elements can't be used as context for createContextualFragment,
+ // often because it doesn't make any sense. So adding children to a
+ // <br> has no real effect on the page, but we can do it. But the
+ // document fragment will have to be created in the body context. Verify
+ // that this doesn't throw and that the children show up.
+ var el = new BRElement();
+ el.appendHtml("<p>Stuff</p>");
+ expect(el.children.length, 1);
+ expect(el.children[0].outerHtml, "<p>Stuff</p>");
+ });
});
group('appendText', () {
« no previous file with comments | « tests/co19/co19-dartium.status ('k') | tools/dom/templates/html/impl/impl_Element.darttemplate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698