Web Inspector: Breakpoint Log action should support template literals
[WebKit-https.git] / LayoutTests / inspector / debugger / breakpoint-action-log.html
1 <!doctype html>
2 <html>
3 <head>
4 <script src="../../http/tests/inspector/resources/inspector-test.js"></script>
5 <script src="resources/script-for-breakpoint-actions.js"></script>
6 <script>
7 function runBreakpointActions()
8 {
9     breakpointActions(42, {x:1, y:2});
10 }
11
12 function test()
13 {
14     let suite = InspectorTest.createAsyncSuite("Debugger.BreakpointAction.Log");
15
16     suite.addTestCase({
17         name: "TemplateLiteralPlaceholders",
18         description: ".",
19         test(resolve, reject) {
20             WebInspector.debuggerManager.addEventListener(WebInspector.DebuggerManager.Event.ScriptAdded, (event) => {
21                 let scriptObject = event.data.script;
22                 if (!/script\-for\-breakpoint\-actions\.js$/.test(scriptObject.url))
23                     return;
24
25                 let location = scriptObject.createSourceCodeLocation(4, 0);
26                 let breakpoint = new WebInspector.Breakpoint(location);
27                 breakpoint.autoContinue = true;
28
29                 function addLogAction(data) {
30                     breakpoint.createAction(WebInspector.BreakpointAction.Type.Log, breakpoint.actions.lastValue, data);
31                 }
32
33                 addLogAction("`${a}`");
34                 addLogAction("'${a}'");
35                 addLogAction("${'ab' + 'c'}");
36                 addLogAction("${\"{abc}\"}");
37                 addLogAction("${'{abc}'}");
38                 addLogAction("${`{abc}`}");
39                 addLogAction("${`ab${'c'}`}");
40                 addLogAction("${({a: 137}).a}");
41                 addLogAction("close curly brace in RegExp: ${/\\}/.test('}')}");
42                 addLogAction("${a} and ${JSON.stringify(b)}");
43
44                 WebInspector.debuggerManager.addBreakpoint(breakpoint);
45
46                 InspectorTest.evaluateInPage("runBreakpointActions()", resolve);
47             });
48
49             InspectorTest.reloadPage();
50         }
51     });
52
53     suite.runTestCasesAndFinish();
54 }
55 </script>
56 </head>
57 <body onload="runTest()">
58     <p>Testing that "Log" breakpoint actions work correctly.</p>
59 </body>
60 </html>