Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / inspector / sources / debugger / promise-pane.html
blob12f8c4f1ef68e78178e9cbdfa09fe1bc9c19ff2c
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 var p1, p2, p3;
8 function testFunction()
10 debugger; // <- will turn on async call stacks here.
11 setTimeout(func1, 0);
14 function func1()
16 p1 = Promise.reject(new Error("EXPECTED"));
17 setTimeout(func2, 0);
20 function func2()
22 var resolve;
23 var reject;
24 p2 = new Promise(
25 function (a, b)
27 resolve = a;
28 reject = b;
31 setTimeout(func3.bind(null, resolve, reject), 50);
34 function func3(resolve, reject)
36 p3 = p1.catch(function() {});
37 var x = 42;
38 resolve(x);
39 setTimeout(func4, 0);
42 function func4()
44 debugger; // <- will stop the test here.
47 function test()
49 var maxAsyncCallStackDepth = 4;
50 var promisePane;
52 InspectorTest.addSniffer(WebInspector.TabbedPane.prototype, "changeTabView", onChangeTabView, true);
53 WebInspector.inspectorView.showViewInDrawer("promises", true);
55 function onChangeTabView(id, view)
57 if (!promisePane && id === "promises") {
58 promisePane = view;
59 InspectorTest.assertTrue(promisePane instanceof WebInspector.PromisePane);
60 InspectorTest.startDebuggerTest(step1, true);
64 function dumpPromiseDataGrid(callback)
66 promisePane._dataGrid._update();
67 var result = InspectorTest.dumpDataGridIntoString(promisePane._dataGrid);
68 result = result.replace(/\|\s+\d+\s+\w*\s*\|/g, "| <number> ms |");
69 InspectorTest.addResult(result);
70 if (callback)
71 callback();
74 function step1()
76 InspectorTest.runTestFunctionAndWaitUntilPaused(step2);
79 function step2()
81 InspectorTest.DebuggerAgent.setAsyncCallStackDepth(maxAsyncCallStackDepth, step3);
84 function step3()
86 InspectorTest.addResult("Is drawer visible: " + WebInspector.inspectorView.drawerVisible());
87 InspectorTest.addResult("Selected view in drawer: " + WebInspector.inspectorView.selectedViewInDrawer());
88 InspectorTest.resumeExecution(InspectorTest.waitUntilPaused.bind(InspectorTest, dumpPromiseDataGrid.bind(null, step4)));
91 var searchValues = [
92 "func3",
93 "func",
94 "promise-pane.html",
95 "promise-pane.html:38",
98 function step4()
100 var text = searchValues.shift();
101 if (!text) {
102 InspectorTest.completeDebuggerTest();
103 return;
105 InspectorTest.addResult("\nSetting search value: " + text);
106 promisePane._textFilterUI.setValue(text);
107 promisePane._refresh();
108 dumpPromiseDataGrid(step4);
112 </script>
113 </head>
115 <body onload="runTest()">
117 Tests promise pane view.
118 </p>
119 </body>
120 </html>