1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4  * License, v. 2.0. If a copy of the MPL was not distributed with this
5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 
7 #ifndef mozilla_dom_FuzzingFunctions
8 #define mozilla_dom_FuzzingFunctions
9 
10 #include "mozilla/EventForwards.h"
11 
12 class nsIWidget;
13 
14 namespace mozilla {
15 
16 class ErrorResult;
17 class TextInputProcessor;
18 
19 namespace dom {
20 
21 class GlobalObject;
22 struct KeyboardEventInit;
23 
24 class FuzzingFunctions final {
25  public:
26   static void GarbageCollect(const GlobalObject&);
27 
28   static void GarbageCollectCompacting(const GlobalObject&);
29 
30   static void Crash(const GlobalObject& aGlobalObject,
31                     const nsAString& aKeyValue);
32 
33   static void CycleCollect(const GlobalObject&);
34 
35   static void MemoryPressure(const GlobalObject&);
36 
37   static void EnableAccessibility(const GlobalObject&, ErrorResult& aRv);
38 
39   MOZ_CAN_RUN_SCRIPT_BOUNDARY static void SynthesizeKeyboardEvents(
40       const GlobalObject& aGlobalObject, const nsAString& aKeyValue,
41       const KeyboardEventInit& aKeyboardEvent, ErrorResult& aRv);
42 
43  private:
44   /**
45    * ActivateModifiers() activates aModifiers in the TextInputProcessor.
46    *
47    * @param aTextInputProcessor The TIP whose modifier state you want to change.
48    * @param aModifiers          Modifiers which you want to activate.
49    * @param aWidget             The widget which should be set to
50    *                            WidgetKeyboardEvent.
51    * @param aRv                 Returns error if TextInputProcessor fails to
52    *                            dispatch a modifier key event.
53    * @return                    Modifiers which are activated by the call.
54    */
55   MOZ_CAN_RUN_SCRIPT static Modifiers ActivateModifiers(
56       TextInputProcessor* aTextInputProcessor, Modifiers aModifiers,
57       nsIWidget* aWidget, ErrorResult& aRv);
58 
59   /**
60    * InactivateModifiers() inactivates aModifiers in the TextInputProcessor.
61    *
62    * @param aTextInputProcessor The TIP whose modifier state you want to change.
63    * @param aModifiers          Modifiers which you want to inactivate.
64    * @param aWidget             The widget which should be set to
65    *                            WidgetKeyboardEvent.
66    * @param aRv                 Returns error if TextInputProcessor fails to
67    *                            dispatch a modifier key event.
68    * @return                    Modifiers which are inactivated by the call.
69    */
70   MOZ_CAN_RUN_SCRIPT static Modifiers InactivateModifiers(
71       TextInputProcessor* aTextInputProcessor, Modifiers aModifiers,
72       nsIWidget* aWidget, ErrorResult& aRv);
73 };
74 
75 }  // namespace dom
76 }  // namespace mozilla
77 
78 #endif  // mozilla_dom_FuzzingFunctions
79