Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / inspector / sources / debugger / event-listener-breakpoints-promises.html
1 <html>
2 <head>
3 <script src="../../../http/tests/inspector/inspector-test.js"></script>
4 <script src="../../../http/tests/inspector/debugger-test.js"></script>
5 <script>
6
7 function testFunction()
8 {
9     var resolve;
10     var reject;
11
12     var p = new Promise(function(res, rej) {
13         resolve = res;
14     });
15     p.then(function() {
16     });
17
18     var q = new Promise(function(res, rej) {
19         reject = rej;
20     });
21     q.catch(function() {
22     });
23
24     resolve(42);
25     reject(new Error("err"));
26 }
27
28 var test = function()
29 {
30     var pane = WebInspector.panels.sources.sidebarPanes.eventListenerBreakpoints;
31     var numberOfPauses = 6;
32
33     InspectorTest.setQuiet(true);
34     InspectorTest.startDebuggerTest(step1);
35
36     function step1()
37     {
38         pane._setBreakpoint("instrumentation:newPromise");
39         pane._setBreakpoint("instrumentation:promiseResolved");
40         pane._setBreakpoint("instrumentation:promiseRejected");
41         InspectorTest.runTestFunctionAndWaitUntilPaused(didPause);
42     }
43
44     function didPause(callFrames, reason, breakpointIds, asyncStackTrace, auxData)
45     {
46         var eventName = (auxData && auxData.eventName || "").replace(/^instrumentation:/, "");
47         InspectorTest.addResult("\nPaused on " + eventName);
48         InspectorTest.captureStackTrace(callFrames);
49
50         if (--numberOfPauses)
51             InspectorTest.resumeExecution(InspectorTest.waitUntilPaused.bind(InspectorTest, didPause));
52         else
53             InspectorTest.resumeExecution(step2);
54     }
55
56     function step2()
57     {
58         pane._removeBreakpoint("instrumentation:newPromise");
59         pane._removeBreakpoint("instrumentation:promiseResolved");
60         pane._removeBreakpoint("instrumentation:promiseRejected");
61         InspectorTest.completeDebuggerTest();
62     }
63 }
64
65 </script>
66 </head>
67
68 <body onload="runTest()">
69 <p>
70 Tests that debugger will stop on Promise events.
71 </p>
72
73 </body>
74 </html>