Reputation: 1603
Debugging Firefox add-on in scratchpad returns some errors in following cases:
Consider the following example which Get Cursor Position
:
Components.utils.import("resource://gre/modules/ctypes.jsm");
var lib = ctypes.open("user32.dll");
/* note: if you go to GetCursorPos page on MSDN, it says first argument is of structure POINT, so lets create that structure,
* the link here shows that that x and y are type Long which is ctypes.long
*/
// https://msdn.microsoft.com/en-us/library/windows/desktop/dd162805%28v=vs.85%29.aspx
var POINT = new ctypes.StructType("tagPOINT", [
{ "x": ctypes.long },
{ "y": ctypes.long }
]);
/* Declare the signature of the function we are going to call */
var GetCursorPos = lib.declare('GetCursorPos',
ctypes.winapi_abi,
ctypes.bool,
POINT.ptr
);
/* Use it like this */
var point = POINT();
var ret = GetCursorPos(point.address());
Components.utils.reportError(ret);
Components.utils.reportError(point);
lib.close();
Any helps to editing and completing the question with better examples or something else, would be appreciated.
Upvotes: 1
Views: 68
Reputation: 43115
For SDK addons I would recommend using jpm watchpost + extension auto installer instead.
That will automatically create an xpi and reinstall it in your browser every time you save a file. Simply keeping the browser console open will get you any potential error outputs.
Interacting with another pages (i.e. content scripts)
The browser toolbox's scratchpad can select the target environment in which it is executed
Using require
In chrome contexts require can be imported via let { require } = Cu.import("resource://gre/modules/commonjs/toolkit/require.js")
If you use the addon debugger I think the addon's require should be available
Upvotes: 1