FuzzingFunctions.webidl (6445B)
1 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* This Source Code Form is subject to the terms of the Mozilla Public 3 * License, v. 2.0. If a copy of the MPL was not distributed with this file, 4 * You can obtain one at http://mozilla.org/MPL/2.0/. 5 */ 6 7 /* 8 * Various functions useful for automated fuzzing that are enabled 9 * only in --enable-fuzzing builds, because they may be dangerous to 10 * enable on untrusted pages. 11 */ 12 13 [Pref="fuzzing.enabled", 14 Exposed=Window] 15 namespace FuzzingFunctions { 16 /** 17 * Synchronously perform a garbage collection. 18 */ 19 undefined garbageCollect(); 20 21 /** 22 * Synchronously perform a compacting garbage collection. 23 */ 24 undefined garbageCollectCompacting(); 25 26 /** 27 * Trigger a forced crash. 28 */ 29 undefined crash(optional DOMString reason = ""); 30 31 /** 32 * Gracefully kill the GPU process 33 */ 34 undefined killGPUProcess(); 35 36 /** 37 * Synchronously perform a cycle collection. 38 */ 39 undefined cycleCollect(); 40 41 /** 42 * Send a memory pressure event, causes shrinking GC, cycle collection and 43 * other actions. 44 */ 45 undefined memoryPressure(); 46 47 /** 48 * Enable accessibility. 49 */ 50 [Throws] 51 undefined enableAccessibility(); 52 53 /** 54 * Send IPC fuzzing ready event to parent. 55 */ 56 undefined signalIPCReady(); 57 58 /** 59 * synthesizeKeyboardEvents() synthesizes a set of "keydown", 60 * "keypress" (only when it's necessary) and "keyup" events in top DOM window 61 * in current process (and the synthesized events will be retargeted to 62 * focused window/document/element). I.e, this is currently not dispatched 63 * via the main process if you call this in a content process. Therefore, in 64 * the case, some default action handlers which are only in the main process 65 * will never run. Note that this does not allow to synthesize keyboard 66 * events if this is called from a keyboard event or composition event 67 * listener. 68 * 69 * @param aKeyValue If you want to synthesize non-printable key 70 * events, you need to set one of key values 71 * defined by "UI Events KeyboardEvent key Values". 72 * You can check our current support values in 73 * dom/events/KeyNameList.h 74 * If you want to synthesize printable key events, 75 * you can set any string value including empty 76 * string. 77 * Note that |key| value in aDictionary is always 78 * ignored. 79 * @param aDictionary If you want to synthesize simple key press 80 * without any modifiers, you can omit this. 81 * Otherwise, specify this with proper values. 82 * If |code| is omitted or empty string, this 83 * guesses proper code value in US-English 84 * keyboard. Otherwise, the value must be empty 85 * string or known code value defined by "UI Events 86 * KeyboardEvent code Values". You can check our 87 * current support values in 88 * dom/events/PhysicalKeyCodeNameList.h. 89 * If |keyCode| is omitted or 0, this guesses 90 * proper keyCode value in US-English keyboard. 91 * If |location| is omitted or 0, this assumes 92 * that left modifier key is pressed if aKeyValue 93 * is one of such modifier keys. 94 * |key|, |isComposing|, |charCode| and |which| 95 * are always ignored. 96 * Modifier states like |shiftKey|, |altKey|, 97 * |modifierAltGraph|, |modifierCapsLock| and 98 * |modifierNumLock| are not adjusted for 99 * aKeyValue. Please specify them manually if 100 * necessary. 101 * Note that this API does not allow to dispatch 102 * known key events with empty |code| value and 103 * 0 |keyCode| value since it's unsual situation 104 * especially 0 |keyCode| value with known key. 105 * Note that when you specify only one of |code| 106 * and |keyCode| value, the other will be guessed 107 * from US-English keyboard layout. So, if you 108 * want to emulate key press with another keyboard 109 * layout, you should specify both values. 110 * 111 * For example: 112 * // Synthesize "Tab" key events. 113 * synthesizeKeyboardEvents("Tab"); 114 * // Synthesize Shift + Tab key events. 115 * synthesizeKeyboardEvents("Tab", { shiftKey: true }); 116 * // Synthesize Control + A key events. 117 * synthesizeKeyboardEvents("a", { controlKey: true }); 118 * // Synthesize Control + Shift + A key events. 119 * synthesizeKeyboardEvents("A", { controlKey: true, 120 * shitKey: true }); 121 * // Synthesize "Enter" key on numpad. 122 * synthesizeKeyboardEvents("Enter", { code: "NumpadEnter" }); 123 * // Synthesize right "Shift" key. 124 * synthesizeKeyboardEvents("Shift", { code: "ShiftRight" }); 125 * // Synthesize "1" on numpad. 126 * synthesizeKeyboardEvents("1", { code: "Numpad1", 127 * modifierNumLock: true }); 128 * // Synthesize "End" on numpad. 129 * synthesizeKeyboardEvents("End", { code: "Numpad1" }); 130 * // Synthesize "%" key of US-English keyboard layout. 131 * synthesizeKeyboardEvents("%", { shiftKey: true }); 132 * // Synthesize "*" key of Japanese keyboard layout. 133 * synthesizeKeyboardEvents("*", { code: "Quote", 134 * shiftKey: true, 135 * keyCode: KeyboardEvent.DOM_VK_COLON }); 136 */ 137 [Throws] 138 undefined synthesizeKeyboardEvents(DOMString aKeyValue, 139 optional KeyboardEventInit aDictionary = {}); 140 141 /** 142 * Spin the event loop for aMilliseconds. 143 */ 144 undefined spinEventLoopFor(unsigned long aMilliseconds); 145 };