Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / inspector / json-balanced-tokenizer.html
blob90a290e393a796276c57faab974895887d6feef5
1 <html>
2 <head>
3 <script src="../http/tests/inspector/inspector-test.js"></script>
5 <script>
6 function test()
8 InspectorTest.runTestSuite([
9 function testMatchQuotes(next)
11 var testStrings = [
12 {"odd back slashes with text around":"tes\\\"t"},
13 {"escaped double quotes":"\"test\""},
14 {"escaped back slash before double quote":"test\\"},
15 {1:2},
16 {"":""},
17 {"nested brackets":{}},
18 {"nested brackets with double quotes":{"":""}},
19 {"etc":{"\\":"\""}},
20 {"etc":{"\\\\":"\\"}},
21 {"etc":{"\\\\\"":"\\\\\""}}
24 for (var i = 0; i < testStrings.length; ++i) {
25 var string = JSON.stringify(testStrings[i]);
26 InspectorTest.addResult("\nParsing " + string);
27 var tokenizer = new WebInspector.TextUtils.BalancedJSONTokenizer(InspectorTest.addResult.bind(InspectorTest));
28 tokenizer.write(string);
30 next();
33 function testMatchSequenceUsingOneShot(next)
35 var testData = [
36 {"one":"one"},
37 [{"one":"one"}, {"two":"two"}],
38 [{"one":"one"}, {"two":"two"}, {"three":"three"}],
41 for (var i = 0; i < testData.length; ++i) {
42 var string = JSON.stringify(testData[i]);
43 InspectorTest.addResult("\nParsing " + string);
44 var tokenizer = new WebInspector.TextUtils.BalancedJSONTokenizer(InspectorTest.addResult.bind(InspectorTest));
45 tokenizer.write(string);
47 next();
50 function testMatchSequenceUsingMultiple(next)
52 var testData = [
53 {"one":"one"},
54 [{"one":"one"}, {"two":"two"}],
55 [{"one":"one"}, {"two":"two"}, {"three":"three"}],
58 for (var i = 0; i < testData.length; ++i) {
59 var string = JSON.stringify(testData[i]);
60 InspectorTest.addResult("\nParsing " + string);
61 var tokenizer = new WebInspector.TextUtils.BalancedJSONTokenizer(InspectorTest.addResult.bind(InspectorTest), true);
62 tokenizer.write(string);
64 next();
67 function testIncrementalWrites(next)
69 var testStrings = [
70 {"odd back slashes with text around":"tes\\\"t"},
71 {"escaped double quotes":"\"test\""},
72 {"escaped back slash before double quote":"test\\"},
73 {1:2},
74 {"":""},
75 {"nested brackets":{}},
76 {"nested brackets with double quotes":{"":""}},
77 {"etc":{"\\":"\""}},
78 {"etc":{"\\\\":"\\"}},
79 {"etc":{"\\\\\"":"\\\\\""}}
81 var string = JSON.stringify(testStrings);
82 var tokenizer = new WebInspector.TextUtils.BalancedJSONTokenizer(InspectorTest.addResult.bind(InspectorTest), true);
83 InspectorTest.addResult("\nRunning at once:");
84 tokenizer.write(string);
86 for (var sample of [3, 15, 50]) {
87 tokenizer = new WebInspector.TextUtils.BalancedJSONTokenizer(InspectorTest.addResult.bind(InspectorTest), true);
88 InspectorTest.addResult("\nRunning by " + sample + ":");
89 for (var i = 0; i < string.length; i += sample)
90 tokenizer.write(string.substring(i, i + sample));
92 next();
94 ]);
96 </script>
98 <body onload="runTest()">
99 Test WebInspector.TextUtils.BalancedJSONTokenizer.
100 </p>
101 </body>
102 </html>