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

Side by Side 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, 4 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
OLDNEW
(Empty)
1 <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.
2 This page contains unittests for tree_parser_util.js
3 <script src='tree_parser_util.js'></script>
4
5 <pre><code id='output'></code></pre>
6 <script>
7 var resultLog = document.getElementById('output');
8 function assert(op, input, expectedResult) {
9 var expectedText = JSON.stringify(expectedResult);
10
11 try {
12 var output = TreeParserUtil[op](input);
13 } catch (e) {
14 var output = e.toString();
15 }
16 var actualText = JSON.stringify(output);
17
18 if (actualText != expectedText) {
19 resultLog.appendChild(document.createTextNode(
20 'FAILURE! during op TreeParserUtil.' + op + '\n' +
21 ' INPUT: ' + JSON.stringify(input) + '\n' +
22 ' ACTUAL: ' + actualText + '\n' +
23 'EXPECTED: ' + expectedText + '\n\n'));
24 }
25 }
26
27 assert('_lex', ' ', []);
28 assert('_lex', ' ) (', [')', '(']);
29 assert('_lex', ' ) ab cd((', [')', 'ab', 'cd', '(', '(']);
30 assert('_lex', 'a.com (y.com ( ) , x.org, z (c.org, z.com (a, d.net())))',
31 ['a.com', '(', 'y.com', '(', ')', ',', 'x.org', ',', 'z', '(', 'c.org',
32 ',', 'z.com', '(', 'a', ',', 'd.net', '(', ')', ')', ')', ')']);
33 assert('parse', 'a.com (y.com (k) , x.org, z.net (c.org, z.com (a, d.net())))',
34 { "value": "a.com", "children": [
35 { "value": "y.com", "children": [
36 { "value": "k", "children": [] }
37 ]},
38 { "value": "x.org", "children": [] },
39 { "value": "z.net", "children": [
40 { "value": "c.org", "children": [] },
41 { "value": "z.com", "children": [
42 { "value": "a", "children": [] },
43 { "value": "d.net", "children": [] }
44 ]}
45 ]}
46 ]});
47 assert('parse', '()', 'Error: Expected an identifier, but found "(".')
48 assert('parse', ')', 'Error: Expected an identifier, but found ")".')
49 assert('parse', '/', 'Error: Expected an identifier, but found "/".')
50 assert('parse', '', 'Error: Expected an identifier, but found end-of-stream.')
51 assert('parse', 'a)', 'Error: Expected end of stream, but found ")".')
52 assert('parse', 'a.com ()', { "value": "a.com", "children": []});
53 assert('parse', 'a.com', { "value": "a.com", "children": []});
54 assert('parse', 'a.com wtf',
55 'Error: Expected end of stream, but found "wtf".');
56 assert('parse', 'a.com () wtf',
57 'Error: Expected end of stream, but found "wtf".');
58 assert('flatten',
59 { "value": "y.com", "children": [
60 { "value": "k", "children": [] },
61 { "value": "j", "children": [] }
62 ]},
63 'y.com(k(),j())');
64 assert('flatten', { "value": "zz", "children": [] }, 'zz()');
65
66 if (resultLog.children.length == 0) {
67 resultLog.appendChild(document.createTextNode("All tests passed!"));
68 }
69 </script>
70 </body>
dcheng 2015/08/04 00:14:41 </html>
OLDNEW
« 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