|
1 | 1 | <html> |
2 | | -<head><title>function instrumentation test</title></head> |
3 | | -<body> |
4 | | -<div id="output"></div> |
5 | | -</body> |
6 | | -<script type="text/javascript" src="../../stacktrace.js"></script> |
7 | | -<script type="text/javascript">function printTrace(trace){var output=document.getElementById("output");if(!output){output=document.createElement("div");output.id="output";document.body.appendChild(output);} |
8 | | -if(!expected){expected="";} |
9 | | -trace.push("--------------Expected:-------------------") |
10 | | -trace.push(expected);output.innerHTML=(trace.join('<br/>'));} |
11 | | -var p=new printStackTrace.implementation();p.instrumentFunction(this,'bar',logStackTrace);function logStackTrace(stack){printTrace(stack);} |
12 | | -var foo=function(){var a=1;bar();} |
13 | | -function bar(){var baz=2;} |
14 | | -var expected=["baz()","bar()","foo()"].join("<br/>");foo();p.deinstrumentFunction(this,'bar');</script> |
| 2 | + <head> |
| 3 | + <title>function instrumentation test</title> |
| 4 | + <script type="text/javascript" src="../../stacktrace.js"></script> |
| 5 | + </head> |
| 6 | + <body> |
| 7 | + <div id="output"></div> |
| 8 | + <script type="text/javascript"> |
| 9 | + function toList(array) { |
| 10 | + return "<ol><li>" + (array.join("</li><li>")) + "</li></ol>"; |
| 11 | + } |
| 12 | + |
| 13 | + var expected = []; |
| 14 | + |
| 15 | + function printTrace(trace) { |
| 16 | + var output = document.getElementById("output"); |
| 17 | + if (!output) { |
| 18 | + output = document.createElement("div"); |
| 19 | + output.id = "output"; |
| 20 | + document.body.appendChild(output); |
| 21 | + } |
| 22 | + |
| 23 | + var content = []; |
| 24 | + content.push(toList(trace)); |
| 25 | + content.push("--------------Expected:-------------------"); |
| 26 | + content.push(toList(expected || [])); |
| 27 | + output.innerHTML = (content.join("<br/>")); |
| 28 | + } |
| 29 | + |
| 30 | + function baz() { |
| 31 | + var c = 3; |
| 32 | + } |
| 33 | + |
| 34 | + function bar() { |
| 35 | + var b = 2; |
| 36 | + baz(); |
| 37 | + } |
| 38 | + |
| 39 | + var foo = function() { |
| 40 | + var a = 1; |
| 41 | + bar(); |
| 42 | + }; |
| 43 | + |
| 44 | + var p = new window.printStackTrace.implementation(); |
| 45 | + p.instrumentFunction(this, 'baz', printTrace); |
| 46 | + |
| 47 | + expected = ["bar()", "foo()"]; |
| 48 | + foo(); |
| 49 | + |
| 50 | + p.deinstrumentFunction(this, 'bar'); |
| 51 | + </script> |
| 52 | + </body> |
15 | 53 | </html> |
0 commit comments