| OLD | NEW |
| (Empty) |
| 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 | |
| 6 <script> function firstLineFunction() | |
| 7 | |
| 8 { | |
| 9 } | |
| 10 | |
| 11 function notFirstLineFunction() | |
| 12 | |
| 13 { | |
| 14 } | |
| 15 | |
| 16 var obj = { | |
| 17 m: function() {} | |
| 18 } | |
| 19 | |
| 20 function functionWithDisplayName() {} | |
| 21 functionWithDisplayName.displayName = "user-friendly name"; | |
| 22 | |
| 23 function functionWithDisplayNameGetter() {} | |
| 24 functionWithDisplayNameGetter.__defineGetter__("displayName", function() { retur
n "FAIL_should_not_execute"; }); | |
| 25 | |
| 26 var smallClosure = (function(p) { return function() { return p; }; })("Capybara"
); | |
| 27 | |
| 28 var bigClosure = (function(p) { | |
| 29 var o = { | |
| 30 e: 7, | |
| 31 f: 5, | |
| 32 get u() { return 3; }, | |
| 33 set v(value) { } | |
| 34 }; | |
| 35 with (o) { | |
| 36 try { | |
| 37 throw Error("Test"); | |
| 38 } catch (ex) { | |
| 39 return function() { | |
| 40 return String(p) + String(ex) + u + e; | |
| 41 }; | |
| 42 } | |
| 43 } | |
| 44 })({}); | |
| 45 | |
| 46 function test() | |
| 47 { | |
| 48 function dumpFunctionDetails(details) | |
| 49 { | |
| 50 InspectorTest.addResult("Function details: "); | |
| 51 InspectorTest.addResult("lineNumber: " + details.location.lineNumber); | |
| 52 InspectorTest.addResult("columnNumber: " + details.location.columnNumber
); | |
| 53 InspectorTest.addResult("scriptId is valid: " + !!details.location.scrip
tId); | |
| 54 InspectorTest.addResult("functionName: " + details.functionName); | |
| 55 InspectorTest.addResult("isGenerator: " + details.isGenerator); | |
| 56 } | |
| 57 | |
| 58 function dumpFunctionNoScopes() | |
| 59 { | |
| 60 InspectorTest.addResult("scopeChain: n/a"); | |
| 61 } | |
| 62 | |
| 63 function dumpFunctionScope(pos, type, propertyDescriptors) | |
| 64 { | |
| 65 var variables; | |
| 66 if (type == "global") { | |
| 67 variables = "<global object properties omitted>"; | |
| 68 } else { | |
| 69 var varArray = []; | |
| 70 for (var i = 0; i < propertyDescriptors.length; i++) { | |
| 71 var d = propertyDescriptors[i]; | |
| 72 var valueStr; | |
| 73 if (d.value) { | |
| 74 if (d.value.value) | |
| 75 valueStr = JSON.stringify(d.value.value); | |
| 76 else | |
| 77 valueStr = "<no string representation>"; | |
| 78 } else { | |
| 79 valueStr = "<no value>"; | |
| 80 } | |
| 81 varArray.push(d.name + ": " + valueStr); | |
| 82 } | |
| 83 varArray.sort(); | |
| 84 variables = varArray.join(); | |
| 85 } | |
| 86 InspectorTest.addResult("scopeChain #" + pos + ": " + type + "; " + vari
ables); | |
| 87 } | |
| 88 | |
| 89 function loadAndDumpScopeObjects(scopeChain, end) | |
| 90 { | |
| 91 function loadScopeObject(pos, next) | |
| 92 { | |
| 93 if (pos >= scopeChain.length) { | |
| 94 next(); | |
| 95 return; | |
| 96 } | |
| 97 var scopeJson = scopeChain[pos]; | |
| 98 InspectorTest.RuntimeAgent.getProperties(scopeJson.object.objectId,
true, didGetProperties); | |
| 99 | |
| 100 function didGetProperties(error, propertyDescriptors) | |
| 101 { | |
| 102 dumpFunctionScope(pos, scopeJson.type, propertyDescriptors); | |
| 103 loadScopeObject(pos + 1, next); | |
| 104 } | |
| 105 } | |
| 106 | |
| 107 if (scopeChain) { | |
| 108 loadScopeObject(0, end); | |
| 109 } else { | |
| 110 dumpFunctionNoScopes(); | |
| 111 end(); | |
| 112 } | |
| 113 } | |
| 114 | |
| 115 function performStandardTestCase(pageExpression, next) | |
| 116 { | |
| 117 InspectorTest.evaluateInPage(pageExpression, didEvaluate); | |
| 118 | |
| 119 function didEvaluate(remote) | |
| 120 { | |
| 121 InspectorTest.addResult(pageExpression + " type = " + remote.type); | |
| 122 InspectorTest.DebuggerAgent.getFunctionDetails(remote.objectId, didG
etDetails); | |
| 123 } | |
| 124 function didGetDetails(error, response) | |
| 125 { | |
| 126 dumpFunctionDetails(response); | |
| 127 loadAndDumpScopeObjects(response.scopeChain, next); | |
| 128 } | |
| 129 } | |
| 130 | |
| 131 InspectorTest.runDebuggerTestSuite([ | |
| 132 function testGetFirstLineFunctionDetails(next) | |
| 133 { | |
| 134 performStandardTestCase("firstLineFunction", next); | |
| 135 }, | |
| 136 function testGetNonFirstLineFunctionDetails(next) | |
| 137 { | |
| 138 performStandardTestCase("notFirstLineFunction", next); | |
| 139 }, | |
| 140 function testGetDetailsOfFunctionWithInferredName(next) | |
| 141 { | |
| 142 performStandardTestCase("obj.m", next); | |
| 143 }, | |
| 144 function testGetDetailsOfFunctionWithDisplayName(next) | |
| 145 { | |
| 146 performStandardTestCase("functionWithDisplayName", next); | |
| 147 }, | |
| 148 function testGetDetailsOfFunctionWithDisplayNameGetter(next) | |
| 149 { | |
| 150 performStandardTestCase("functionWithDisplayNameGetter", next); | |
| 151 }, | |
| 152 function testSmallClosure(next) | |
| 153 { | |
| 154 performStandardTestCase("smallClosure", next); | |
| 155 }, | |
| 156 function testBigClosure(next) | |
| 157 { | |
| 158 performStandardTestCase("bigClosure", next); | |
| 159 } | |
| 160 ]); | |
| 161 }; | |
| 162 | |
| 163 </script> | |
| 164 </head> | |
| 165 | |
| 166 <body onload="runTest()"> | |
| 167 <p>Tests that Debugger.getFunctionDetails command returns correct location. | |
| 168 <a href="https://bugs.webkit.org/show_bug.cgi?id=71808">Bug 71808</a> | |
| 169 </p> | |
| 170 </body> | |
| 171 </html> | |
| OLD | NEW |