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

Unified Diff: content/test/data/tree_parser_util_unittest.html

Issue 1264923002: Introduce cross_site_iframe_factory.html, and use it in a test (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Self-review fixes. 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
Index: content/test/data/tree_parser_util_unittest.html
diff --git a/content/test/data/tree_parser_util_unittest.html b/content/test/data/tree_parser_util_unittest.html
new file mode 100644
index 0000000000000000000000000000000000000000..ae540929abca1113f41cfc9ccb425fc434cbb858
--- /dev/null
+++ b/content/test/data/tree_parser_util_unittest.html
@@ -0,0 +1,70 @@
+<html><body>
dcheng 2015/08/04 00:14:41 Is this run automatically somewhere, or is this es
ncarter (slow) 2015/08/04 23:51:21 It's run manually. I couldn't quite bring myself t
ncarter (slow) 2015/08/05 16:43:13 I went ahead and just removed this file.
+This page contains unittests for tree_parser_util.js
+<script src='tree_parser_util.js'></script>
+
+<pre><code id='output'></code></pre>
+<script>
+var resultLog = document.getElementById('output');
+function assert(op, input, expectedResult) {
+ var expectedText = JSON.stringify(expectedResult);
+
+ try {
+ var output = TreeParserUtil[op](input);
+ } catch (e) {
+ var output = e.toString();
+ }
+ var actualText = JSON.stringify(output);
+
+ if (actualText != expectedText) {
+ resultLog.appendChild(document.createTextNode(
+ 'FAILURE! during op TreeParserUtil.' + op + '\n' +
+ ' INPUT: ' + JSON.stringify(input) + '\n' +
+ ' ACTUAL: ' + actualText + '\n' +
+ 'EXPECTED: ' + expectedText + '\n\n'));
+ }
+}
+
+assert('_lex', ' ', []);
+assert('_lex', ' ) (', [')', '(']);
+assert('_lex', ' ) ab cd((', [')', 'ab', 'cd', '(', '(']);
+assert('_lex', 'a.com (y.com ( ) , x.org, z (c.org, z.com (a, d.net())))',
+ ['a.com', '(', 'y.com', '(', ')', ',', 'x.org', ',', 'z', '(', 'c.org',
+ ',', 'z.com', '(', 'a', ',', 'd.net', '(', ')', ')', ')', ')']);
+assert('parse', 'a.com (y.com (k) , x.org, z.net (c.org, z.com (a, d.net())))',
+ { "value": "a.com", "children": [
+ { "value": "y.com", "children": [
+ { "value": "k", "children": [] }
+ ]},
+ { "value": "x.org", "children": [] },
+ { "value": "z.net", "children": [
+ { "value": "c.org", "children": [] },
+ { "value": "z.com", "children": [
+ { "value": "a", "children": [] },
+ { "value": "d.net", "children": [] }
+ ]}
+ ]}
+ ]});
+assert('parse', '()', 'Error: Expected an identifier, but found "(".')
+assert('parse', ')', 'Error: Expected an identifier, but found ")".')
+assert('parse', '/', 'Error: Expected an identifier, but found "/".')
+assert('parse', '', 'Error: Expected an identifier, but found end-of-stream.')
+assert('parse', 'a)', 'Error: Expected end of stream, but found ")".')
+assert('parse', 'a.com ()', { "value": "a.com", "children": []});
+assert('parse', 'a.com', { "value": "a.com", "children": []});
+assert('parse', 'a.com wtf',
+ 'Error: Expected end of stream, but found "wtf".');
+assert('parse', 'a.com () wtf',
+ 'Error: Expected end of stream, but found "wtf".');
+assert('flatten',
+ { "value": "y.com", "children": [
+ { "value": "k", "children": [] },
+ { "value": "j", "children": [] }
+ ]},
+ 'y.com(k(),j())');
+assert('flatten', { "value": "zz", "children": [] }, 'zz()');
+
+if (resultLog.children.length == 0) {
+ resultLog.appendChild(document.createTextNode("All tests passed!"));
+}
+</script>
+</body>
dcheng 2015/08/04 00:14:41 </html>
« content/test/data/tree_parser_util.js ('K') | « content/test/data/tree_parser_util.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698