|
| 1 | +<!DOCTYPE html> |
1 | 2 | <html> |
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> |
| 3 | + <head> |
| 4 | + <title>function instrumentation test</title> |
| 5 | + <script type="text/javascript" src="../../stacktrace.js"></script> |
| 6 | + <script type="text/javascript" src="testCommon.js"></script> |
| 7 | + </head> |
| 8 | + <body> |
| 9 | + <div id="output"></div> |
| 10 | + <script type="text/javascript"> |
| 11 | + function baz() { |
| 12 | + var c = 3; |
| 13 | + } |
| 14 | + |
| 15 | + function bar() { |
| 16 | + var b = 2; |
| 17 | + baz(); |
| 18 | + } |
| 19 | + |
| 20 | + var foo = function() { |
| 21 | + var a = 1; |
| 22 | + bar(); |
| 23 | + }; |
| 24 | + |
| 25 | + var p = new window.printStackTrace.implementation(); |
| 26 | + p.instrumentFunction(this, 'baz', printTrace); |
| 27 | + |
| 28 | + expected = ["bar()", "foo()"]; |
| 29 | + foo(); |
| 30 | + |
| 31 | + p.deinstrumentFunction(this, 'bar'); |
| 32 | + </script> |
| 33 | + </body> |
53 | 34 | </html> |
0 commit comments