Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / inspector / sources / debugger-step / debugger-step-into-async2.html
blobf0de1a48fb3cdac7dd06aa5b7f6a5dfb0a5036b1
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 src="../debugger/resources/framework.js"></script>
6 <script>
8 var dummy = function FAIL_should_not_pause_here() { return 0; };
10 function testFunction()
12 debugger; // <- will turn on async call stacks here.
14 setTimeout(dummy, 0);
15 setTimeout(callback7, 20); // <- StepIntoAsync
18 function callback7()
20 Promise.resolve(42)
21 .then(
22 function inner()
24 var p = Promise.reject(new Error("my error"));
25 p.catch(function() {});
26 debugger;
27 return p; // <- StepIntoAsync
30 .then(dummy)
31 .catch(Framework.throwFrameworkException)
32 .catch(callback8);
33 return 7;
36 function callback8()
38 var obj = {};
39 Object.observe(obj, callback9);
40 debugger;
41 obj.foo = 1; // <- StepIntoAsync
42 setTimeout(dummy);
43 return 8;
46 function callback9()
48 var iframe = document.getElementById("iframe");
49 var win = iframe.contentWindow;
50 window.addEventListener("message", callback10, false);
51 debugger;
52 win.postMessage("skip debugger", "*"); // <- StepIntoAsync
53 setTimeout(dummy, 0);
54 Promise.resolve().then(dummy);
55 return 9;
58 function callback10()
60 window.removeEventListener("message", callback10, false);
61 debugger;
62 Promise.resolve({foo: 44}) // <- StepIntoAsync
63 .then(
64 function inner1() // <- StepIntoAsync when in inner1 should lead debugger to the
65 { // next promise handler in the chain, i.e. the one, which will
66 } // receive the result returned by inner1, that is inner2.
68 .then(Framework.empty)
69 .then(
70 function inner2()
72 return callback11();
75 .then(dummy);
76 setTimeout(dummy, 0);
77 return 10;
80 function callback11()
82 return 11;
85 function test()
87 var maxAsyncCallStackDepth = 4;
88 var frameworkRegexString = "/framework\\.js$";
89 WebInspector.settingForTest("skipStackFramesPattern").set(frameworkRegexString);
91 InspectorTest.startDebuggerTest(step1, true);
93 function step1()
95 InspectorTest.runTestFunctionAndWaitUntilPaused(step2);
98 function step2()
100 InspectorTest.DebuggerAgent.setAsyncCallStackDepth(maxAsyncCallStackDepth, step3);
103 function step3()
105 var actions = [
106 "StepOver", "StepOver", "Print", // on setTimeout(callback1)
107 "StepIntoAsync", "Print", // at callback7
108 "Resume", // now paused at debugger in inner()
109 "StepOver", "StepOver", "StepIntoAsync", "Print", // at callback8
110 "Resume", "StepOver", "StepIntoAsync", "Print", // at callback9
111 "Resume", "StepOver", "StepIntoAsync", "Print", // at onmessage handler in iframe
112 "Resume", // now paused at debugger in callback10
113 "StepInto", "StepIntoAsync", "Print", // in inner1
114 "StepIntoAsync", "Print", // in inner2
115 // Test that StepIntoAsync is StepInto when there are no Async operations.
116 "StepIntoAsync", "StepIntoAsync", "Print", // in callback11
118 InspectorTest.waitUntilPausedAndPerformSteppingActions(actions, step4);
121 function step4()
123 InspectorTest.completeDebuggerTest();
127 </script>
128 </head>
130 <body onload="runTest()">
132 Tests debugger StepIntoAsync action (part 2).
133 </p>
134 <div><iframe src="../debugger/resources/post-message-listener.html"
135 id="iframe" width="800" height="100" style="border: 1px solid black;">
136 </iframe></div>
137 </body>
138 </html>