• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1
2<p><b>Test for <a href="https://bugs.webkit.org/show_bug.cgi?id=30212">Bug 30212</a> - Each JS execution in console adds extra item into "scripts" combo</b>
3
4<p>The following manual test creates functions via <tt>eval()</tt> and the
5<tt>Function()</tt> constructor, some functions are named using the
6<code>//@sourceURL=</code> directive, some aren't.  Some contain
7<tt>debugger</tt> commands, some don't.
8
9<p>The functions named <tt>f_named_X</tt> are 'named' via the
10<code>//@sourceURL=</code> directive, the ones named <tt>f_unnamed_X</tt>
11are not.  The 'named' functions should show up in the Scripts select element used
12to select a resource/script to view, the 'unnamed' ones should not.
13
14<ul>
15<li><p>open this page with Web Inspector
16<li><p>switch to the Scripts panel, enabling debug if required
17<li><p>the available scripts in the select element should be:
18<ul>
19<li>(program): f_named_1.eval
20<li>(program): f_named_2.eval
21<li>(program): f_named_3.eval
22<li>hidden-evals.html
23</ul>
24<li><p>click this button: <input id=button type=button value="click me">
25<li><p>debugger should stop in the <code>clickHandler</code> function
26<li><p>at this point, start stepping <b>into</b> the code
27<li><p>you should be able to step into functions <code>f_unnamed_1()</code>
28and <code>f_unnamed_2()</code>.  There are no resource/scripts in the
29select element that contain these functions, until you actually are paused
30in them.  At that point, entries for these functions will be in the select element,
31named: "(program)".  After pausing in both functions, there will be two "(program)"
32entries.
33<li><p>you should be able to use the next/prev buttons (to the left of the select element)
34to switch to other resources/scripts that have been opened, including the ones
35containing these functions
36<li><p>you should be able to click on the functions that exist in the 'hidden'
37resources from the Call Stack, and be shown the source; click around the
38stack trace entries to verify
39<li><p>rather than stepping into the <code>f_named_3()</code> call, press the
40resume button
41<li><p>the debugger should stop in <code>f_named_3()</code> because of the
42<code>debugger</code> command
43<li><p>rather than stepping into the <code>f_unnamed_3()</code> call, press the
44resume button
45<li><p>the debugger should stop in <code>f_unnamed_3()</code> because of the
46<code>debugger</code> command.  At this point, a third "(program)" entry for
47this function is added to the select element.
48</ul>
49
50<script>
51
52function doNothing() { /* allows multi-line functions, easier to debug */ };
53
54eval([
55    "function f_named_1() {",
56    "   doNothing();",
57    "   return 'named_1';",
58    "}",
59    "//@sourceURL=f_named_1.eval"
60].join("\n"));
61
62eval([
63    "function f_unnamed_1() {",
64    "   doNothing();",
65    "   return 'unnamed_1';",
66    "}"
67].join("\n"));
68
69f_named_2 = Function([
70    "",
71    "   doNothing();",
72    "   return 'named_2';",
73    "//@sourceURL=f_named_2.eval"
74].join("\n"));
75
76f_unnamed_2 = Function([
77    "",
78    "   doNothing();",
79    "   return 'unnamed_2';"
80].join("\n"));
81
82f_named_3 = Function([
83    "",
84    "   debugger;",
85    "   doNothing();",
86    "   return 'named_3';",
87    "//@sourceURL=f_named_3.eval"
88].join("\n"));
89
90f_unnamed_3 = Function([
91    "",
92    "   debugger;",
93    "   doNothing();",
94    "   return 'unnamed_3';"
95].join("\n"));
96
97var button = document.getElementById("button");
98
99button.addEventListener("click", clickHandler, false);
100
101function clickHandler() {
102    debugger;
103    f_named_1();
104    f_unnamed_1();
105    f_named_2();
106    f_unnamed_2();
107
108    // press "resume" at this point
109    console.log("press resume before calling f_named_3()");
110    f_named_3();
111
112    // press "resume" at this point
113    console.log("press resume before calling f_unnamed_3()");
114    f_unnamed_3();
115}
116
117</script>
118<!-- End -->
119