dom/plugins/test/testplugin/README

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

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 = Instructions for using the test plugin =
michael@0 2
michael@0 3 == MIME type ==
michael@0 4
michael@0 5 The test plugin registers itself for the MIME type "application/x-test".
michael@0 6
michael@0 7 == Event Model ==
michael@0 8
michael@0 9 * getEventModel()
michael@0 10 Returns the NPAPI event model in use. On platforms without event models,
michael@0 11 simply returns 0;
michael@0 12
michael@0 13 == Rendering ==
michael@0 14
michael@0 15 By default, the plugin fills its rectangle with gray, with a black border, and
michael@0 16 renders the user-agent string (obtained from NPN_UserAgent) centered in black.
michael@0 17 This rendering method is not supported for the async drawing models.
michael@0 18
michael@0 19 The test plugin supports the following parameters:
michael@0 20
michael@0 21 * drawmode="solid"
michael@0 22 The plugin will draw a solid color instead of the default rendering described
michael@0 23 above. The default solid color is completely transparent black (i.e., nothing).
michael@0 24 This should be specified when using one of the async models.
michael@0 25
michael@0 26 * asyncmodel="bitmap"
michael@0 27 The plugin will use the NPAPI Async Bitmap drawing model extension. On
michael@0 28 unsupported platforms this will fallback to non-async rendering.
michael@0 29
michael@0 30 * asyncmodel="dxgi"
michael@0 31 The plugin will use the NPAPI Async DXGI drawing model extension. Only
michael@0 32 supported on Windows Vista or higher. On unsupported platforms this will
michael@0 33 fallback to non-async rendering.
michael@0 34
michael@0 35 * color
michael@0 36 This specifies the color to use for drawmode="solid". The value should be 8 hex
michael@0 37 digits, 2 per channel in AARRGGBB format.
michael@0 38
michael@0 39 == Generic API Tests ==
michael@0 40
michael@0 41 * setUndefinedValueTest
michael@0 42 Attempts to set the value of an undefined variable (0x0) via NPN_SetValue,
michael@0 43 returns true if it succeeds and false if it doesn't. It should never succeed.
michael@0 44
michael@0 45 * .getReflector()
michael@0 46 Hands back an object which reflects properties as values, e.g.
michael@0 47 .getReflector().foo = 'foo'
michael@0 48 .getReflector()['foo'] = 'foo'
michael@0 49 .getReflector()[1] = 1
michael@0 50
michael@0 51 * .getNPNVdocumentOrigin()
michael@0 52 Returns the origin string retrieved from the browser by a NPNVdocumentOrigin
michael@0 53 variable request. Does not cache the value, gets it from the browser every time.
michael@0 54
michael@0 55 == NPN_ConvertPoint testing ==
michael@0 56
michael@0 57 * convertPointX(sourceSpace, sourceX, sourceY, destSpace)
michael@0 58 * convertPointY(sourceSpace, sourceX, sourceY, destSpace)
michael@0 59 The plugin uses NPN_ConvertPoint to convert sourceX and sourceY from the source
michael@0 60 to dest space and returns the X or Y result based on the call.
michael@0 61
michael@0 62 == NPCocoaEventWindowFocusChanged ==
michael@0 63
michael@0 64 * getTopLevelWindowActivationState()
michael@0 65 Returns the activation state for the top-level window as set by the last
michael@0 66 NPCocoaEventWindowFocusChanged event. Returns true for active, false for
michael@0 67 inactive, and throws an exception if the state is unknown (uninitialized).
michael@0 68
michael@0 69 * getTopLevelWindowActivationEventCount()
michael@0 70 Returns the number of NPCocoaEventWindowFocusChanged events received by
michael@0 71 the instance.
michael@0 72
michael@0 73 == Focus Tests ==
michael@0 74
michael@0 75 * getFocusState()
michael@0 76 Returns the plugin's focus state. Returns true for focused, false for unfocused,
michael@0 77 and throws an exception if the state is unknown (uninitialized). This does not
michael@0 78 necessarily correspond to actual input focus - this corresponds to focus as
michael@0 79 defined by the NPAPI event model in use.
michael@0 80
michael@0 81 * getFocusEventCount()
michael@0 82 Returns the number of focus events received by the instance.
michael@0 83
michael@0 84 == NPRuntime testing ==
michael@0 85
michael@0 86 The test plugin object supports the following scriptable methods:
michael@0 87
michael@0 88 * identifierToStringTest(ident)
michael@0 89 Converts a string, int32 or double parameter 'ident' to an NPIdentifier and
michael@0 90 then to a string, which is returned.
michael@0 91
michael@0 92 * npnEvaluateTest(script)
michael@0 93 Calls NPN_Evaluate on the 'script' argument, which is a string containing
michael@0 94 some script to be executed. Returns the result of the evaluation.
michael@0 95
michael@0 96 * npnInvokeTest(method, expected, args...)
michael@0 97 Causes the plugin to call the specified script method using NPN_Invoke,
michael@0 98 passing it 1 or more arguments specified in args. The return value of this
michael@0 99 call is compared against 'expected', and if they match, npnInvokeTest will
michael@0 100 return true. Otherwise, it will return false.
michael@0 101
michael@0 102 * npnInvokeDefaultTest(object, argument)
michael@0 103 Causes the plugin to call NPN_InvokeDefault on the specified object,
michael@0 104 with the specified argument. Returns the result of the invocation.
michael@0 105
michael@0 106 * getError()
michael@0 107 If an error has occurred during the last stream or npruntime function,
michael@0 108 this will return a string error message, otherwise it returns "pass".
michael@0 109
michael@0 110 * throwExceptionNextInvoke()
michael@0 111 Sets a flag which causes the next call to a scriptable method to throw
michael@0 112 one or more exceptions. If no parameters are passed to the next
michael@0 113 scriptable method call, it will cause a generic exception to be thrown.
michael@0 114 Otherwise there will be one exception thrown per argument, with the argument
michael@0 115 used as the exception message. Example:
michael@0 116
michael@0 117 plugin.throwExceptionNextInvoke();
michael@0 118 plugin.npnInvokeTest("first exception message", "second exception message");
michael@0 119
michael@0 120 * () - default method
michael@0 121 Returns a string consisting of the plugin name, concatenated with any
michael@0 122 arguments passed to the method.
michael@0 123
michael@0 124 * .crash() - Crashes the plugin
michael@0 125
michael@0 126 * getObjectValue() - Returns a custom plugin-implemented scriptable object.
michael@0 127 * checkObjectValue(obj) - Returns true if the object from setObjectValue() is
michael@0 128 the same object passed into this function. It should return true when
michael@0 129 the object is passed to the same plugin instance, and false when passed
michael@0 130 to other plugin instances, see bug 532246 and
michael@0 131 test_multipleinstanceobjects.html.
michael@0 132
michael@0 133 * callOnDestroy(fn) - Calls `fn` when the plugin instance is being destroyed
michael@0 134
michael@0 135 * getAuthInfo(protocol, host, port, scheme, realm) - a wrapper for
michael@0 136 NPN_GetAuthenticationInfo(). Returns a string "username|password" for
michael@0 137 the specified auth criteria, or throws an exception if no data is
michael@0 138 available.
michael@0 139
michael@0 140 * timerTest(callback) - initiates tests of NPN_ScheduleTimer &
michael@0 141 NPN_UnscheduleTimer. When finished, calls the script callback
michael@0 142 with a boolean value, indicating whether the tests were successful.
michael@0 143
michael@0 144 * asyncCallbackTest(callback) - initiates tests of
michael@0 145 NPN_PluginThreadAsyncCall. When finished, calls the script callback
michael@0 146 with a boolean value, indicating whether the tests were successful.
michael@0 147
michael@0 148 * paintscript="..." content attribute
michael@0 149 If the "paintscript" attribute is set on the plugin element during plugin
michael@0 150 initialization, then every time the plugin paints it gets the contents of that
michael@0 151 attribute and evaluates it as a script in the context of the plugin's DOM
michael@0 152 window. This is useful for testing evil plugin code that might, for example,
michael@0 153 modify the DOM during painting.
michael@0 154
michael@0 155 == Private browsing ==
michael@0 156
michael@0 157 The test plugin object supports the following scriptable methods:
michael@0 158
michael@0 159 * queryPrivateModeState
michael@0 160 Returns the value of NPN_GetValue(NPNVprivateModeBool).
michael@0 161
michael@0 162 * lastReportedPrivateModeState
michael@0 163 Returns the last value set by NPP_SetValue(NPNVprivateModeBool).
michael@0 164
michael@0 165 == Windowed/windowless mode ==
michael@0 166
michael@0 167 The test plugin is windowless by default.
michael@0 168
michael@0 169 The test plugin supports the following parameter:
michael@0 170
michael@0 171 * wmode="window"
michael@0 172 The plugin will be given a native widget on platforms where we support this
michael@0 173 (Windows and X).
michael@0 174
michael@0 175 The test plugin object supports the following scriptable method:
michael@0 176
michael@0 177 * hasWidget()
michael@0 178 Returns true if the plugin has an associated widget. This will return true if
michael@0 179 wmode="window" was specified and the platform supports windowed plugins.
michael@0 180
michael@0 181 == Plugin invalidation ==
michael@0 182
michael@0 183 * setColor(colorString)
michael@0 184 Sets the color used for drawmode="solid" and invalidates the plugin area.
michael@0 185 This calls NPN_Invalidate, even for windowed plugins, since that should work
michael@0 186 for windowed plugins too (Silverlight depends on it).
michael@0 187
michael@0 188 * getPaintCount()
michael@0 189 Returns the number of times this plugin instance has processed a paint request.
michael@0 190 This can be used to detect whether painting has happened in a plugin's
michael@0 191 window.
michael@0 192
michael@0 193 * getWidthAtLastPaint()
michael@0 194 Returns the window width that was current when the plugin last painted.
michael@0 195
michael@0 196 * setInvalidateDuringPaint(value)
michael@0 197 When value is true, every time the plugin paints, it will invalidate
michael@0 198 itself *during the paint* using NPN_Invalidate.
michael@0 199
michael@0 200 * setSlowPaint(value)
michael@0 201 When value is true, the instance will sleep briefly during paint.
michael@0 202
michael@0 203 == Plugin geometry ==
michael@0 204
michael@0 205 The test plugin supports the following scriptable methods:
michael@0 206
michael@0 207 * getEdge(edge)
michael@0 208 Returns the integer screen pixel coordinate of an edge of the plugin's
michael@0 209 area:
michael@0 210 -- edge=0: returns left edge coordinate
michael@0 211 -- edge=1: returns top edge coordinate
michael@0 212 -- edge=2: returns right edge coordinate
michael@0 213 -- edge=3: returns bottom edge coordinate
michael@0 214 The coordinates are relative to the top-left corner of the top-level window
michael@0 215 containing the plugin, including the window decorations. Therefore:
michael@0 216 -- On Mac, they're relative to the top-left corner of the toplevel Cocoa
michael@0 217 window.
michael@0 218 -- On Windows, they're relative to the top-left corner of the toplevel HWND's
michael@0 219 non-client area.
michael@0 220 -- On GTK2, they're relative to the top-left corner of the toplevel window's
michael@0 221 window manager frame.
michael@0 222 This means they can be added to Gecko's window.screenX/screenY (if DPI is set
michael@0 223 to 96) to get screen coordinates.
michael@0 224 On the platforms that support window-mode plugins (Windows/GTK2), this only
michael@0 225 works for window-mode plugins. It will throw an error for windowless plugins.
michael@0 226
michael@0 227 * getClipRegionRectCount()
michael@0 228 Returns the number of rectangles in the plugin's clip region.
michael@0 229 For plugins with widgets, the clip region is computed as the intersection of the
michael@0 230 clip region for the widget (if the platform does not support clip regions
michael@0 231 on native widgets, this would just be the widget's rectangle) with the
michael@0 232 clip regions of all ancestor widgets which would clip this widget.
michael@0 233 On the platforms that support window-mode plugins (Windows/GTK2), this only
michael@0 234 works for window-mode plugins. It will throw an error for windowless plugins.
michael@0 235 On Mac, all plugins have a clip region containing just a single clip
michael@0 236 rectangle only. So if you request wmode="window" but the plugin reports
michael@0 237 !hasWidget, you can assume that complex clip regions are not supported.
michael@0 238
michael@0 239 * getClipRegionRectEdge(i, edge)
michael@0 240 Returns the integer screen pixel coordinate of an edge of a rectangle from the
michael@0 241 plugin's clip region. If i is less than zero or greater than or equal to
michael@0 242 getClipRegionRectCount(), this will throw an error. The coordinates are
michael@0 243 the same as for getEdge. See getClipRegionRectCount() above for
michael@0 244 notes on platform plugin limitations.
michael@0 245
michael@0 246 == Keyboard events ==
michael@0 247
michael@0 248 * getLastKeyText()
michael@0 249 Returns the text which was inputted by last keyboard events. This is cleared at
michael@0 250 every keydown event.
michael@0 251 NOTE: Currently, this is implemented only on Windows.
michael@0 252
michael@0 253 == Mouse events ==
michael@0 254
michael@0 255 The test plugin supports the following scriptable methods:
michael@0 256
michael@0 257 * getLastMouseX()
michael@0 258 Returns the X coordinate of the last mouse event (move, button up, or
michael@0 259 button down), relative to the left edge of the plugin, or -1 if no mouse
michael@0 260 event has been received.
michael@0 261
michael@0 262 * getLastMouseX()
michael@0 263 Returns the Y coordinate of the last mouse event (move, button up, or
michael@0 264 button down), relative to the top edge of the plugin, or -1 if no mouse
michael@0 265 event has been received.
michael@0 266
michael@0 267 == Instance lifecycle ==
michael@0 268
michael@0 269 The test plugin supports the following scriptable methods:
michael@0 270
michael@0 271 * startWatchingInstanceCount()
michael@0 272 Marks all currently running instances as "ignored". Throws an exception if
michael@0 273 there is already a watch (startWatchingInstanceCount has already been
michael@0 274 called on some instance without a corresponding stopWatchingInstanceCount).
michael@0 275
michael@0 276 * getInstanceCount()
michael@0 277 Returns the count of currently running instances that are not ignored.
michael@0 278 Throws an exception if there is no watch.
michael@0 279
michael@0 280 * stopWatchingInstanceCount()
michael@0 281 Stops watching. Throws an exception if there is no watch.
michael@0 282
michael@0 283 == NPAPI Timers ==
michael@0 284
michael@0 285 * unscheduleAllTimers()
michael@0 286 Instructs the plugin instance to cancel all timers created via
michael@0 287 NPN_ScheduleTimer.
michael@0 288
michael@0 289 == Stream Functionality ==
michael@0 290
michael@0 291 The test plugin enables a variety of NPAPI streaming tests, which are
michael@0 292 initiated by passing a variety of attributes to the <embed> element which
michael@0 293 causes the plugin to be initialized. The plugin stream test code is
michael@0 294 designed to receive a stream from the browser (by specifying a "src",
michael@0 295 "geturl", or "geturlnotify" attribute), and then (if a "frame" attribute
michael@0 296 is specified) send the data from that stream back to the browser in another
michael@0 297 stream, whereupon it will be displayed in the specified frame. If some
michael@0 298 error occurs during stream processing, an error message will appear in the
michael@0 299 frame instead of the stream data. If no "frame" attribute is present, a
michael@0 300 stream can still be received by the plugin, but the plugin will do nothing
michael@0 301 with it.
michael@0 302
michael@0 303 The attributes which control stream tests are:
michael@0 304
michael@0 305 "streammode": one of "normal", "asfile", "asfileonly", "seek". Sets the
michael@0 306 stream mode to the specified mode in any call to NPP_NewStream.
michael@0 307 Defaults to "asfileonly".
michael@0 308
michael@0 309 "streamchunksize": the number of bytes the plugin reports it can accept
michael@0 310 in calls to NPP_WriteReady. Defaults to 1,024.
michael@0 311
michael@0 312 "src": a url. If specified, the browser will call NPP_NewStream for
michael@0 313 this url as soon as the plugin is initialized.
michael@0 314
michael@0 315 "geturl": a url. If specified, the plugin will request this url
michael@0 316 from the browser when the plugin is initialized, via a call to
michael@0 317 NPN_GetURL.
michael@0 318
michael@0 319 "geturlnotify": a url. If specified, the plugin will request this url
michael@0 320 from the browser when the plugin is initialized, via a call to
michael@0 321 NPN_GetURLNotify. The plugin passes some "notifyData" to
michael@0 322 NPN_GetURLNotify, which it verifies is present in the call to
michael@0 323 NPP_URLNotify. If the "notifyData" does not match, an error
michael@0 324 will be displayed in the test frame (if any), instead of the stream
michael@0 325 data.
michael@0 326
michael@0 327 "frame": the name of a frame in the same HTML document as the <embed>
michael@0 328 element which instantiated the plugin. For any of the preceding three
michael@0 329 attributes, a stream is received by the plugin via calls to NPP_NewStream,
michael@0 330 NPP_WriteReady, NPP_Write, and NPP_DestroyStream. When NPP_DestroyStream
michael@0 331 is called (or NPP_UrlNotify, in the case of "geturlnotify"), and a
michael@0 332 "frame" attribute is present, the data from the stream is converted into a
michael@0 333 data: url, and sent back to the browser in another stream via a call to
michael@0 334 NPN_GetURL, whereupon it should be displayed in the specified frame.
michael@0 335
michael@0 336 "range": one or more byte ranges, in the format "offset,length;offset,length".
michael@0 337 Only valid when "streammode" = "seek". When "range" is present, the plugin
michael@0 338 will request the specified byte ranges from the stream via a call to
michael@0 339 NPN_RequestRead, which it makes after the browser makes its final call to
michael@0 340 NPP_Write. The plugin verifies that the browser makes additional calls
michael@0 341 to NPP_Write according to the requested byte ranges, and that the data
michael@0 342 received is correct. Any errors will appear in the test "frame", if
michael@0 343 specified.
michael@0 344
michael@0 345 "posturl": a url. After the plugin receives a stream, and NPP_DestroyStream
michael@0 346 is called, if "posturl" is specified, the plugin will post the contents
michael@0 347 of the stream to the specified url via NPN_PostURL. See "postmode" for
michael@0 348 additional details.
michael@0 349
michael@0 350 "postmode": either "frame" or "stream". If "frame", and a "frame" attribute
michael@0 351 is present, the plugin will pass the frame name to calls to NPN_PostURL,
michael@0 352 so that the HTTP response from that operation will be displayed in the
michael@0 353 specified frame. If "stream", the HTTP response is delivered to the plugin
michael@0 354 via calls to NPP_NewStream etc, and if a "frame" attribute is present, the
michael@0 355 contents of that stream will be passed back to the browser and displayed
michael@0 356 in the specified frame via NPN_GetURL.
michael@0 357
michael@0 358 "newstream": if "true", then any stream which is sent to a frame in the browser
michael@0 359 is sent via calls to NPN_NewStream and NPN_Write. Doing so will cause
michael@0 360 the browser to store the stream data in a file, and set the frame's
michael@0 361 location to the corresponding file:// url.
michael@0 362
michael@0 363 "functiontofail": one of "npp_newstream", "npp_write", "npp_destroystream".
michael@0 364 When specified, the given function will return an error code (-1 for
michael@0 365 NPP_Write, or else the value of the "failurecode" attribute) the first time
michael@0 366 it is called by the browser.
michael@0 367
michael@0 368 "failurecode": one of the NPError constants. Used to specify the error
michael@0 369 that will be returned by the "functiontofail".
michael@0 370
michael@0 371 If the plugin is instantiated as a full-page plugin, the following defaults
michael@0 372 are used:
michael@0 373 streammode="seek" frame="testframe" range="100,100"
michael@0 374
michael@0 375 * streamTest(url, doPost, postData, writeCallback, notifyCallback, redirectCallback, allowRedirects)
michael@0 376 This will test how NPN_GetURLNotify and NPN_PostURLNotify behave when they are
michael@0 377 called with arbitrary (malformed) URLs. The function will return `true` if
michael@0 378 NPN_[Get/Post]URLNotify succeeds, and `false` if it fails.
michael@0 379 @url url to request
michael@0 380 @param doPost whether to call NPN_PostURLNotify
michael@0 381 @param postData null, or a string to send a postdata
michael@0 382 @writeCallback will be called when data is received for the stream
michael@0 383 @notifyCallback will be called when the urlnotify is received with the notify result
michael@0 384 @redirectCallback will be called from urlredirectnotify if a redirect is attempted
michael@0 385 @allowRedirects boolean value indicating whether or not to allow redirects
michael@0 386
michael@0 387 * setPluginWantsAllStreams(wantsAllStreams)
michael@0 388 Set the value returned by the plugin for NPPVpluginWantsAllNetworkStreams.
michael@0 389
michael@0 390 == Internal consistency ==
michael@0 391
michael@0 392 * doInternalConsistencyCheck()
michael@0 393 Does internal consistency checking, returning an empty string if everything is
michael@0 394 OK, otherwise returning some kind of error string. On Windows, in windowed
michael@0 395 mode, this checks that the position of the plugin's internal child
michael@0 396 window has not been disturbed relative to the plugin window.
michael@0 397
michael@0 398 == Windows native widget message behaviour ==
michael@0 399
michael@0 400 * Mouse events are handled (saving the last mouse event coordinate) and not
michael@0 401 passed to the overridden windowproc.
michael@0 402
michael@0 403 * WM_MOUSEWHEEL events are handled and not passed to the parent window or the
michael@0 404 overridden windowproc.
michael@0 405
michael@0 406 * WM_MOUSEACTIVATE events are handled by calling SetFocus on the plugin's
michael@0 407 widget, if the plugin is windowed. If it's not windowed they're passed to
michael@0 408 the overriden windowproc (but hopefully never sent by the browser anyway).
michael@0 409
michael@0 410 == Getting and Setting Cookies ==
michael@0 411
michael@0 412 * setCookie(string)
michael@0 413 Sets the given string as the cookie for window's URL.
michael@0 414
michael@0 415 * getCookie()
michael@0 416 Returns the cookie string for the window's URL, the cookie set by setCookie.
michael@0 417
michael@0 418 == FPU Control ==
michael@0 419
michael@0 420 x86-only on some OSes:
michael@0 421
michael@0 422 * The .enableFPExceptions() method will enable floating-point exceptions,
michael@0 423 as evil plugins or extensions might do.
michael@0 424
michael@0 425 == HiDPI Mode ==
michael@0 426
michael@0 427 * queryContentsScaleFactor()
michael@0 428 Returns the contents scale factor. On platforms without support for this query
michael@0 429 always returns 1.0 (a double value). Likewise on hardware without HiDPI mode
michael@0 430 support.

mercurial