| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <title>parseHtmlSubset test</title> | 4 <title>parseHtmlSubset test</title> |
| 5 <script src="http://closure-library.googlecode.com/svn/trunk/closure/goog/base.j
s"></script> | 5 <script src="webui_resource_test.js"></script> |
| 6 <script src="parse_html_subset.js"></script> | |
| 7 <script> | |
| 8 | |
| 9 goog.require('goog.testing.AsyncTestCase'); | |
| 10 goog.require('goog.testing.jsunit'); | |
| 11 | |
| 12 </script> | |
| 13 | |
| 14 </head> | 6 </head> |
| 15 <body> | 7 <body> |
| 16 <script> | 8 <script> |
| 17 | 9 |
| 18 var asyncTestCase = goog.testing.AsyncTestCase.createAndInstall(); | |
| 19 | |
| 20 function parseAndAssertThrows() { | 10 function parseAndAssertThrows() { |
| 21 var args = arguments; | 11 var args = arguments; |
| 22 assertThrows(function() { | 12 assertThrows(function() { |
| 23 parseHtmlSubset.apply(null, args); | 13 parseHtmlSubset.apply(null, args); |
| 24 }); | 14 }); |
| 25 } | 15 } |
| 26 | 16 |
| 27 function parseAndAssertNotThrows() { | 17 function parseAndAssertNotThrows() { |
| 28 var args = arguments; | 18 var args = arguments; |
| 29 assertNotThrows(function() { | 19 parseHtmlSubset.apply(null, args); |
| 30 parseHtmlSubset.apply(null, args); | |
| 31 }); | |
| 32 } | 20 } |
| 33 | 21 |
| 34 function testText() { | 22 function testText() { |
| 35 parseAndAssertNotThrows(''); | 23 parseAndAssertNotThrows(''); |
| 36 parseAndAssertNotThrows('abc'); | 24 parseAndAssertNotThrows('abc'); |
| 37 parseAndAssertNotThrows(' '); | 25 parseAndAssertNotThrows(' '); |
| 38 } | 26 } |
| 39 | 27 |
| 40 function testSupportedTags() { | 28 function testSupportedTags() { |
| 41 parseAndAssertNotThrows('<b>bold</b>'); | 29 parseAndAssertNotThrows('<b>bold</b>'); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 | 94 |
| 107 function testInvalidCustomAttributes() { | 95 function testInvalidCustomAttributes() { |
| 108 function returnsFalsey() { | 96 function returnsFalsey() { |
| 109 return false; | 97 return false; |
| 110 } | 98 } |
| 111 parseAndAssertThrows('<a class="fancy">I\'m fancy!</a>', null, | 99 parseAndAssertThrows('<a class="fancy">I\'m fancy!</a>', null, |
| 112 {class: returnsFalsey}); | 100 {class: returnsFalsey}); |
| 113 parseAndAssertThrows('<a class="fancy">I\'m fancy!</a>'); | 101 parseAndAssertThrows('<a class="fancy">I\'m fancy!</a>'); |
| 114 } | 102 } |
| 115 | 103 |
| 116 function testOnError() { | 104 function testOnErrorAsync(testDoneCalback) { |
| 117 window.called = false; | 105 window.called = false; |
| 118 | 106 |
| 119 asyncTestCase.waitForAsync('Waiting for image error callbacks'); | |
| 120 | |
| 121 parseAndAssertThrows('<img onerror="window.called = true" src="_.png">'); | 107 parseAndAssertThrows('<img onerror="window.called = true" src="_.png">'); |
| 122 parseAndAssertThrows('<img src="_.png" onerror="window.called = true">'); | 108 parseAndAssertThrows('<img src="_.png" onerror="window.called = true">'); |
| 123 | 109 |
| 124 window.setTimeout(function() { | 110 window.setTimeout(function() { |
| 125 asyncTestCase.continueTesting(); | |
| 126 assertFalse(window.called); | 111 assertFalse(window.called); |
| 112 testDoneCalback(); |
| 127 }); | 113 }); |
| 128 } | 114 } |
| 129 | 115 |
| 130 </script> | 116 </script> |
| 131 | 117 |
| 132 </body> | 118 </body> |
| 133 </html> | 119 </html> |
| OLD | NEW |