Upstream version 9.38.198.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     console.log("%% self-escape1", "dummy");
31     console.log("%%s self-escape2", "dummy");
32     console.log("%%ss self-escape3", "dummy");
33     console.log("%%s%s%%s self-escape4", "dummy");
34     console.log("%%%%% self-escape5", "dummy");
35     console.log("%%%s self-escape6", "dummy");
36     
37     // Populate Globals
38     var regex1 = /^url\(\s*(?:(?:"(?:[^\\\"]|(?:\\[\da-f]{1,6}\s?|\.))*"|'(?:[^\\\']|(?:\\[\da-f]{1,6}\s?|\.))*')|(?:[!#$%&*-~\w]|(?:\\[\da-f]{1,6}\s?|\.))*)\s*\)/i;
39     var regex2 = new RegExp("foo\\\\bar\\sbaz", "i");
40     var str = "test";
41     var str2 = "test named \"test\"";
42     var error = new Error;
43     var errorWithMessage = new Error("my error message");
44     var node = document.getElementById("p");
45     var func = function() { return 1; };
46     var multilinefunc = function() {
47         return 2;
48     };
49     var num = 1.2e-1;
50     var linkify = "http://webkit.org/";
51     var valuelessAttribute = document.createAttribute("attr");
52     var valuedAttribute = document.createAttribute("attr");
53     valuedAttribute.value = "value";
54     var existingAttribute = document.getElementById("x").attributes[0];
55     var throwingLengthGetter = {get length() { throw "Length called"; }};
56     var objectWithNonEnumerables = Object.create({ foo: 1 }, {
57         getFoo: { value: function() { return this.foo; } },
58         bar: { get: function() { return this.bar; }, set: function(x) { this.bar = x; } }
59     });
60     var negZero = 1 / Number.NEGATIVE_INFINITY;
61
62     var arrayLikeFunction = function() {};
63     arrayLikeFunction.splice = function() {};
64
65     globals = [
66         regex1, regex2, str, str2, error, errorWithMessage, node, func, multilinefunc, num, linkify,
67         null, undefined, valuelessAttribute, valuedAttribute, existingAttribute, throwingLengthGetter,
68         NaN, Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY, array, {}, [function() {}], bar, svg,
69         objectWithNonEnumerables, negZero, Object.create(null), Object, Object.prototype, arrayLikeFunction,
70         new Number(42), new String("abc"), new  Uint16Array([1, 2, 3])
71     ];
72
73     runTest();
74 }
75
76 function test()
77 {
78     InspectorTest.hideInspectorView();
79     InspectorTest.evaluateInPage("globals.length", loopOverGlobals.bind(this, 0));
80
81     function loopOverGlobals(current, total)
82     {
83         function advance()
84         {
85             var next = current + 1;
86             if (next == total.description)
87                 InspectorTest.waitForRemoteObjectsConsoleMessages(onRemoteObjectsLoaded);
88             else
89                 loopOverGlobals(next, total);
90         }
91
92         function onRemoteObjectsLoaded()
93         {
94             InspectorTest.expandConsoleMessages(finish);
95         }
96
97         function finish()
98         {
99             InspectorTest.dumpConsoleMessages();
100             InspectorTest.completeTest();
101         }
102
103         InspectorTest.evaluateInPage("log(" + current + ")");
104         InspectorTest.runAfterPendingDispatches(evalInConsole);
105         function evalInConsole()
106         {
107             InspectorTest.evaluateInConsole("globals[" + current + "]");
108             InspectorTest.runAfterPendingDispatches(advance);
109         }
110     }
111 }
112 </script>
113 </head>
114
115 <body onload="onload()">
116 <div id="x"></div>
117 <p id="p">Tests that console logging dumps proper messages.</p>
118 </body>
119 <svg id="svg-node"></svg>
120 </html>