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

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

Issue 23534024: createRange.... (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
« no previous file with comments | « sdk/lib/html/dartium/html_dartium.dart ('k') | tools/dom/scripts/htmlrenamer.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
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.$dom_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.$dom_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;
78 var fragment = new DocumentFragment();; 78 var fragment = new DocumentFragment();;
79 while (contextElement.firstChild != null) { 79 while (contextElement.firstChild != null) {
80 fragment.append(contextElement.firstChild); 80 fragment.append(contextElement.firstChild);
81 } 81 }
82 return fragment; 82 return fragment;
83 } 83 }
84 } 84 }
85 85
86 // Delay to wait for the image load to fail. 86 // Delay to wait for the image load to fail.
87 const Duration imageLoadDelay = const Duration(milliseconds: 500); 87 const Duration imageLoadDelay = const Duration(milliseconds: 500);
88 88
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 | « sdk/lib/html/dartium/html_dartium.dart ('k') | tools/dom/scripts/htmlrenamer.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698