Upstream version 5.34.104.0
[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     globals = [
56         regex1, regex2, str, str2, error, errorWithMessage, node, func, multilinefunc, num, linkify,
57         null, undefined, valuelessAttribute, valuedAttribute, existingAttribute, throwingLengthGetter,
58         NaN, Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY, array, {}, [function() {}], bar, svg,
59         objectWithNonEnumerables, negZero, Object.create(null), Object, Object.prototype
60     ];
61
62     runTest();
63 }
64
65 function test()
66 {
67     InspectorTest.evaluateInPage("globals.length", loopOverGlobals.bind(this, 0));
68
69     function loopOverGlobals(current, total)
70     {
71         function advance()
72         {
73             var next = current + 1;
74             if (next == total.description) {
75                 InspectorTest.expandConsoleMessages();
76                 InspectorTest.runAfterPendingDispatches(finish);
77             } else {
78                 loopOverGlobals(next, total);
79             }
80         }
81
82         function finish()
83         {
84             InspectorTest.dumpConsoleMessages();
85             InspectorTest.completeTest();
86         }
87
88         InspectorTest.evaluateInPage("log(" + current + ")");
89         InspectorTest.runAfterPendingDispatches(evalInConsole);
90         function evalInConsole()
91         {
92             InspectorTest.evaluateInConsole("globals[" + current + "]");
93             InspectorTest.runAfterPendingDispatches(advance);
94         }
95     }
96 }
97 </script>
98 </head>
99
100 <body onload="onload()">
101 <div id="x"></div>
102 <p id="p">Tests that console logging dumps proper messages.</p>
103 </body>
104 <svg id="svg-node"></svg>
105 </html>