e50f80776d9db7d81888240fee7d82640cc1ff95
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / inspector / console / console-format.html
1 <html>
2 <head>
3 <script src="../../http/tests/inspector/inspector-test.js"></script>
4 <script src="../../http/tests/inspector/console-test.js"></script>
5 <script>
6
7 // Global Values
8 var globals = [];
9
10 function log(current)
11 {
12     console.log(globals[current]);
13     console.log([globals[current]]);
14 }
15
16 function onload()
17 {
18     var foo = { foo: "foo"};
19     var bar = { bar: "bar" };
20     bar.__proto__ = foo;
21     var array = ["test", "test2"]; array.length = 10;
22     array.foo = {}; 
23     array[4] = "test4";
24
25     var svg = document.getElementById("svg-node");
26     console.log(array);
27     console.log("%o", array);
28     console.log("%O", array);
29     console.log("Test for zero \"%f\" in formatter", 0);
30     // Populate Globals
31     var regex1 = /^url\(\s*(?:(?:"(?:[^\\\"]|(?:\\[\da-f]{1,6}\s?|\.))*"|'(?:[^\\\']|(?:\\[\da-f]{1,6}\s?|\.))*')|(?:[!#$%&*-~\w]|(?:\\[\da-f]{1,6}\s?|\.))*)\s*\)/i;
32     var regex2 = new RegExp("foo\\\\bar\\sbaz", "i");
33     var str = "test";
34     var str2 = "test named \"test\"";
35     var error = new Error;
36     var errorWithMessage = new Error("my error message");
37     var node = document.getElementById("p");
38     var func = function() { return 1; };
39     var multilinefunc = function() {
40         return 2;
41     };
42     var num = 1.2e-1;
43     var linkify = "http://webkit.org/";
44     var valuelessAttribute = document.createAttribute("attr");
45     var valuedAttribute = document.createAttribute("attr");
46     valuedAttribute.value = "value";
47     var existingAttribute = document.getElementById("x").attributes[0];
48     var throwingLengthGetter = {get length() { throw "Length called"; }};
49     var objectWithNonEnumerables = Object.create({ foo: 1 }, {
50         getFoo: { value: function() { return this.foo; } },
51         bar: { get: function() { return this.bar; }, set: function(x) { this.bar = x; } }
52     });
53     var negZero = 1 / Number.NEGATIVE_INFINITY;
54
55     var arrayLikeFunction = function() {};
56     arrayLikeFunction.splice = function() {};
57
58     globals = [
59         regex1, regex2, str, str2, error, errorWithMessage, node, func, multilinefunc, num, linkify,
60         null, undefined, valuelessAttribute, valuedAttribute, existingAttribute, throwingLengthGetter,
61         NaN, Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY, array, {}, [function() {}], bar, svg,
62         objectWithNonEnumerables, negZero, Object.create(null), Object, Object.prototype, arrayLikeFunction
63     ];
64
65     runTest();
66 }
67
68 function test()
69 {
70     InspectorTest.evaluateInPage("globals.length", loopOverGlobals.bind(this, 0));
71
72     function loopOverGlobals(current, total)
73     {
74         function advance()
75         {
76             var next = current + 1;
77             if (next == total.description) {
78                 InspectorTest.expandConsoleMessages();
79                 InspectorTest.runAfterPendingDispatches(finish);
80             } else {
81                 loopOverGlobals(next, total);
82             }
83         }
84
85         function finish()
86         {
87             InspectorTest.dumpConsoleMessages();
88             InspectorTest.completeTest();
89         }
90
91         InspectorTest.evaluateInPage("log(" + current + ")");
92         InspectorTest.runAfterPendingDispatches(evalInConsole);
93         function evalInConsole()
94         {
95             InspectorTest.evaluateInConsole("globals[" + current + "]");
96             InspectorTest.runAfterPendingDispatches(advance);
97         }
98     }
99 }
100 </script>
101 </head>
102
103 <body onload="onload()">
104 <div id="x"></div>
105 <p id="p">Tests that console logging dumps proper messages.</p>
106 </body>
107 <svg id="svg-node"></svg>
108 </html>