• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<style>code{background-color: #ffc;}</style>
2<p><b>Test for <a href="https://bugs.webkit.org/show_bug.cgi?id=31375">Bug 31375</a> - Web Inspector: breakpoints in named evals are not restored after a reload</b>
3
4<ul>
5<li><p>open this page with Web Inspector
6<li><p>switch to the Scripts panel, enabling debug if required
7<li><p>the available scripts in the select element should be:
8<ul>
9<li>(program): f1.js
10<li>(program): f2.js
11<li>bp-in-named-eval-after-reload.html
12</ul>
13<li><p>In <code>(program) f1.js</code>, set a breakpoint on the first
14executable line of the function <code>f1()</code>, the invocation of <code>doNothing()</code>.
15<li><p>In <code>(program) f2.js</code>, set a breakpoint on the first
16executable line of the function <code>f2()</code>, the invocation of <code>doNothing()</code>.
17<li><p>click this button: <input id=button type=button value="click me">
18<li><p>debugger should stop in the <code>f1()</code> function.
19<li><p>resume the debugger
20<li><p>debugger should stop in the <code>f2()</code> function (the function in <code>(program) f2.js</code>)
21<li><p>resume the debugger
22<li><p>switch to the web page, reload the web page, switch back to web inspector
23<li><p>in the breakpoints sidebar panel, click on the two breakpoints listed
24and the source for those functions should be shown in the source panel, and
25the previous breakpoint markers should be visible
26<li><p>click the "click me" button above, again
27<li><p>debugger should stop in the <code>f1()</code> function.
28<li><p>resume the debugger
29<li><p>debugger should stop in the <code>f2()</code> function.
30<li><p>resume the debugger
31</ul>
32
33<p>Note that without the fix in <a href="https://bugs.webkit.org/show_bug.cgi?id=31375">Bug 31375</a>,
34the breakpoints won't work after reloading the page.
35
36<script>
37
38function doNothing() { /* allows multi-line functions, easier to debug */ };
39
40eval([
41    "function f1() {",
42    "   doNothing();",
43    "   console.log(new Date() + ':  f1() called');",
44    "}",
45    "//@sourceURL=f1.js"
46].join("\n"));
47
48f2 = Function([
49    "",
50    "   doNothing();",
51    "   console.log(new Date() + ':  f2() called');",
52    "//@sourceURL=f2.js"
53].join("\n"));
54
55var button = document.getElementById("button");
56
57button.addEventListener("click", clickHandler, false);
58
59function clickHandler() {
60    f1();
61    f2();
62}
63
64</script>
65<!-- End -->
66