001package Torello.Browser.BrowserAPI;
002
003// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
004// Java-HTML Imports
005// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
006
007import Torello.Browser.*;
008import Torello.Browser.helper.*;
009import Torello.Browser.JavaScriptAPI.*;
010import Torello.JSON.*;
011
012import Torello.Java.ReadOnly.ReadOnlyList;
013import Torello.Java.ReadOnly.ReadOnlyArrayList;
014
015import Torello.JavaDoc.Annotations.StaticFunctional;
016import Torello.JavaDoc.Annotations.JDHeaderBackgroundImg;
017
018
019// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
020// JDK Imports
021// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
022
023import javax.json.JsonObject;
024import javax.json.JsonValue;
025
026/**
027 * <SPAN CLASS=COPIEDJDK><B>EventBreakpoints permits setting JavaScript breakpoints on operations and events
028 * occurring in native code invoked from JavaScript. Once breakpoint is hit, it is
029 * reported through Debugger domain, similarly to regular breakpoints being hit.</B></SPAN>
030 * <EMBED CLASS='external-html' DATA-FILE-ID=CDP.CODE_GEN_NOTE>
031 */
032@StaticFunctional@JDHeaderBackgroundImg(EmbedTagFileID="CDP.WOOD_PLANK_NOTE")
033public class EventBreakpoints
034{
035    // No Pubic Constructors
036    private EventBreakpoints() { }
037
038
039
040
041
042    // ********************************************************************************************
043    // ********************************************************************************************
044    // Commands
045    // ********************************************************************************************
046    // ********************************************************************************************
047
048
049    /**
050     * Removes all breakpoints
051     * 
052     * @return An instance of <CODE>{@link Script}&lt;Void&gt;</CODE>
053     *
054     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
055     * browser receives the invocation-request.
056     *
057     * <BR /><BR /><DIV CLASS=JDHint>
058     * This Browser-Function <I>does not have</I> a return-value.  You may choose to
059     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <Void>} to ensure that
060     * the Browser Function has run to completion.
061     * </DIV>
062     */
063    public static Script<Void> disable()
064    {
065        // Ultra-Simple Request JSON - Because this method has no parameters
066        final String requestJSON = "{\"method\":\"EventBreakpoints.disable\"}";
067
068        return Script.NO_RET(Domains.EventBreakpoints, "disable", requestJSON);
069    }
070
071    /**
072     * Removes breakpoint on particular native event.
073     * 
074     * @param eventName Instrumentation name to stop on.
075     * 
076     * @return An instance of <CODE>{@link Script}&lt;Void&gt;</CODE>
077     *
078     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
079     * browser receives the invocation-request.
080     *
081     * <BR /><BR /><DIV CLASS=JDHint>
082     * This Browser-Function <I>does not have</I> a return-value.  You may choose to
083     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <Void>} to ensure that
084     * the Browser Function has run to completion.
085     * </DIV>
086     */
087    public static Script<Void> removeInstrumentationBreakpoint(String eventName)
088    {
089        // Build the JSON Request-Object (as a String); only 1 Parameter is passed
090        final String requestJSON = WriteJSON.get(
091            CDPTypes.STRING, "eventName", false,
092            "EventBreakpoints.removeInstrumentationBreakpoint", eventName
093        );
094
095        return Script.NO_RET(Domains.EventBreakpoints, "removeInstrumentationBreakpoint", requestJSON);
096    }
097
098    /**
099     * Sets breakpoint on particular native event.
100     * 
101     * @param eventName Instrumentation name to stop on.
102     * 
103     * @return An instance of <CODE>{@link Script}&lt;Void&gt;</CODE>
104     *
105     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
106     * browser receives the invocation-request.
107     *
108     * <BR /><BR /><DIV CLASS=JDHint>
109     * This Browser-Function <I>does not have</I> a return-value.  You may choose to
110     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <Void>} to ensure that
111     * the Browser Function has run to completion.
112     * </DIV>
113     */
114    public static Script<Void> setInstrumentationBreakpoint(String eventName)
115    {
116        // Build the JSON Request-Object (as a String); only 1 Parameter is passed
117        final String requestJSON = WriteJSON.get(
118            CDPTypes.STRING, "eventName", false,
119            "EventBreakpoints.setInstrumentationBreakpoint", eventName
120        );
121
122        return Script.NO_RET(Domains.EventBreakpoints, "setInstrumentationBreakpoint", requestJSON);
123    }
124
125
126}