• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<html>
2<head>
3<script>
4
5function log(message) {
6    console.log(message)
7}
8
9var funcBody = "(){\n" +
10"   var thisFunc = arguments.callee;\n" +
11"   if (!thisFunc.name) thisFunc.displayName = 'f%';\n" +
12"   log(thisFunc.name || thisFunc.displayName);\n" +
13"}";
14
15var funcs = [];
16var patterns = [
17    // proper use of @sourceURL comment
18    "//@sourceURL=f%.js\nfuncs.push(function" + funcBody + ")",
19    "//@sourceURL=f%.js\nfuncs.push(function f%" + funcBody + ")",
20    " //@sourceURL=f%.js\nfuncs.push(function f%" + funcBody + ")",
21    "// @sourceURL=f%.js\nfuncs.push(function f%" + funcBody + ")",
22    "//@ sourceURL=f%.js\nfuncs.push(function f%" + funcBody + ")",
23    "//@sourceURL =f%.js\nfuncs.push(function f%" + funcBody + ")",
24    "//@sourceURL= f%.js\nfuncs.push(function f%" + funcBody + ")",
25    "//@sourceURL=f%.js \nfuncs.push(function f%" + funcBody + ")",
26    " // @ sourceURL = f%.js \nfuncs.push(function f%" + funcBody + ")",
27    "//@sourceURL=f%.js\nfuncs.push(function f%" + funcBody + ");\n//@sourceURL=should-not-see\n",
28    "funcs.push(function f%" + funcBody + ")\n//@sourceURL=f%.js\n",
29    "funcs.push(function f%" + funcBody + ")\n//@sourceURL=f%.js \n",
30    "funcs.push(function f%" + funcBody + ")\n//@sourceURL=f%.js",
31
32    // improper or non-existant use of @sourceURL comment
33    "funcs.push(function f%" + funcBody + ")",
34    "//@sourceurl=f%.js\nfuncs.push(function f%" + funcBody + ")",
35    "//sourceURL=f%.js\nfuncs.push(function f%" + funcBody + ")",
36    "/*@sourceURL=f%.js*/\nfuncs.push(function f%" + funcBody + ")",
37    "//\nsourceURL='f%.js';\nfuncs.push(function f%" + funcBody + ")",
38    "//@sourceURL=\nfuncs.push(function" + funcBody + ")",
39];
40
41
42for (var i=0; i<patterns.length; i++) {
43    eval(patterns[i].replace(/%/g, i));
44}
45
46</script>
47</head>
48
49<body>
50<p>This page's JavaScript calls functions from named eval()'s.
51
52<p>Used to test <a href="https://bugs.webkit.org/show_bug.cgi?id=25475">https://bugs.webkit.org/show_bug.cgi?id=25475</a>
53
54<p>Load the Web Inspector and look at
55the script's panel, and the script list drop-down control.
56You should see entries for scripts named
57<tt>"(program):f0.js"</tt> through <tt>"(program):f12.js"</tt>.  The entries were named
58via proper use of the <tt>//@sourceURL</tt> comment.  There will also be entries
59named <tt>"(program)"</tt> for source that does not properly use, or use at all,
60the <tt>//@sourceURL</tt> comment.
61
62<p>Now, set a breakpoint in the body of the <tt>"f0"</tt> function in the
63<tt>"(program):f0.js"</tt> script.  Then click this button:
64
65<p><input type="button" value="run" onclick="funcs[0]()">
66
67<p>When stopped at the breakpoint, the entry for the function in the
68call stack control should the name of the script, <tt>"(program):f0.js"</tt>,
69beside the function name <tt>"f0"</tt>.  Note the function name for
70<tt>f0</tt> is set with the new <tt>"displayName"</tt> property.
71</body>
72</html>
73