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

Side by Side Diff: tests/html/safe_dom_test.dart

Issue 24084004: Exposing document.createElement (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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 | Annotate | Revision Log
OLDNEW
1 library safe_dom_test; 1 library safe_dom_test;
2 2
3 import 'dart:async'; 3 import 'dart:async';
4 import 'dart:html'; 4 import 'dart:html';
5 import '../../pkg/unittest/lib/unittest.dart'; 5 import '../../pkg/unittest/lib/unittest.dart';
6 import '../../pkg/unittest/lib/html_config.dart'; 6 import '../../pkg/unittest/lib/html_config.dart';
7 7
8 main() { 8 main() {
9 useHtmlConfiguration(); 9 useHtmlConfiguration();
10 10
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 expect(div.nodes.length, 1); 57 expect(div.nodes.length, 1);
58 expect(div.nodes[0] is SpanElement, isTrue); 58 expect(div.nodes[0] is SpanElement, isTrue);
59 }); 59 });
60 } 60 }
61 61
62 DocumentFragment createContextualFragment(String html, [String contextTag]) { 62 DocumentFragment createContextualFragment(String html, [String contextTag]) {
63 var doc = document.implementation.createHtmlDocument(''); 63 var doc = document.implementation.createHtmlDocument('');
64 64
65 var contextElement; 65 var contextElement;
66 if (contextTag != null) { 66 if (contextTag != null) {
67 contextElement = doc.$dom_createElement(contextTag); 67 contextElement = doc.createElement(contextTag);
68 } else { 68 } else {
69 contextElement = doc.body; 69 contextElement = doc.body;
70 } 70 }
71 71
72 if (Range.supportsCreateContextualFragment) { 72 if (Range.supportsCreateContextualFragment) {
73 var range = doc.createRange(); 73 var range = doc.createRange();
74 range.selectNode(contextElement); 74 range.selectNode(contextElement);
75 return range.createContextualFragment(html); 75 return range.createContextualFragment(html);
76 } else { 76 } else {
77 contextElement.unsafeInnerHtml = html; 77 contextElement.unsafeInnerHtml = html;
(...skipping 11 matching lines...) Expand all
89 Future<bool> isSafe() { 89 Future<bool> isSafe() {
90 return new Future.delayed(imageLoadDelay).then((_) { 90 return new Future.delayed(imageLoadDelay).then((_) {
91 window.postMessage('check_unsafe', '*'); 91 window.postMessage('check_unsafe', '*');
92 }).then((_) { 92 }).then((_) {
93 return window.onMessage.where( 93 return window.onMessage.where(
94 (e) => e.data.startsWith('unsafe_check')).first; 94 (e) => e.data.startsWith('unsafe_check')).first;
95 }).then((e) { 95 }).then((e) {
96 return e.data == 'unsafe_check_passed'; 96 return e.data == 'unsafe_check_passed';
97 }); 97 });
98 } 98 }
OLDNEW
« no previous file with comments | « tests/html/custom/document_register_type_extensions_test.dart ('k') | tools/dom/scripts/htmldartgenerator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698