Unreviewed, add extra test failure logging after r200971
[WebKit-https.git] / LayoutTests / inspector / debugger / tail-deleted-frames-this-value.html
1 <!doctype html>
2 <html>
3 <head>
4 <script src="../../http/tests/inspector/resources/inspector-test.js"></script>
5 <script src="../../http/tests/inspector/debugger/debugger-test.js"></script>
6 <script src="./resources/tail-deleted-frames-this-value.js"></script>
7 <script>
8
9 function test()
10 {
11     var scriptObject;
12
13     function startTest() {
14         InspectorTest.log("Starting Test");
15         // 0 based indices.
16         let testInfo = {line: 3, column: 4};
17         let location = scriptObject.createSourceCodeLocation(testInfo.line, testInfo.column);
18         let breakpoint = new WI.Breakpoint(location);
19         WI.debuggerManager.addBreakpoint(breakpoint);
20         InspectorTest.evaluateInPage("startABC()");
21     }
22
23     WI.debuggerManager.addEventListener(WI.DebuggerManager.Event.CallFramesDidChange, function(event) {
24         var activeCallFrame = WI.debuggerManager.activeCallFrame;
25
26         if (!activeCallFrame)
27             return;
28
29         var stopLocation = "line: " + activeCallFrame.sourceCodeLocation.lineNumber + ", column: " + activeCallFrame.sourceCodeLocation.columnNumber;
30
31         InspectorTest.log("\n\n------------------------------------");
32         InspectorTest.log("Hit breakpoint at " + stopLocation);
33         InspectorTest.log("------------------------------------");
34
35         // top down list
36         let expectedFrames = [
37             {functionName: 'a', thisValue: ['aThis', 2], isTailDeleted: false},
38             {functionName: 'b', thisValue: ['bThis', 1], isTailDeleted: true},
39             {functionName: 'c', thisValue: ['cThis', 0], isTailDeleted: true}
40         ];
41
42         let targetData = WI.debuggerManager.dataForTarget(WI.debuggerManager.activeCallFrame.target);
43         let callFrames = targetData.callFrames;
44
45         InspectorTest.assert(callFrames.length >= expectedFrames.length, `Should have at least ${expectedFrames.length} frames, but have ${callFrame.length} instead.`);
46
47         // Resolve a thisObject preview on each of the CallFrames.
48         let promises = [];
49         for (let callFrame of callFrames) {
50             InspectorTest.assert(!callFrame.thisObject.preview, "thisObject should not have a preview");
51             if (callFrame.thisObject.canLoadPreview()) {
52                 promises.push(new Promise((resolve, reject) => {
53                     callFrame.thisObject.updatePreview(resolve);
54                 }));
55             }
56         }
57
58         Promise.all(promises).then(() => {
59             for (let i = 0; i < expectedFrames.length; i++) {
60                 let callFrame = callFrames[i];
61                 let expectedFrame = expectedFrames[i];
62                 InspectorTest.log("Expected frame: " + JSON.stringify(expectedFrame));
63                 InspectorTest.assert(callFrame.functionName === expectedFrame.functionName, `Should have functionName of '${expectedFrame.functionName}', but have '${callFrame.functionName}' instead.`);
64                 InspectorTest.assert(callFrame.isTailDeleted === expectedFrame.isTailDeleted, `Should have isTailDeleted of '${expectedFrame.isTailDeleted}', but have '${callFrame.isTailDeleted}' instead.`);
65
66                 let thisObject = callFrame.thisObject;
67                 let properties = thisObject.preview.propertyPreviews;
68                 InspectorTest.assert(properties.length === 1, "Should have one property.");
69                 let prop = properties[0];
70                 InspectorTest.expectThat(expectedFrame.thisValue[0] === prop.name, `'this' value should have expected property: ${expectedFrame.thisValue[0]}`);
71                 InspectorTest.assert('' + expectedFrame.thisValue[1] === prop.value, `'this' value object should have expected property value: ${expectedFrame.thisValue[1]}`);
72                 InspectorTest.pass(`Call Frame ${i} 'this' value is correct.`);
73             }
74
75             WI.debuggerManager.resume();
76         });
77     });
78
79     WI.debuggerManager.addEventListener(WI.DebuggerManager.Event.Resumed, function(event) {
80         InspectorTest.log("Tests done");
81         InspectorTest.completeTest();
82     });
83
84     WI.debuggerManager.addEventListener(WI.DebuggerManager.Event.ScriptAdded, function(event) {
85         eventScriptObject = event.data.script;
86         
87         if (/tail-deleted-frames-this-value\.js$/.test(eventScriptObject.url)) {
88             scriptObject = eventScriptObject;
89             startTest();
90             return;
91         }
92
93     });
94
95     InspectorTest.reloadPage();
96 }
97 </script>
98 </head>
99 <body onload="runTest()">
100     <p>Testing that we keep around tail deleted frames in the inspector and their this values.</p>
101 </body>
102 </html>