Upstream version 11.40.271.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / inspector / sources / debugger / debugger-save-to-temp-var.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 src="../../../http/tests/inspector/debugger-test.js"></script>
6 <script>
7
8 var thisObj;
9
10 function testFunction()
11 {
12     function inner()
13     {
14         debugger;
15     }
16
17     thisObj = { foo: 42, __proto__: null };
18     for (var i = 1; i < 6; ++i)
19         thisObj["temp" + i] = "FAIL";
20
21     inner.call(thisObj);
22 }
23
24 function checkThisObject()
25 {
26     for (var key in thisObj) {
27         if (key === "foo")
28             console.assert(thisObj[key] === 42);
29         else if (key.substr(0, 4) === "temp")
30             console.assert(thisObj[key] === "FAIL");
31         else
32             console.error("FAIL: Unexpected property " + key);
33     }
34 }
35
36 function onload()
37 {
38     for (var i = 3; i < 8; ++i)
39         window["temp" + i] = "Reserved";
40
41     runTest();
42 }
43
44 function test()
45 {
46     var expressions = [
47         "42",
48         "'foo string'",
49         "NaN",
50         "Infinity",
51         "-Infinity",
52         "-0",
53         "[1, 2, NaN, -0, null, undefined]",
54         "({ foo: 'bar' })",
55         "(function(){ return arguments; })(1,2,3,4)",
56         "(function func() {})",
57         "new Error('errr')"
58     ];
59
60     InspectorTest.setQuiet(true);
61     InspectorTest.startDebuggerTest(step1);
62
63     InspectorTest.addResult("Number of expressions: " + expressions.length);
64     InspectorTest.addResult("Names [temp3..temp7] are reserved\n");
65
66     function step1()
67     {
68         InspectorTest.runTestFunctionAndWaitUntilPaused(didPause);
69     }
70
71     function didPause()
72     {
73         evaluateNext();
74     }
75
76     function evaluateNext()
77     {
78         var expression = expressions.shift();
79         if (!expression) {
80             InspectorTest.waitForRemoteObjectsConsoleMessages(tearDown);
81             return;
82         }
83
84         function didEvaluate(result, wasThrown)
85         {
86             InspectorTest.assertTrue(!wasThrown, "FAIL: was thrown. Expression: " + expression);
87             WebInspector.panels.sources._saveToTempVariable(result);
88             InspectorTest.waitUntilNthMessageReceived(2, evaluateNext);
89         }
90
91         WebInspector.context.flavor(WebInspector.ExecutionContext).evaluate(expression, "console", true, undefined, undefined, undefined, didEvaluate);
92     }
93
94     function tearDown()
95     {
96         InspectorTest.evaluateInPage("checkThisObject()", dumpConsoleMessages);
97     }
98
99     function dumpConsoleMessages()
100     {
101         InspectorTest.dumpConsoleMessages();
102         InspectorTest.completeDebuggerTest();
103     }
104 }
105
106 </script>
107 </head>
108
109 <body onload="onload()">
110 <p>
111 Tests saving objects to temporary variables while paused.
112 </p>
113
114 </body>
115 </html>