Sat, 03 Jan 2015 20:18:00 +0100
Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.
michael@0 | 1 | /* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #include "nsISupports.idl" |
michael@0 | 7 | |
michael@0 | 8 | %{ C++ |
michael@0 | 9 | #include "jsdebug.h" |
michael@0 | 10 | #include "nsAString.h" |
michael@0 | 11 | %} |
michael@0 | 12 | |
michael@0 | 13 | [ptr] native JSDContext(JSDContext); |
michael@0 | 14 | [ptr] native JSDObject(JSDObject); |
michael@0 | 15 | [ptr] native JSDProperty(JSDProperty); |
michael@0 | 16 | [ptr] native JSDScript(JSDScript); |
michael@0 | 17 | [ptr] native JSDStackFrameInfo(JSDStackFrameInfo); |
michael@0 | 18 | [ptr] native JSDThreadState(JSDThreadState); |
michael@0 | 19 | [ptr] native JSDValue(JSDValue); |
michael@0 | 20 | [ptr] native JSRuntime(JSRuntime); |
michael@0 | 21 | [ptr] native JSContext(JSContext); |
michael@0 | 22 | [ptr] native JSCompartment(JSCompartment); |
michael@0 | 23 | |
michael@0 | 24 | /* interfaces we declare in this file */ |
michael@0 | 25 | interface jsdIDebuggerService; |
michael@0 | 26 | interface jsdIFilter; |
michael@0 | 27 | interface jsdINestCallback; |
michael@0 | 28 | interface jsdIFilterEnumerator; |
michael@0 | 29 | interface jsdIContextEnumerator; |
michael@0 | 30 | interface jsdIScriptEnumerator; |
michael@0 | 31 | interface jsdIScriptHook; |
michael@0 | 32 | interface jsdIErrorHook; |
michael@0 | 33 | interface jsdIExecutionHook; |
michael@0 | 34 | interface jsdICallHook; |
michael@0 | 35 | interface jsdIEphemeral; |
michael@0 | 36 | interface jsdIContext; |
michael@0 | 37 | interface jsdIStackFrame; |
michael@0 | 38 | interface jsdIScript; |
michael@0 | 39 | interface jsdIValue; |
michael@0 | 40 | interface jsdIObject; |
michael@0 | 41 | interface jsdIProperty; |
michael@0 | 42 | interface jsdIActivationCallback; |
michael@0 | 43 | |
michael@0 | 44 | /** |
michael@0 | 45 | * Debugger service. It is not a good idea to have more than one active client |
michael@0 | 46 | * of the debugger service. |
michael@0 | 47 | * |
michael@0 | 48 | * Note that all the APIs in this file are deprecated. All consumers of |
michael@0 | 49 | * these interfaces should switch to using the new Debugger API, documented |
michael@0 | 50 | * here: https://wiki.mozilla.org/Debugger |
michael@0 | 51 | */ |
michael@0 | 52 | [scriptable, uuid(39609752-2d73-4019-a324-a374dee16d3c)] |
michael@0 | 53 | interface jsdIDebuggerService : nsISupports |
michael@0 | 54 | { |
michael@0 | 55 | /** Internal use only. */ |
michael@0 | 56 | [noscript] readonly attribute JSDContext JSDContext; |
michael@0 | 57 | |
michael@0 | 58 | /** |
michael@0 | 59 | * Called when an error or warning occurs. |
michael@0 | 60 | */ |
michael@0 | 61 | attribute jsdIErrorHook errorHook; |
michael@0 | 62 | /** |
michael@0 | 63 | * Called when a jsdIScript is created or destroyed. |
michael@0 | 64 | */ |
michael@0 | 65 | attribute jsdIScriptHook scriptHook; |
michael@0 | 66 | /** |
michael@0 | 67 | * Called when the engine encounters a breakpoint. |
michael@0 | 68 | */ |
michael@0 | 69 | attribute jsdIExecutionHook breakpointHook; |
michael@0 | 70 | /** |
michael@0 | 71 | * Called when the engine encounters the debugger keyword. |
michael@0 | 72 | */ |
michael@0 | 73 | attribute jsdIExecutionHook debuggerHook; |
michael@0 | 74 | /** |
michael@0 | 75 | * Called when the errorHook returns false. |
michael@0 | 76 | */ |
michael@0 | 77 | attribute jsdIExecutionHook debugHook; |
michael@0 | 78 | /** |
michael@0 | 79 | * Called before the next PC is executed. |
michael@0 | 80 | */ |
michael@0 | 81 | attribute jsdIExecutionHook interruptHook; |
michael@0 | 82 | /** |
michael@0 | 83 | * Called when an exception is thrown (even if it will be caught.) |
michael@0 | 84 | */ |
michael@0 | 85 | attribute jsdIExecutionHook throwHook; |
michael@0 | 86 | /** |
michael@0 | 87 | * Called before and after a toplevel script is evaluated. |
michael@0 | 88 | */ |
michael@0 | 89 | attribute jsdICallHook topLevelHook; |
michael@0 | 90 | /** |
michael@0 | 91 | * Called before and after a function is called. |
michael@0 | 92 | */ |
michael@0 | 93 | attribute jsdICallHook functionHook; |
michael@0 | 94 | |
michael@0 | 95 | /** |
michael@0 | 96 | * Link native frames in call stacks. |
michael@0 | 97 | */ |
michael@0 | 98 | const unsigned long ENABLE_NATIVE_FRAMES = 0x01; |
michael@0 | 99 | /** |
michael@0 | 100 | * Normally, if a script has a 0 in JSD_SCRIPT_PROFILE_BIT it is included in |
michael@0 | 101 | * profile data, otherwise it is not profiled. Setting the |
michael@0 | 102 | * PROFILE_WHEN_SET flag reverses this convention. |
michael@0 | 103 | */ |
michael@0 | 104 | const unsigned long PROFILE_WHEN_SET = 0x02; |
michael@0 | 105 | /** |
michael@0 | 106 | * Normally, when the script in the top frame of a thread state has a 1 in |
michael@0 | 107 | * JSD_SCRIPT_DEBUG_BIT, the execution hook is ignored. Setting the |
michael@0 | 108 | * DEBUG_WHEN_SET flag reverses this convention. |
michael@0 | 109 | */ |
michael@0 | 110 | const unsigned long DEBUG_WHEN_SET = 0x04; |
michael@0 | 111 | /** |
michael@0 | 112 | * When this flag is set the internal call hook will collect profile data. |
michael@0 | 113 | */ |
michael@0 | 114 | const unsigned long COLLECT_PROFILE_DATA = 0x08; |
michael@0 | 115 | /** |
michael@0 | 116 | * When this flag is set, stack frames that are disabled for debugging |
michael@0 | 117 | * will not appear in the call stack chain. |
michael@0 | 118 | */ |
michael@0 | 119 | const unsigned long HIDE_DISABLED_FRAMES = 0x10; |
michael@0 | 120 | /** |
michael@0 | 121 | * When this flag is set, the debugger will only check the |
michael@0 | 122 | * JSD_SCRIPT_DEBUG_BIT on the top (most recent) stack frame. This |
michael@0 | 123 | * makes it possible to stop in an enabled frame which was called from |
michael@0 | 124 | * a stack that contains a disabled frame. |
michael@0 | 125 | * |
michael@0 | 126 | * When this flag is *not* set, any stack that contains a disabled frame |
michael@0 | 127 | * will not be debugged (the execution hook will not be invoked.) |
michael@0 | 128 | * |
michael@0 | 129 | * This only applies when the reason for calling the hook would have |
michael@0 | 130 | * been TYPE_INTERRUPTED or TYPE_THROW. TYPE_BREAKPOINT, |
michael@0 | 131 | * TYPE_DEBUG_REQUESTED, and TYPE_DEBUGGER_KEYWORD always stop, regardless |
michael@0 | 132 | * of this setting, as long as the top frame is not disabled. |
michael@0 | 133 | * |
michael@0 | 134 | * If HIDE_DISABLED_FRAMES is set, this is effectively set as well. |
michael@0 | 135 | */ |
michael@0 | 136 | const unsigned long MASK_TOP_FRAME_ONLY = 0x20; |
michael@0 | 137 | /** |
michael@0 | 138 | * This flag has been retired, do not re-use. It previously provided a hook |
michael@0 | 139 | * for object allocation. |
michael@0 | 140 | */ |
michael@0 | 141 | const unsigned long DISABLE_OBJECT_TRACE_RETIRED = 0x40; |
michael@0 | 142 | |
michael@0 | 143 | /** |
michael@0 | 144 | * Debugger service flags. |
michael@0 | 145 | */ |
michael@0 | 146 | attribute unsigned long flags; |
michael@0 | 147 | |
michael@0 | 148 | /** |
michael@0 | 149 | * Major version number of implementation. |
michael@0 | 150 | */ |
michael@0 | 151 | readonly attribute unsigned long implementationMajor; |
michael@0 | 152 | /** |
michael@0 | 153 | * Minor version number of implementation. |
michael@0 | 154 | */ |
michael@0 | 155 | readonly attribute unsigned long implementationMinor; |
michael@0 | 156 | /** |
michael@0 | 157 | * Free form AUTF8String identifier for implementation. |
michael@0 | 158 | */ |
michael@0 | 159 | readonly attribute AUTF8String implementationString; |
michael@0 | 160 | |
michael@0 | 161 | /** |
michael@0 | 162 | * |true| if the debugger service has been turned on. This does not |
michael@0 | 163 | * necessarily mean another app is actively using the service, as the |
michael@0 | 164 | * autostart pref may have turned the service on. |
michael@0 | 165 | */ |
michael@0 | 166 | readonly attribute boolean isOn; |
michael@0 | 167 | |
michael@0 | 168 | |
michael@0 | 169 | /** |
michael@0 | 170 | * Synchronous activation of the debugger is no longer supported, |
michael@0 | 171 | * and will throw an exception. |
michael@0 | 172 | */ |
michael@0 | 173 | void on(); |
michael@0 | 174 | |
michael@0 | 175 | /** |
michael@0 | 176 | * Turn on the debugger. This function should only be called from |
michael@0 | 177 | * JavaScript code. The debugger will be enabled on the runtime the call is |
michael@0 | 178 | * made on, as determined by nsIXPCNativeCallContext. |
michael@0 | 179 | * |
michael@0 | 180 | * The debugger will be activated asynchronously, because there can be no |
michael@0 | 181 | * JS on the stack when code is to be re-compiled for debug mode. |
michael@0 | 182 | */ |
michael@0 | 183 | void asyncOn(in jsdIActivationCallback callback); |
michael@0 | 184 | |
michael@0 | 185 | /** |
michael@0 | 186 | * Called by nsIXPConnect after it's had a chance to recompile for |
michael@0 | 187 | * debug mode. |
michael@0 | 188 | */ |
michael@0 | 189 | [noscript] void activateDebugger(in JSRuntime rt); |
michael@0 | 190 | |
michael@0 | 191 | /** |
michael@0 | 192 | * Called by nsIXPConnect to deactivate debugger on setup failure. |
michael@0 | 193 | */ |
michael@0 | 194 | [noscript] void deactivateDebugger(); |
michael@0 | 195 | |
michael@0 | 196 | /** |
michael@0 | 197 | * Recompile all active scripts in the runtime for debugMode. |
michael@0 | 198 | */ |
michael@0 | 199 | [noscript] void recompileForDebugMode(in JSContext cx, in JSCompartment comp, in boolean mode); |
michael@0 | 200 | |
michael@0 | 201 | /** |
michael@0 | 202 | * Turn the debugger off. This will invalidate all of your jsdIEphemeral |
michael@0 | 203 | * derived objects, and clear all of your breakpoints. |
michael@0 | 204 | */ |
michael@0 | 205 | void off (); |
michael@0 | 206 | |
michael@0 | 207 | /** |
michael@0 | 208 | * Peek at the current pause depth of the debugger. |
michael@0 | 209 | * |
michael@0 | 210 | * @return depth Number of pause() calls still waiting to be unPause()d. |
michael@0 | 211 | */ |
michael@0 | 212 | readonly attribute unsigned long pauseDepth; |
michael@0 | 213 | /** |
michael@0 | 214 | * Temporarily disable the debugger. Hooks will not be called while the |
michael@0 | 215 | * debugger is paused. Multiple calls to pause will increase the "pause |
michael@0 | 216 | * depth", and equal number of unPause calles must be made to resume |
michael@0 | 217 | * normal debugging. |
michael@0 | 218 | * |
michael@0 | 219 | * @return depth Number of times pause has been called since the debugger |
michael@0 | 220 | * has been unpaused. |
michael@0 | 221 | */ |
michael@0 | 222 | unsigned long pause(); |
michael@0 | 223 | /** |
michael@0 | 224 | * Undo a pause. Once this is called, the debugger won't start |
michael@0 | 225 | * getting execution callbacks until the stack is fully unwound so |
michael@0 | 226 | * that no JS scripts are live. There is no way to query whether |
michael@0 | 227 | * there are such scripts left to unwind at a given point in time. |
michael@0 | 228 | * |
michael@0 | 229 | * @return depth The number of remaining pending pause calls. |
michael@0 | 230 | */ |
michael@0 | 231 | unsigned long unPause(); |
michael@0 | 232 | |
michael@0 | 233 | /** |
michael@0 | 234 | * Force the engine to perform garbage collection. |
michael@0 | 235 | */ |
michael@0 | 236 | void GC(); |
michael@0 | 237 | |
michael@0 | 238 | /** |
michael@0 | 239 | * Clear profile data for all scripts. |
michael@0 | 240 | */ |
michael@0 | 241 | void clearProfileData(); |
michael@0 | 242 | |
michael@0 | 243 | /** |
michael@0 | 244 | * Adds an execution hook filter. These filters are consulted each time one |
michael@0 | 245 | * of the jsdIExecutionHooks is about to be called. Filters are matched in |
michael@0 | 246 | * a first in, first compared fashion. The first filter to match determines |
michael@0 | 247 | * whether or not the hook is called. Use swapFilter to reorder existing |
michael@0 | 248 | * filters, and removeFilter to remove them. |
michael@0 | 249 | * |
michael@0 | 250 | * If |filter| is already present this method throws NS_ERROR_INVALID_ARG. |
michael@0 | 251 | * |
michael@0 | 252 | * @param filter Object representing the filter to add. |
michael@0 | 253 | * @param after Insert |filter| after this one. Pass null to insert at |
michael@0 | 254 | * the beginning. |
michael@0 | 255 | */ |
michael@0 | 256 | void insertFilter(in jsdIFilter filter, in jsdIFilter after); |
michael@0 | 257 | /** |
michael@0 | 258 | * Same as insertFilter, except always add to the end of the list. |
michael@0 | 259 | */ |
michael@0 | 260 | void appendFilter(in jsdIFilter filter); |
michael@0 | 261 | /** |
michael@0 | 262 | * Remove a filter. |
michael@0 | 263 | * |
michael@0 | 264 | * If |filter| is not present this method throws NS_ERROR_INVALID_ARG. |
michael@0 | 265 | * |
michael@0 | 266 | * @param filter Object representing the filter to remove. Must be the exact |
michael@0 | 267 | * object passed to addFilter, not just a new object with the same |
michael@0 | 268 | * properties. |
michael@0 | 269 | */ |
michael@0 | 270 | void removeFilter(in jsdIFilter filter); |
michael@0 | 271 | /** |
michael@0 | 272 | * Swap position of two filters. |
michael@0 | 273 | * |
michael@0 | 274 | * If |filter_a| is not present, this method throws NS_ERROR_INVALID_ARG. |
michael@0 | 275 | * If |filter_b| is not present, filter_a is replaced by filter_b. |
michael@0 | 276 | * If |filter_a| == |filter_b|, then filter is refreshed. |
michael@0 | 277 | */ |
michael@0 | 278 | void swapFilters(in jsdIFilter filter_a, in jsdIFilter filter_b); |
michael@0 | 279 | /** |
michael@0 | 280 | * Enumerate registered filters. This routine refreshes each filter before |
michael@0 | 281 | * passing them on to the enumeration function. Calling this with a null |
michael@0 | 282 | * |enumerator| is equivalent to jsdIService::refreshFilters. |
michael@0 | 283 | * |
michael@0 | 284 | * @param enumerator jsdIFilterEnumerator instance to be called back for the |
michael@0 | 285 | * enumeration. |
michael@0 | 286 | */ |
michael@0 | 287 | void enumerateFilters(in jsdIFilterEnumerator enumerator); |
michael@0 | 288 | /** |
michael@0 | 289 | * Force the debugger to resync its internal filter cache with the |
michael@0 | 290 | * actual values in the jsdIFilter objects. To refresh a single filter |
michael@0 | 291 | * use jsdIService::swapFilters. This method is equivalent to |
michael@0 | 292 | * jsdIService::enumerateFilters with a null enumerator. |
michael@0 | 293 | */ |
michael@0 | 294 | void refreshFilters(); |
michael@0 | 295 | /** |
michael@0 | 296 | * Clear the list of filters. |
michael@0 | 297 | */ |
michael@0 | 298 | void clearFilters(); |
michael@0 | 299 | |
michael@0 | 300 | /** |
michael@0 | 301 | * Enumerate all known contexts. |
michael@0 | 302 | */ |
michael@0 | 303 | void enumerateContexts(in jsdIContextEnumerator enumerator); |
michael@0 | 304 | |
michael@0 | 305 | /** |
michael@0 | 306 | * Enumerate all scripts the debugger knows about. Any scripts created |
michael@0 | 307 | * before you turned the debugger on, or after turning the debugger off |
michael@0 | 308 | * will not be available unless the autostart perf is set. |
michael@0 | 309 | * |
michael@0 | 310 | * @param enumerator jsdIScriptEnumerator instance to be called back for |
michael@0 | 311 | * the enumeration. |
michael@0 | 312 | */ |
michael@0 | 313 | void enumerateScripts(in jsdIScriptEnumerator enumerator); |
michael@0 | 314 | /** |
michael@0 | 315 | * Clear all breakpoints in all scripts. |
michael@0 | 316 | */ |
michael@0 | 317 | void clearAllBreakpoints(); |
michael@0 | 318 | |
michael@0 | 319 | /** |
michael@0 | 320 | * When called from JavaScript, this method returns the jsdIValue wrapper |
michael@0 | 321 | * for the given value. If a wrapper does not exist one will be created. |
michael@0 | 322 | * When called from another language this method returns an xpconnect |
michael@0 | 323 | * defined error code. |
michael@0 | 324 | */ |
michael@0 | 325 | jsdIValue wrapValue(in jsval value); |
michael@0 | 326 | |
michael@0 | 327 | /* XXX these two routines are candidates for refactoring. The only problem |
michael@0 | 328 | * is that it is not clear where and how they should land. |
michael@0 | 329 | */ |
michael@0 | 330 | |
michael@0 | 331 | /** |
michael@0 | 332 | * Push a new network queue, and enter a new UI event loop. |
michael@0 | 333 | * @param callback jsdINestCallback instance to be called back after the |
michael@0 | 334 | * network queue has been pushed, but before the |
michael@0 | 335 | * UI loop starts. |
michael@0 | 336 | * @return depth returns the current number of times the event loop has been |
michael@0 | 337 | * nested. your code can use it for sanity checks. |
michael@0 | 338 | */ |
michael@0 | 339 | unsigned long enterNestedEventLoop(in jsdINestCallback callback); |
michael@0 | 340 | /** |
michael@0 | 341 | * Exit the current nested event loop after the current iteration completes, |
michael@0 | 342 | * and pop the network event queue. |
michael@0 | 343 | * |
michael@0 | 344 | * @return depth returns the current number of times the event loop has been |
michael@0 | 345 | * nested. your code can use it for sanity checks. |
michael@0 | 346 | */ |
michael@0 | 347 | unsigned long exitNestedEventLoop(); |
michael@0 | 348 | |
michael@0 | 349 | /** |
michael@0 | 350 | * Output dump of JS heap. |
michael@0 | 351 | * |
michael@0 | 352 | * @param fileName Filename to dump the heap into. |
michael@0 | 353 | */ |
michael@0 | 354 | void dumpHeap(in AUTF8String fileName); |
michael@0 | 355 | |
michael@0 | 356 | /** |
michael@0 | 357 | * Suppress console warnings about using JSD, which is a deprecated API. |
michael@0 | 358 | * |
michael@0 | 359 | * This applies only to the next call to asyncOn; any subsequent calls |
michael@0 | 360 | * will elicit the warning, unless you call 'acknowledgeDeprecation' |
michael@0 | 361 | * before each of them, too. This arrangement ensures that one add-on's |
michael@0 | 362 | * acknowledgement doesn't suppress warnings for other add-ons. |
michael@0 | 363 | */ |
michael@0 | 364 | void acknowledgeDeprecation(); |
michael@0 | 365 | }; |
michael@0 | 366 | |
michael@0 | 367 | /* callback interfaces */ |
michael@0 | 368 | |
michael@0 | 369 | /** |
michael@0 | 370 | * Object representing a pattern of global object and/or url the debugger should |
michael@0 | 371 | * ignore. The debugger service itself will not modify properties of these |
michael@0 | 372 | * objects. |
michael@0 | 373 | */ |
michael@0 | 374 | [scriptable, uuid(9ae587cd-b78c-47f0-a612-4b3a211a6a71)] |
michael@0 | 375 | interface jsdIFilter : nsISupports |
michael@0 | 376 | { |
michael@0 | 377 | /** |
michael@0 | 378 | * These two bytes of the flags attribute are reserved for interpretation |
michael@0 | 379 | * by the jsdService implementation. You can do what you like with the |
michael@0 | 380 | * remaining flags. |
michael@0 | 381 | */ |
michael@0 | 382 | const unsigned long FLAG_RESERVED_MASK = 0xFF; |
michael@0 | 383 | /** |
michael@0 | 384 | * Filters without this flag set are ignored. |
michael@0 | 385 | */ |
michael@0 | 386 | const unsigned long FLAG_ENABLED = 0x01; |
michael@0 | 387 | /** |
michael@0 | 388 | * Filters with this flag set are "pass" filters, they allow matching hooks |
michael@0 | 389 | * to continue. Filters without this flag block matching hooks. |
michael@0 | 390 | */ |
michael@0 | 391 | const unsigned long FLAG_PASS = 0x02; |
michael@0 | 392 | |
michael@0 | 393 | /** |
michael@0 | 394 | * FLAG_* values from above, OR'd together. |
michael@0 | 395 | */ |
michael@0 | 396 | attribute unsigned long flags; |
michael@0 | 397 | |
michael@0 | 398 | /** |
michael@0 | 399 | * String representing the url pattern to be filtered. Supports limited |
michael@0 | 400 | * glob matching, at the beginning and end of the pattern only. For example, |
michael@0 | 401 | * "chrome://venkman*" filters all urls that start with chrome/venkman, |
michael@0 | 402 | * "*.cgi" filters all cgi's, and "http://myserver/utils.js" filters only |
michael@0 | 403 | * the utils.js file on "myserver". A null urlPattern matches all urls. |
michael@0 | 404 | * |
michael@0 | 405 | * The jsdIService caches this value internally, to if it changes you must |
michael@0 | 406 | * swap the filter with itself using jsdIService::swapFilters. |
michael@0 | 407 | */ |
michael@0 | 408 | attribute AUTF8String urlPattern; |
michael@0 | 409 | |
michael@0 | 410 | /** |
michael@0 | 411 | * Line number for the start of this filter. Line numbers are one based. |
michael@0 | 412 | * Assigning a 0 to this attribute will tell the debugger to ignore the |
michael@0 | 413 | * entire file. |
michael@0 | 414 | */ |
michael@0 | 415 | attribute unsigned long startLine; |
michael@0 | 416 | |
michael@0 | 417 | /** |
michael@0 | 418 | * Line number for the end of this filter. Line numbers are one based. |
michael@0 | 419 | * Assigning a 0 to this attribute will tell the debugger to ignore from |
michael@0 | 420 | * |startLine| to the end of the file. |
michael@0 | 421 | */ |
michael@0 | 422 | attribute unsigned long endLine; |
michael@0 | 423 | }; |
michael@0 | 424 | |
michael@0 | 425 | /** |
michael@0 | 426 | * Notify client code that debugMode has been activated. |
michael@0 | 427 | */ |
michael@0 | 428 | [scriptable, function, uuid(6da7f5fb-3a84-4abe-9e23-8b2045960732)] |
michael@0 | 429 | interface jsdIActivationCallback : nsISupports |
michael@0 | 430 | { |
michael@0 | 431 | void onDebuggerActivated(); |
michael@0 | 432 | }; |
michael@0 | 433 | |
michael@0 | 434 | /** |
michael@0 | 435 | * Pass an instance of one of these to jsdIDebuggerService::enterNestedEventLoop. |
michael@0 | 436 | */ |
michael@0 | 437 | [scriptable, function, uuid(88bea60f-9b5d-4b39-b08b-1c3a278782c6)] |
michael@0 | 438 | interface jsdINestCallback : nsISupports |
michael@0 | 439 | { |
michael@0 | 440 | /** |
michael@0 | 441 | * This method will be called after pre-nesting work has completed, such |
michael@0 | 442 | * as pushing the js context and network event queue, but before the new |
michael@0 | 443 | * event loop starts. |
michael@0 | 444 | */ |
michael@0 | 445 | void onNest(); |
michael@0 | 446 | }; |
michael@0 | 447 | |
michael@0 | 448 | /** |
michael@0 | 449 | * Pass an instance of one of these to jsdIDebuggerService::enumerateFilters. |
michael@0 | 450 | */ |
michael@0 | 451 | [scriptable, function, uuid(e391ba85-9379-4762-b387-558e38db730f)] |
michael@0 | 452 | interface jsdIFilterEnumerator : nsISupports |
michael@0 | 453 | { |
michael@0 | 454 | /** |
michael@0 | 455 | * The enumerateFilter method will be called once for every filter the |
michael@0 | 456 | * debugger knows about. |
michael@0 | 457 | */ |
michael@0 | 458 | void enumerateFilter(in jsdIFilter filter); |
michael@0 | 459 | }; |
michael@0 | 460 | |
michael@0 | 461 | /** |
michael@0 | 462 | * Pass an instance of one of these to jsdIDebuggerService::enumerateScripts. |
michael@0 | 463 | */ |
michael@0 | 464 | [scriptable, function, uuid(4eef60c2-9bbc-48fa-b196-646a832c6c81)] |
michael@0 | 465 | interface jsdIScriptEnumerator : nsISupports |
michael@0 | 466 | { |
michael@0 | 467 | /** |
michael@0 | 468 | * The enumerateScript method will be called once for every script the |
michael@0 | 469 | * debugger knows about. |
michael@0 | 470 | */ |
michael@0 | 471 | void enumerateScript(in jsdIScript script); |
michael@0 | 472 | }; |
michael@0 | 473 | |
michael@0 | 474 | /** |
michael@0 | 475 | * Pass an instance of one of these to jsdIDebuggerService::enumerateContexts. |
michael@0 | 476 | */ |
michael@0 | 477 | [scriptable, function, uuid(57d18286-550c-4ca9-ac33-56f12ebba91e)] |
michael@0 | 478 | interface jsdIContextEnumerator : nsISupports |
michael@0 | 479 | { |
michael@0 | 480 | /** |
michael@0 | 481 | * The enumerateContext method will be called once for every context |
michael@0 | 482 | * currently in use. |
michael@0 | 483 | */ |
michael@0 | 484 | void enumerateContext(in jsdIContext executionContext); |
michael@0 | 485 | }; |
michael@0 | 486 | |
michael@0 | 487 | /** |
michael@0 | 488 | * Set jsdIDebuggerService::scriptHook to an instance of one of these. |
michael@0 | 489 | */ |
michael@0 | 490 | [scriptable, uuid(d030d1a2-a58a-4f19-b9e3-96da4e2cdd09)] |
michael@0 | 491 | interface jsdIScriptHook : nsISupports |
michael@0 | 492 | { |
michael@0 | 493 | /** |
michael@0 | 494 | * Called when scripts are created. |
michael@0 | 495 | */ |
michael@0 | 496 | void onScriptCreated(in jsdIScript script); |
michael@0 | 497 | /** |
michael@0 | 498 | * Called when the JavaScript engine destroys a script. The jsdIScript |
michael@0 | 499 | * object passed in will already be invalidated. |
michael@0 | 500 | */ |
michael@0 | 501 | void onScriptDestroyed(in jsdIScript script); |
michael@0 | 502 | }; |
michael@0 | 503 | |
michael@0 | 504 | /** |
michael@0 | 505 | * Hook instances of this interface up to the |
michael@0 | 506 | * jsdIDebuggerService::functionHook and toplevelHook properties. |
michael@0 | 507 | */ |
michael@0 | 508 | [scriptable, function, uuid(3eff1314-7ae3-4cf8-833b-c33c24a55633)] |
michael@0 | 509 | interface jsdICallHook : nsISupports |
michael@0 | 510 | { |
michael@0 | 511 | /** |
michael@0 | 512 | * TYPE_* values must be kept in sync with the JSD_HOOK_* #defines |
michael@0 | 513 | * in jsdebug.h. |
michael@0 | 514 | */ |
michael@0 | 515 | |
michael@0 | 516 | /** |
michael@0 | 517 | * Toplevel script is starting. |
michael@0 | 518 | */ |
michael@0 | 519 | const unsigned long TYPE_TOPLEVEL_START = 0; |
michael@0 | 520 | /** |
michael@0 | 521 | * Toplevel script has completed. |
michael@0 | 522 | */ |
michael@0 | 523 | const unsigned long TYPE_TOPLEVEL_END = 1; |
michael@0 | 524 | /** |
michael@0 | 525 | * Function is being called. |
michael@0 | 526 | */ |
michael@0 | 527 | const unsigned long TYPE_FUNCTION_CALL = 2; |
michael@0 | 528 | /** |
michael@0 | 529 | * Function is returning. |
michael@0 | 530 | */ |
michael@0 | 531 | const unsigned long TYPE_FUNCTION_RETURN = 3; |
michael@0 | 532 | |
michael@0 | 533 | /** |
michael@0 | 534 | * Called before the JavaScript engine executes a top level script or calls |
michael@0 | 535 | * a function. |
michael@0 | 536 | */ |
michael@0 | 537 | void onCall(in jsdIStackFrame frame, in unsigned long type); |
michael@0 | 538 | }; |
michael@0 | 539 | |
michael@0 | 540 | [scriptable, function, uuid(e6b45eee-d974-4d85-9d9e-f5a67218deb4)] |
michael@0 | 541 | interface jsdIErrorHook : nsISupports |
michael@0 | 542 | { |
michael@0 | 543 | /** |
michael@0 | 544 | * REPORT_* values must be kept in sync with JSREPORT_* #defines in |
michael@0 | 545 | * jsapi.h |
michael@0 | 546 | */ |
michael@0 | 547 | |
michael@0 | 548 | /** |
michael@0 | 549 | * Report is an error. |
michael@0 | 550 | */ |
michael@0 | 551 | const unsigned long REPORT_ERROR = 0x00; |
michael@0 | 552 | /** |
michael@0 | 553 | * Report is only a warning. |
michael@0 | 554 | */ |
michael@0 | 555 | const unsigned long REPORT_WARNING = 0x01; |
michael@0 | 556 | /** |
michael@0 | 557 | * Report represents an uncaught exception. |
michael@0 | 558 | */ |
michael@0 | 559 | const unsigned long REPORT_EXCEPTION = 0x02; |
michael@0 | 560 | /** |
michael@0 | 561 | * Report is due to strict mode. |
michael@0 | 562 | */ |
michael@0 | 563 | const unsigned long REPORT_STRICT = 0x04; |
michael@0 | 564 | |
michael@0 | 565 | /** |
michael@0 | 566 | * Called when the JavaScript engine encounters an error. Return |true| |
michael@0 | 567 | * to pass the error along, |false| to invoke the debugHook. |
michael@0 | 568 | */ |
michael@0 | 569 | boolean onError(in AUTF8String message, in AUTF8String fileName, |
michael@0 | 570 | in unsigned long line, in unsigned long pos, |
michael@0 | 571 | in unsigned long flags, in unsigned long errnum, |
michael@0 | 572 | in jsdIValue exc); |
michael@0 | 573 | }; |
michael@0 | 574 | |
michael@0 | 575 | /** |
michael@0 | 576 | * Hook instances of this interface up to the |
michael@0 | 577 | * jsdIDebuggerService::breakpointHook, debuggerHook, errorHook, interruptHook, |
michael@0 | 578 | * and throwHook properties. |
michael@0 | 579 | */ |
michael@0 | 580 | [scriptable, function, uuid(3a722496-9d78-4f0a-a797-293d9e8cb8d2)] |
michael@0 | 581 | interface jsdIExecutionHook : nsISupports |
michael@0 | 582 | { |
michael@0 | 583 | /** |
michael@0 | 584 | * TYPE_* values must be kept in sync with JSD_HOOK_* #defines in jsdebug.h. |
michael@0 | 585 | */ |
michael@0 | 586 | |
michael@0 | 587 | /** |
michael@0 | 588 | * Execution stopped because we're in single step mode. |
michael@0 | 589 | */ |
michael@0 | 590 | const unsigned long TYPE_INTERRUPTED = 0; |
michael@0 | 591 | /** |
michael@0 | 592 | * Execution stopped by a trap instruction (i.e. breakoint.) |
michael@0 | 593 | */ |
michael@0 | 594 | const unsigned long TYPE_BREAKPOINT = 1; |
michael@0 | 595 | /** |
michael@0 | 596 | * Error handler returned an "invoke debugger" value. |
michael@0 | 597 | */ |
michael@0 | 598 | const unsigned long TYPE_DEBUG_REQUESTED = 2; |
michael@0 | 599 | /** |
michael@0 | 600 | * Debugger keyword encountered. |
michael@0 | 601 | */ |
michael@0 | 602 | const unsigned long TYPE_DEBUGGER_KEYWORD = 3; |
michael@0 | 603 | /** |
michael@0 | 604 | * Exception was thrown. |
michael@0 | 605 | */ |
michael@0 | 606 | const unsigned long TYPE_THROW = 4; |
michael@0 | 607 | |
michael@0 | 608 | /** |
michael@0 | 609 | * RETURN_* values must be kept in sync with JSD_HOOK_RETURN_* #defines in |
michael@0 | 610 | * jsdebug.h. |
michael@0 | 611 | */ |
michael@0 | 612 | |
michael@0 | 613 | /** |
michael@0 | 614 | * Indicates unrecoverable error processing the hook. This will cause |
michael@0 | 615 | * the script being executed to be aborted without raising a JavaScript |
michael@0 | 616 | * exception. |
michael@0 | 617 | */ |
michael@0 | 618 | const unsigned long RETURN_HOOK_ERROR = 0; |
michael@0 | 619 | /** |
michael@0 | 620 | * Continue processing normally. This is the "do nothing special" return |
michael@0 | 621 | * value for all hook types *except* TYPE_THROW. Returning RETURN_CONTINUE |
michael@0 | 622 | * from TYPE_THROW cause the exception to be ignored. Return |
michael@0 | 623 | * RETURN_CONTINUE_THROW to continue exception processing from TYPE_THROW |
michael@0 | 624 | * hooks. |
michael@0 | 625 | */ |
michael@0 | 626 | const unsigned long RETURN_CONTINUE = 1; |
michael@0 | 627 | /** |
michael@0 | 628 | * Same effect as RETURN_HOOK_ERROR. |
michael@0 | 629 | */ |
michael@0 | 630 | const unsigned long RETURN_ABORT = 2; |
michael@0 | 631 | /** |
michael@0 | 632 | * Return the value of the |val| parameter. |
michael@0 | 633 | */ |
michael@0 | 634 | const unsigned long RETURN_RET_WITH_VAL = 3; |
michael@0 | 635 | /** |
michael@0 | 636 | * Throw the value of the |val| parameter. |
michael@0 | 637 | */ |
michael@0 | 638 | const unsigned long RETURN_THROW_WITH_VAL = 4; |
michael@0 | 639 | /** |
michael@0 | 640 | * Continue the current throw. |
michael@0 | 641 | */ |
michael@0 | 642 | const unsigned long RETURN_CONTINUE_THROW = 5; |
michael@0 | 643 | |
michael@0 | 644 | /** |
michael@0 | 645 | * @param frame A jsdIStackFrame object representing the bottom stack frame. |
michael@0 | 646 | * @param type One of the jsdIExecutionHook::TYPE_ constants. |
michael@0 | 647 | * @param val in - Current exception (if any) when this method is called. |
michael@0 | 648 | * out - If you return RETURN_THROW_WITH_VAL, value to be |
michael@0 | 649 | * thrown. |
michael@0 | 650 | * If you return RETURN_RET_WITH_VAL, value to return. |
michael@0 | 651 | * All other return values, not significant. |
michael@0 | 652 | * @retval One of the jsdIExecutionHook::RETURN_* constants. |
michael@0 | 653 | */ |
michael@0 | 654 | unsigned long onExecute(in jsdIStackFrame frame, |
michael@0 | 655 | in unsigned long type, inout jsdIValue val); |
michael@0 | 656 | }; |
michael@0 | 657 | |
michael@0 | 658 | /** |
michael@0 | 659 | * Objects which inherit this interface may go away, with (jsdIScript) or |
michael@0 | 660 | * without (all others) notification. These objects are generally wrappers |
michael@0 | 661 | * around JSD structures that go away when you call jsdService::Off(). |
michael@0 | 662 | */ |
michael@0 | 663 | [scriptable, uuid(46f1e23e-1dd2-11b2-9ceb-8285f2e95e69)] |
michael@0 | 664 | interface jsdIEphemeral : nsISupports |
michael@0 | 665 | { |
michael@0 | 666 | /** |
michael@0 | 667 | * |true| if this object is still valid. If not, many or all of the methods |
michael@0 | 668 | * and/or properties of the inheritor may no longer be callable. |
michael@0 | 669 | */ |
michael@0 | 670 | readonly attribute boolean isValid; |
michael@0 | 671 | /** |
michael@0 | 672 | * Mark this instance as invalid. |
michael@0 | 673 | */ |
michael@0 | 674 | [noscript] void invalidate(); |
michael@0 | 675 | }; |
michael@0 | 676 | |
michael@0 | 677 | /* handle objects */ |
michael@0 | 678 | |
michael@0 | 679 | /** |
michael@0 | 680 | * Context object. Only context's which are also nsISupports objects can be |
michael@0 | 681 | * reflected by this interface. |
michael@0 | 682 | */ |
michael@0 | 683 | [scriptable, uuid(3e5c934d-6863-4d81-96f5-76a3b962fc2b)] |
michael@0 | 684 | interface jsdIContext : jsdIEphemeral |
michael@0 | 685 | { |
michael@0 | 686 | /* Internal use only. */ |
michael@0 | 687 | [noscript] readonly attribute JSContext JSContext; |
michael@0 | 688 | |
michael@0 | 689 | /** |
michael@0 | 690 | * OPT_* values must be kept in sync with JSOPTION_* #defines in jsapi.h. |
michael@0 | 691 | */ |
michael@0 | 692 | |
michael@0 | 693 | /** |
michael@0 | 694 | * Strict mode is on. |
michael@0 | 695 | */ |
michael@0 | 696 | const long OPT_STRICT = 0x01; |
michael@0 | 697 | /** |
michael@0 | 698 | * Warnings reported as errors. |
michael@0 | 699 | */ |
michael@0 | 700 | const long OPT_WERR = 0x02; |
michael@0 | 701 | /** |
michael@0 | 702 | * Makes eval() use the last object on its 'obj' param's scope chain as the |
michael@0 | 703 | * ECMA 'variables object'. |
michael@0 | 704 | */ |
michael@0 | 705 | const long OPT_VAROBJFIX = 0x04; |
michael@0 | 706 | /** |
michael@0 | 707 | * Private data for this object is an nsISupports object. Attempting to |
michael@0 | 708 | * alter this bit will result in an NS_ERROR_ILLEGAL_VALUE. |
michael@0 | 709 | */ |
michael@0 | 710 | const long OPT_ISUPPORTS = 0x08; |
michael@0 | 711 | /** |
michael@0 | 712 | * OPT_* values above, OR'd together. |
michael@0 | 713 | */ |
michael@0 | 714 | attribute unsigned long options; |
michael@0 | 715 | |
michael@0 | 716 | /** |
michael@0 | 717 | * Unique tag among all valid jsdIContext objects, useful as a hash key. |
michael@0 | 718 | */ |
michael@0 | 719 | readonly attribute unsigned long tag; |
michael@0 | 720 | |
michael@0 | 721 | /** |
michael@0 | 722 | * Private data for this context, if it is an nsISupports, |null| otherwise. |
michael@0 | 723 | */ |
michael@0 | 724 | readonly attribute nsISupports privateData; |
michael@0 | 725 | |
michael@0 | 726 | /** |
michael@0 | 727 | * Retrieve the underlying context wrapped by this jsdIContext. |
michael@0 | 728 | */ |
michael@0 | 729 | readonly attribute nsISupports wrappedContext; |
michael@0 | 730 | |
michael@0 | 731 | /** |
michael@0 | 732 | * Top of the scope chain for this context. |
michael@0 | 733 | */ |
michael@0 | 734 | readonly attribute jsdIValue globalObject; |
michael@0 | 735 | |
michael@0 | 736 | /** |
michael@0 | 737 | * |true| if this context should be allowed to run scripts, |false| |
michael@0 | 738 | * otherwise. This attribute is only valid for contexts which implement |
michael@0 | 739 | * nsIScriptContext. Setting or getting this attribute on any other |
michael@0 | 740 | * context will throw a NS_ERROR_NO_INTERFACE exception. |
michael@0 | 741 | */ |
michael@0 | 742 | attribute boolean scriptsEnabled; |
michael@0 | 743 | }; |
michael@0 | 744 | |
michael@0 | 745 | /** |
michael@0 | 746 | * Stack frame objects. These are only valid inside the jsdIExecutionHook which |
michael@0 | 747 | * gave it to you. After you return from that handler the bottom frame, and any |
michael@0 | 748 | * frame you found attached through it, are invalidated via the jsdIEphemeral |
michael@0 | 749 | * interface. Once a jsdIStackFrame has been invalidated all method and |
michael@0 | 750 | * property accesses will throw a NS_ERROR_NOT_AVAILABLE exception. |
michael@0 | 751 | */ |
michael@0 | 752 | [scriptable, uuid(7c95422c-7579-4a6f-8ef7-e5b391552ee5)] |
michael@0 | 753 | interface jsdIStackFrame : jsdIEphemeral |
michael@0 | 754 | { |
michael@0 | 755 | /** Internal use only. */ |
michael@0 | 756 | [noscript] readonly attribute JSDContext JSDContext; |
michael@0 | 757 | /** Internal use only. */ |
michael@0 | 758 | [noscript] readonly attribute JSDThreadState JSDThreadState; |
michael@0 | 759 | /** Internal use only. */ |
michael@0 | 760 | [noscript] readonly attribute JSDStackFrameInfo JSDStackFrameInfo; |
michael@0 | 761 | |
michael@0 | 762 | /** |
michael@0 | 763 | * True if stack frame represents a frame created as a result of a debugger |
michael@0 | 764 | * evaluation. |
michael@0 | 765 | */ |
michael@0 | 766 | readonly attribute boolean isDebugger; |
michael@0 | 767 | /** |
michael@0 | 768 | * True if stack frame is constructing a new object. |
michael@0 | 769 | */ |
michael@0 | 770 | readonly attribute boolean isConstructing; |
michael@0 | 771 | |
michael@0 | 772 | /** |
michael@0 | 773 | * Link to the caller's stack frame. |
michael@0 | 774 | */ |
michael@0 | 775 | readonly attribute jsdIStackFrame callingFrame; |
michael@0 | 776 | /** |
michael@0 | 777 | * Executon context. |
michael@0 | 778 | */ |
michael@0 | 779 | readonly attribute jsdIContext executionContext; |
michael@0 | 780 | /** |
michael@0 | 781 | * Function name executing in this stack frame. |
michael@0 | 782 | */ |
michael@0 | 783 | readonly attribute AUTF8String functionName; |
michael@0 | 784 | /** |
michael@0 | 785 | * Script running in this stack frame, null for native frames. |
michael@0 | 786 | */ |
michael@0 | 787 | readonly attribute jsdIScript script; |
michael@0 | 788 | /** |
michael@0 | 789 | * Current program counter in this stack frame. |
michael@0 | 790 | */ |
michael@0 | 791 | readonly attribute unsigned long pc; |
michael@0 | 792 | /** |
michael@0 | 793 | * Current line number (using the script's pc to line map.) |
michael@0 | 794 | */ |
michael@0 | 795 | readonly attribute unsigned long line; |
michael@0 | 796 | /** |
michael@0 | 797 | * Function object running in this stack frame. |
michael@0 | 798 | */ |
michael@0 | 799 | readonly attribute jsdIValue callee; |
michael@0 | 800 | /** |
michael@0 | 801 | * Top object in the scope chain. |
michael@0 | 802 | */ |
michael@0 | 803 | readonly attribute jsdIValue scope; |
michael@0 | 804 | /** |
michael@0 | 805 | * |this| object for this stack frame. |
michael@0 | 806 | */ |
michael@0 | 807 | readonly attribute jsdIValue thisValue; |
michael@0 | 808 | /** |
michael@0 | 809 | * Evaluate arbitrary JavaScript in this stack frame. |
michael@0 | 810 | * @param bytes Script to be evaluated. |
michael@0 | 811 | * @param fileName Filename to compile this script under. This is the |
michael@0 | 812 | * filename you'll see in error messages, etc. |
michael@0 | 813 | * @param line Starting line number for this script. One based. |
michael@0 | 814 | * @retval Result of evaluating the script. |
michael@0 | 815 | */ |
michael@0 | 816 | boolean eval(in AString bytes, in AUTF8String fileName, |
michael@0 | 817 | in unsigned long line, out jsdIValue result); |
michael@0 | 818 | |
michael@0 | 819 | }; |
michael@0 | 820 | |
michael@0 | 821 | /** |
michael@0 | 822 | * Script object. In JavaScript engine terms, there's a single script for each |
michael@0 | 823 | * function, and one for the top level script. |
michael@0 | 824 | */ |
michael@0 | 825 | [scriptable, uuid(8ce9b2a2-cc33-48a8-9f47-8696186ed9a5)] |
michael@0 | 826 | interface jsdIScript : jsdIEphemeral |
michael@0 | 827 | { |
michael@0 | 828 | /** Internal use only. */ |
michael@0 | 829 | [noscript] readonly attribute JSDContext JSDContext; |
michael@0 | 830 | /** Internal use only. */ |
michael@0 | 831 | [noscript] readonly attribute JSDScript JSDScript; |
michael@0 | 832 | |
michael@0 | 833 | /** |
michael@0 | 834 | * Last version set on this context. |
michael@0 | 835 | * Scripts typically select this with the "language" attribute. |
michael@0 | 836 | * See the VERSION_* consts on jsdIDebuggerService. |
michael@0 | 837 | */ |
michael@0 | 838 | readonly attribute long version; |
michael@0 | 839 | |
michael@0 | 840 | /** |
michael@0 | 841 | * Tag value guaranteed unique among jsdIScript objects. Useful as a |
michael@0 | 842 | * hash key in script. |
michael@0 | 843 | */ |
michael@0 | 844 | readonly attribute unsigned long tag; |
michael@0 | 845 | |
michael@0 | 846 | /** |
michael@0 | 847 | * FLAG_* values need to be kept in sync with JSD_SCRIPT_* #defines in |
michael@0 | 848 | * jsdebug.h. |
michael@0 | 849 | */ |
michael@0 | 850 | |
michael@0 | 851 | /** |
michael@0 | 852 | * Determines whether or not to collect profile information for this |
michael@0 | 853 | * script. The context flag FLAG_PROFILE_WHEN_SET decides the logic. |
michael@0 | 854 | */ |
michael@0 | 855 | const unsigned long FLAG_PROFILE = 0x01; |
michael@0 | 856 | /** |
michael@0 | 857 | * Determines whether or not to ignore breakpoints, etc. in this script. |
michael@0 | 858 | * The context flag JSD_DEBUG_WHEN_SET decides the logic. |
michael@0 | 859 | */ |
michael@0 | 860 | const unsigned long FLAG_DEBUG = 0x02; |
michael@0 | 861 | /** |
michael@0 | 862 | * Determines whether to invoke the onScriptDestroy callback for this |
michael@0 | 863 | * script. The default is for this to be true if the onScriptCreated |
michael@0 | 864 | * callback was invoked for this script. |
michael@0 | 865 | */ |
michael@0 | 866 | const unsigned long FLAG_CALL_DESTROY_HOOK = 0x04; |
michael@0 | 867 | |
michael@0 | 868 | /** |
michael@0 | 869 | * FLAG_* attributes from above, OR'd together. |
michael@0 | 870 | */ |
michael@0 | 871 | attribute unsigned long flags; |
michael@0 | 872 | |
michael@0 | 873 | /** |
michael@0 | 874 | * Filename given for this script when it was compiled. |
michael@0 | 875 | * This data is copied from the underlying structure when the jsdIScript |
michael@0 | 876 | * instance is created and is therefore available even after the script is |
michael@0 | 877 | * invalidated. |
michael@0 | 878 | */ |
michael@0 | 879 | readonly attribute AUTF8String fileName; |
michael@0 | 880 | /** |
michael@0 | 881 | * Function name for this script. "anonymous" for unnamed functions (or |
michael@0 | 882 | * a function actually named anonymous), empty for top level scripts. |
michael@0 | 883 | * This data is copied from the underlying structure when the jsdIScript |
michael@0 | 884 | * instance is created and is therefore available even after the script is |
michael@0 | 885 | * invalidated. |
michael@0 | 886 | */ |
michael@0 | 887 | readonly attribute AUTF8String functionName; |
michael@0 | 888 | /** |
michael@0 | 889 | * The names of the arguments for this function; empty if this is |
michael@0 | 890 | * not a function. |
michael@0 | 891 | */ |
michael@0 | 892 | void getParameterNames([optional] out unsigned long count, |
michael@0 | 893 | [array, size_is(count), retval] out wstring paramNames); |
michael@0 | 894 | /** |
michael@0 | 895 | * Fetch the function object as a jsdIValue. |
michael@0 | 896 | */ |
michael@0 | 897 | readonly attribute jsdIValue functionObject; |
michael@0 | 898 | /** |
michael@0 | 899 | * Source code for this script, without function declaration. |
michael@0 | 900 | */ |
michael@0 | 901 | readonly attribute AString functionSource; |
michael@0 | 902 | /** |
michael@0 | 903 | * Line number in source file containing the first line of this script. |
michael@0 | 904 | * This data is copied from the underlying structure when the jsdIScript |
michael@0 | 905 | * instance is created and is therefore available even after the script is |
michael@0 | 906 | * invalidated. |
michael@0 | 907 | */ |
michael@0 | 908 | readonly attribute unsigned long baseLineNumber; |
michael@0 | 909 | /** |
michael@0 | 910 | * Total number of lines in this script. |
michael@0 | 911 | * This data is copied from the underlying structure when the jsdIScript |
michael@0 | 912 | * instance is created and is therefore available even after the script is |
michael@0 | 913 | * invalidated. |
michael@0 | 914 | */ |
michael@0 | 915 | readonly attribute unsigned long lineExtent; |
michael@0 | 916 | |
michael@0 | 917 | /** |
michael@0 | 918 | * Number of times this script has been called. |
michael@0 | 919 | */ |
michael@0 | 920 | readonly attribute unsigned long callCount; |
michael@0 | 921 | /** |
michael@0 | 922 | * Number of times this script called itself, directly or indirectly. |
michael@0 | 923 | */ |
michael@0 | 924 | readonly attribute unsigned long maxRecurseDepth; |
michael@0 | 925 | /** |
michael@0 | 926 | * Shortest execution time recorded, in milliseconds. |
michael@0 | 927 | */ |
michael@0 | 928 | readonly attribute double minExecutionTime; |
michael@0 | 929 | /** |
michael@0 | 930 | * Longest execution time recorded, in milliseconds. |
michael@0 | 931 | */ |
michael@0 | 932 | readonly attribute double maxExecutionTime; |
michael@0 | 933 | /** |
michael@0 | 934 | * Total time spent in this function, in milliseconds. |
michael@0 | 935 | */ |
michael@0 | 936 | readonly attribute double totalExecutionTime; |
michael@0 | 937 | /** |
michael@0 | 938 | * Shortest execution time recorded, in milliseconds, excluding time spent |
michael@0 | 939 | * in other called code. |
michael@0 | 940 | */ |
michael@0 | 941 | readonly attribute double minOwnExecutionTime; |
michael@0 | 942 | /** |
michael@0 | 943 | * Longest execution time recorded, in milliseconds, excluding time spent |
michael@0 | 944 | * in other called code. |
michael@0 | 945 | */ |
michael@0 | 946 | readonly attribute double maxOwnExecutionTime; |
michael@0 | 947 | /** |
michael@0 | 948 | * Total time spent in this function, in milliseconds, excluding time spent |
michael@0 | 949 | * in other called code. |
michael@0 | 950 | */ |
michael@0 | 951 | readonly attribute double totalOwnExecutionTime; |
michael@0 | 952 | |
michael@0 | 953 | /** |
michael@0 | 954 | * Clear profile data for this script. |
michael@0 | 955 | */ |
michael@0 | 956 | void clearProfileData(); |
michael@0 | 957 | |
michael@0 | 958 | const unsigned long PCMAP_SOURCETEXT = 1; /* map to actual source text */ |
michael@0 | 959 | const unsigned long PCMAP_PRETTYPRINT = 2; /* map to pretty printed source */ |
michael@0 | 960 | |
michael@0 | 961 | /** |
michael@0 | 962 | * Get the closest line number to a given PC. |
michael@0 | 963 | * The |pcmap| argument specifies which pc to source line map to use. |
michael@0 | 964 | */ |
michael@0 | 965 | unsigned long pcToLine(in unsigned long pc, in unsigned long pcmap); |
michael@0 | 966 | /** |
michael@0 | 967 | * Get the first PC associated with a line. |
michael@0 | 968 | * The |pcmap| argument specifies which pc to source line map to use. |
michael@0 | 969 | */ |
michael@0 | 970 | unsigned long lineToPc(in unsigned long line, in unsigned long pcmap); |
michael@0 | 971 | /** |
michael@0 | 972 | * Determine is a particular line is executable, like checking that |
michael@0 | 973 | * lineToPc == pcToLine, except in one call. |
michael@0 | 974 | * The |pcmap| argument specifies which pc to source line map to use. |
michael@0 | 975 | */ |
michael@0 | 976 | boolean isLineExecutable(in unsigned long line, in unsigned long pcmap); |
michael@0 | 977 | |
michael@0 | 978 | /** |
michael@0 | 979 | * Return a list of all executable lines in a script. |
michael@0 | 980 | * |pcmap| specifies which pc to source line map to use. |
michael@0 | 981 | * |startLine| and |maxLines| may be used to retrieve a chunk at a time. |
michael@0 | 982 | */ |
michael@0 | 983 | void getExecutableLines(in unsigned long pcmap, |
michael@0 | 984 | in unsigned long startLine, in unsigned long maxLines, |
michael@0 | 985 | [optional] out unsigned long count, |
michael@0 | 986 | [array, size_is(count), retval] out unsigned long executableLines); |
michael@0 | 987 | |
michael@0 | 988 | /** |
michael@0 | 989 | * Set a breakpoint at a PC in this script. |
michael@0 | 990 | */ |
michael@0 | 991 | void setBreakpoint(in unsigned long pc); |
michael@0 | 992 | /** |
michael@0 | 993 | * Clear a breakpoint at a PC in this script. |
michael@0 | 994 | */ |
michael@0 | 995 | void clearBreakpoint(in unsigned long pc); |
michael@0 | 996 | /** |
michael@0 | 997 | * Clear all breakpoints set in this script. |
michael@0 | 998 | */ |
michael@0 | 999 | void clearAllBreakpoints(); |
michael@0 | 1000 | /** |
michael@0 | 1001 | * Call interrupt hook at least once per source line |
michael@0 | 1002 | */ |
michael@0 | 1003 | void enableSingleStepInterrupts(in boolean mode); |
michael@0 | 1004 | }; |
michael@0 | 1005 | |
michael@0 | 1006 | /** |
michael@0 | 1007 | * Value objects. Represents typeless JavaScript values (jsval in SpiderMonkey |
michael@0 | 1008 | * terminology.) These are valid until the debugger is turned off. Holding a |
michael@0 | 1009 | * jsdIValue adds a root for the underlying JavaScript value, so don't keep it |
michael@0 | 1010 | * if you don't need to. |
michael@0 | 1011 | */ |
michael@0 | 1012 | [scriptable, uuid(1cd3535b-4ddb-4202-9053-e0ec88f5c82b)] |
michael@0 | 1013 | interface jsdIValue : jsdIEphemeral |
michael@0 | 1014 | { |
michael@0 | 1015 | /** Internal use only. */ |
michael@0 | 1016 | [noscript] readonly attribute JSDContext JSDContext; |
michael@0 | 1017 | /** Internal use only. */ |
michael@0 | 1018 | [noscript] readonly attribute JSDValue JSDValue; |
michael@0 | 1019 | |
michael@0 | 1020 | /** |
michael@0 | 1021 | * |false| unless the value is a function declared in script. |
michael@0 | 1022 | */ |
michael@0 | 1023 | readonly attribute boolean isNative; |
michael@0 | 1024 | /** |
michael@0 | 1025 | * |true| if the value represents a number, either double or integer. |
michael@0 | 1026 | * |false| for all other values, including numbers assigned as strings |
michael@0 | 1027 | * (eg. x = "1";) |
michael@0 | 1028 | */ |
michael@0 | 1029 | readonly attribute boolean isNumber; |
michael@0 | 1030 | /** |
michael@0 | 1031 | * |true| if the value represents a JavaScript primitive number or AUTF8String |
michael@0 | 1032 | */ |
michael@0 | 1033 | readonly attribute boolean isPrimitive; |
michael@0 | 1034 | |
michael@0 | 1035 | /** Value is either |true| or |false|. */ |
michael@0 | 1036 | const unsigned long TYPE_BOOLEAN = 0; |
michael@0 | 1037 | /** Value is a primitive number that is too large to fit in an integer. */ |
michael@0 | 1038 | const unsigned long TYPE_DOUBLE = 1; |
michael@0 | 1039 | /** Value is a primitive number that fits into an integer. */ |
michael@0 | 1040 | const unsigned long TYPE_INT = 2; |
michael@0 | 1041 | /** Value is a function. */ |
michael@0 | 1042 | const unsigned long TYPE_FUNCTION = 3; |
michael@0 | 1043 | /** Value is |null|. */ |
michael@0 | 1044 | const unsigned long TYPE_NULL = 4; |
michael@0 | 1045 | /** Value is an object. */ |
michael@0 | 1046 | const unsigned long TYPE_OBJECT = 5; |
michael@0 | 1047 | /** Value is a primitive AUTF8String. */ |
michael@0 | 1048 | const unsigned long TYPE_STRING = 6; |
michael@0 | 1049 | /** Value is void. */ |
michael@0 | 1050 | const unsigned long TYPE_VOID = 7; |
michael@0 | 1051 | |
michael@0 | 1052 | /** |
michael@0 | 1053 | * One of the TYPE_* values above. |
michael@0 | 1054 | */ |
michael@0 | 1055 | readonly attribute unsigned long jsType; |
michael@0 | 1056 | /** |
michael@0 | 1057 | * Prototype value if this value represents an object, null if the value is |
michael@0 | 1058 | * not an object or the object has no prototype. |
michael@0 | 1059 | */ |
michael@0 | 1060 | readonly attribute jsdIValue jsPrototype; |
michael@0 | 1061 | /** |
michael@0 | 1062 | * Parent value if this value represents an object, null if the value is not |
michael@0 | 1063 | * an object or the object has no parent. |
michael@0 | 1064 | */ |
michael@0 | 1065 | readonly attribute jsdIValue jsParent; |
michael@0 | 1066 | /** |
michael@0 | 1067 | * Class name if this value represents an object. Empty AUTF8String if the value |
michael@0 | 1068 | * is not an object. |
michael@0 | 1069 | */ |
michael@0 | 1070 | readonly attribute AUTF8String jsClassName; |
michael@0 | 1071 | /** |
michael@0 | 1072 | * Constructor name if this value represents an object. Empty AUTF8String if the |
michael@0 | 1073 | * value is not an object. |
michael@0 | 1074 | */ |
michael@0 | 1075 | readonly attribute jsdIValue jsConstructor; |
michael@0 | 1076 | /** |
michael@0 | 1077 | * Function name if this value represents a function. Empty AUTF8String if the |
michael@0 | 1078 | * value is not a function. |
michael@0 | 1079 | */ |
michael@0 | 1080 | readonly attribute AUTF8String jsFunctionName; |
michael@0 | 1081 | |
michael@0 | 1082 | /** |
michael@0 | 1083 | * Value if interpreted as a boolean. Converts if necessary. |
michael@0 | 1084 | */ |
michael@0 | 1085 | readonly attribute boolean booleanValue; |
michael@0 | 1086 | /** |
michael@0 | 1087 | * Value if interpreted as a double. Converts if necessary. |
michael@0 | 1088 | */ |
michael@0 | 1089 | readonly attribute double doubleValue; |
michael@0 | 1090 | /** |
michael@0 | 1091 | * Value if interpreted as an integer. Converts if necessary. |
michael@0 | 1092 | */ |
michael@0 | 1093 | readonly attribute long intValue; |
michael@0 | 1094 | /** |
michael@0 | 1095 | * Value if interpreted as an object. |
michael@0 | 1096 | */ |
michael@0 | 1097 | readonly attribute jsdIObject objectValue; |
michael@0 | 1098 | /** |
michael@0 | 1099 | * Value if interpreted as a AUTF8String. Converts if necessary. |
michael@0 | 1100 | */ |
michael@0 | 1101 | readonly attribute AUTF8String stringValue; |
michael@0 | 1102 | |
michael@0 | 1103 | /** |
michael@0 | 1104 | * Number of properties. 0 if the value is not an object, or the value is |
michael@0 | 1105 | * an object but has no properties. |
michael@0 | 1106 | */ |
michael@0 | 1107 | readonly attribute long propertyCount; |
michael@0 | 1108 | |
michael@0 | 1109 | /** |
michael@0 | 1110 | * Retrieves all properties if this value represents an object. If this |
michael@0 | 1111 | * value is not an object a 0 element array is returned. |
michael@0 | 1112 | * @param propArray Array of jsdIProperty values for this value. |
michael@0 | 1113 | * @param length Size of array. |
michael@0 | 1114 | */ |
michael@0 | 1115 | void getProperties([array, size_is(length)] out jsdIProperty propArray, |
michael@0 | 1116 | out unsigned long length); |
michael@0 | 1117 | /** |
michael@0 | 1118 | * Retrieves a single property from the value. Only valid if the value |
michael@0 | 1119 | * represents an object. |
michael@0 | 1120 | * @param name Name of the property to retrieve. |
michael@0 | 1121 | * @retval jsdIProperty for the requested property name or null if no |
michael@0 | 1122 | * property exists for the requested name. |
michael@0 | 1123 | */ |
michael@0 | 1124 | jsdIProperty getProperty(in AUTF8String name); |
michael@0 | 1125 | |
michael@0 | 1126 | /** |
michael@0 | 1127 | * jsdIValues are wrappers around JavaScript engine structures. Much of the |
michael@0 | 1128 | * data is copied instead of shared. The refresh method is used to resync |
michael@0 | 1129 | * the jsdIValue with the underlying structure. |
michael@0 | 1130 | */ |
michael@0 | 1131 | void refresh(); |
michael@0 | 1132 | |
michael@0 | 1133 | /** |
michael@0 | 1134 | * When called from JavaScript, this method returns the JavaScript value |
michael@0 | 1135 | * wrapped by this jsdIValue. The calling script is free to use the result |
michael@0 | 1136 | * as it would any other JavaScript value. |
michael@0 | 1137 | * When called from another language this method returns an xpconnect |
michael@0 | 1138 | * defined error code. |
michael@0 | 1139 | */ |
michael@0 | 1140 | [implicit_jscontext] jsval getWrappedValue(); |
michael@0 | 1141 | |
michael@0 | 1142 | /** |
michael@0 | 1143 | * If this is a function value, return its associated jsdIScript. |
michael@0 | 1144 | * Otherwise, return null. |
michael@0 | 1145 | */ |
michael@0 | 1146 | readonly attribute jsdIScript script; |
michael@0 | 1147 | }; |
michael@0 | 1148 | |
michael@0 | 1149 | /** |
michael@0 | 1150 | * Properties specific to values which are also objects. |
michael@0 | 1151 | * XXX We don't add roots for these yet, so make sure you hold on to the |
michael@0 | 1152 | * jsdIValue from whence your jsdIObject instance came for at least as long as |
michael@0 | 1153 | * you hold the jsdIObject. |
michael@0 | 1154 | * XXX Maybe the jsClassName, jsConstructorName, and property related attribute/ |
michael@0 | 1155 | * functions from jsdIValue should move to this interface. We could inherit from |
michael@0 | 1156 | * jsdIValue or use interface flattening or something. |
michael@0 | 1157 | */ |
michael@0 | 1158 | [scriptable, uuid(87d86308-7a27-4255-b23c-ce2394f02473)] |
michael@0 | 1159 | interface jsdIObject : nsISupports |
michael@0 | 1160 | { |
michael@0 | 1161 | /** Internal use only. */ |
michael@0 | 1162 | [noscript] readonly attribute JSDContext JSDContext; |
michael@0 | 1163 | /** Internal use only. */ |
michael@0 | 1164 | [noscript] readonly attribute JSDObject JSDObject; |
michael@0 | 1165 | |
michael@0 | 1166 | /** |
michael@0 | 1167 | * The URL (filename) that contains the script which caused this object |
michael@0 | 1168 | * to be created. |
michael@0 | 1169 | */ |
michael@0 | 1170 | readonly attribute AUTF8String creatorURL; |
michael@0 | 1171 | /** |
michael@0 | 1172 | * Line number in the creatorURL where this object was created. |
michael@0 | 1173 | */ |
michael@0 | 1174 | readonly attribute unsigned long creatorLine; |
michael@0 | 1175 | /** |
michael@0 | 1176 | * The URL (filename) that contains the script which defined the constructor |
michael@0 | 1177 | * used to create this object. |
michael@0 | 1178 | */ |
michael@0 | 1179 | readonly attribute AUTF8String constructorURL; |
michael@0 | 1180 | /** |
michael@0 | 1181 | * Line number in the creatorURL where this object was created. |
michael@0 | 1182 | */ |
michael@0 | 1183 | readonly attribute unsigned long constructorLine; |
michael@0 | 1184 | /** |
michael@0 | 1185 | * jsdIValue for this object. |
michael@0 | 1186 | */ |
michael@0 | 1187 | readonly attribute jsdIValue value; |
michael@0 | 1188 | }; |
michael@0 | 1189 | |
michael@0 | 1190 | /** |
michael@0 | 1191 | * Representation of a property of an object. When an instance is invalid, all |
michael@0 | 1192 | * method and property access will result in a NS_UNAVAILABLE error. |
michael@0 | 1193 | */ |
michael@0 | 1194 | [scriptable, uuid(acf1329e-aaf6-4d6a-a1eb-f75858566f09)] |
michael@0 | 1195 | interface jsdIProperty : jsdIEphemeral |
michael@0 | 1196 | { |
michael@0 | 1197 | /** Internal use only. */ |
michael@0 | 1198 | [noscript] readonly attribute JSDContext JSDContext; |
michael@0 | 1199 | /** Internal use only. */ |
michael@0 | 1200 | [noscript] readonly attribute JSDProperty JSDProperty; |
michael@0 | 1201 | |
michael@0 | 1202 | /** |
michael@0 | 1203 | * FLAG_* values must be kept in sync with JSDPD_* #defines in jsdebug.h. |
michael@0 | 1204 | */ |
michael@0 | 1205 | |
michael@0 | 1206 | /** visible to for/in loop */ |
michael@0 | 1207 | const unsigned long FLAG_ENUMERATE = 0x01; |
michael@0 | 1208 | /** assignment is error */ |
michael@0 | 1209 | const unsigned long FLAG_READONLY = 0x02; |
michael@0 | 1210 | /** property cannot be deleted */ |
michael@0 | 1211 | const unsigned long FLAG_PERMANENT = 0x04; |
michael@0 | 1212 | /** property has an alias id */ |
michael@0 | 1213 | const unsigned long FLAG_ALIAS = 0x08; |
michael@0 | 1214 | /** argument to function */ |
michael@0 | 1215 | const unsigned long FLAG_ARGUMENT = 0x10; |
michael@0 | 1216 | /** local variable in function */ |
michael@0 | 1217 | const unsigned long FLAG_VARIABLE = 0x20; |
michael@0 | 1218 | /** exception occurred looking up property, value is exception */ |
michael@0 | 1219 | const unsigned long FLAG_EXCEPTION = 0x40; |
michael@0 | 1220 | /** native getter returned false without throwing an exception */ |
michael@0 | 1221 | const unsigned long FLAG_ERROR = 0x80; |
michael@0 | 1222 | /** found via explicit lookup (property defined elsewhere.) */ |
michael@0 | 1223 | const unsigned long FLAG_HINTED = 0x800; |
michael@0 | 1224 | |
michael@0 | 1225 | /** FLAG_* values OR'd together, representing the flags for this property. */ |
michael@0 | 1226 | readonly attribute unsigned long flags; |
michael@0 | 1227 | /** jsdIValue representing the alias for this property. */ |
michael@0 | 1228 | readonly attribute jsdIValue alias; |
michael@0 | 1229 | /** name for this property. */ |
michael@0 | 1230 | readonly attribute jsdIValue name; |
michael@0 | 1231 | /** value of this property. */ |
michael@0 | 1232 | readonly attribute jsdIValue value; |
michael@0 | 1233 | }; |