Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 = new Range(); |
|
blois
2013/08/27 16:08:10
This test requires that the range be created from
Emily Fortuna
2013/08/27 22:48:43
fixed.
| |
| 74 range.selectNode(contextElement); | 74 range.selectNode(contextElement); |
| 75 return range.createContextualFragment(html); | 75 return range.createContextualFragment(html); |
| 76 } else { | 76 } else { |
| 77 contextElement.innerHtml = html; | 77 contextElement.innerHtml = 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 } |
| OLD | NEW |