5 function log(message
) {
9 var funcBody
= "(){\n" +
10 " var thisFunc = arguments.callee;\n" +
11 " if (!thisFunc.name) thisFunc.displayName = 'f%';\n" +
12 " log(thisFunc.name || thisFunc.displayName);\n" +
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",
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
+ ")",
42 for (var i
=0; i
<patterns
.length
; i
++) {
43 eval(patterns
[i
].replace(/%/g
, i
));
50 <p>This page's JavaScript calls functions from named eval()'s.
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>
54 <p>Load the Web Inspector and look at
55 the script's panel, and the script list drop-down control.
56 You should see entries for scripts named
57 <tt>"(program):f0.js"</tt> through
<tt>"(program):f12.js"</tt>. The entries were named
58 via proper use of the
<tt>//@sourceURL
</tt> comment. There will also be entries
59 named
<tt>"(program)"</tt> for source that does not properly use, or use at all,
60 the
<tt>//@sourceURL
</tt> comment.
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:
65 <p><input type=
"button" value=
"run" onclick=
"funcs[0]()">
67 <p>When stopped at the breakpoint, the entry for the function in the
68 call stack control should the name of the script,
<tt>"(program):f0.js"</tt>,
69 beside the function name
<tt>"f0"</tt>. Note the function name for
70 <tt>f0
</tt> is set with the new
<tt>"displayName"</tt> property.