Web Inspector: Breakpoints in sourceURL named scripts do not work
[WebKit-https.git] / LayoutTests / inspector-protocol / debugger / setBreakpointByUrl-sourceURL.html
1 <html>
2 <head>
3 <script src="../../http/tests/inspector-protocol/resources/protocol-test.js"></script>
4 <script src="resources/breakpoint.js"></script>
5 <script>
6 // sourceURL-test.js:
7 eval("function sourceURLFunction() {\n    var a = 1;\n    var b = 2;\n    var c = a+b;\n    alert(c);\n}\n//# sourceURL=sourceURL-test.js")
8
9 function test()
10 {
11     InspectorTest.sendCommand("Debugger.enable", {});
12     InspectorTest.sendCommand("Debugger.setBreakpointsActive", {active: true}, function() {
13         InspectorTest.log("Breakpoints Enabled");
14     });
15
16     InspectorTest.eventHandler["Debugger.scriptParsed"] = function(messageObject)
17     {
18         if (/sourceURL-test\.js$/.test(messageObject.params.url)) {
19             InspectorTest.log("Found sourceURL-test.js");
20             var params = {url: messageObject.params.url, lineNumber: 3, columnNumber: 0};
21             InspectorTest.sendCommand("Debugger.setBreakpointByUrl", params, function(responseObject) {
22                 InspectorTest.checkForError(responseObject);
23                 InspectorTest.log("Running sourceURLFunction");
24                 InspectorTest.sendCommand("Runtime.evaluate", {expression: "sourceURLFunction()"});
25             });
26         }
27     }
28
29     InspectorTest.eventHandler["Debugger.paused"] = function(messageObject)
30     {
31         InspectorTest.log("Hit Breakpoint!");
32         var callFrameIdentifier = messageObject.params.callFrames[0].callFrameId;
33         InspectorTest.sendCommand("Debugger.evaluateOnCallFrame", {callFrameId: callFrameIdentifier, expression: "a"}, function(messageObject) {
34             InspectorTest.log("Evaluted value of `a` (expecting number 1) was: " + JSON.stringify(messageObject.result.result));
35             InspectorTest.sendCommand("Debugger.evaluateOnCallFrame", {callFrameId: callFrameIdentifier, expression: "c"}, function(messageObject) {
36                 InspectorTest.log("Evaluted value of `c` (expecting undefined) was: " + JSON.stringify(messageObject.result.result));
37                 InspectorTest.completeTest();
38             });
39         });
40     }
41 }
42 </script>
43 </head>
44 <body onload="runTest()">
45 <p>Debugger.setBreakpointByUrl in Script named via sourceURL</p>
46 </body>
47 </html>