Thunderbird extension console logging - firefox-addon

I have the following code in my bootstrapped Thunderbird add-on main.js file:
exports.main = function() {
console.log("abc");
};
When I run this code in FireFox in Add-on Builder, I get this message displayed in FireFox Error Console:
info: vladp: abc
However, when I run my extension in Thunderbird nothing is displayed. I have set up the development enviroment as described here: https://developer.mozilla.org/en-US/docs/Setting_up_extension_development_environment
How do I make it work in Thunderbird Error Console? Or is there any other way to log some debug information, apart from "dump()"?
UPDATE 1
As suggested by speedball2001, I've changed my code to:
exports.main = function() {
var Application = Components.classes["#mozilla.org/steel/application;1"].getService(Components.interfaces.steelIApplication);
Application.console.log('Bam!');
};
However, when I run Thunderbird, I get the following error in error console:
Timestamp: 2013.05.22. 16:39:07
Error: myfirstext: An exception occurred.
ReferenceError: Components is not defined
resource://jid0-7yp22cmsooypei7nicamg3n0ha0-at-jetpack/myfirstext/lib/main.js 57
How do I fix it?

Thunderbird provides an Application interface that, among other things, helps with logging:
var {Cc, Ci} = require("chrome");
var Application = Cc["#mozilla.org/steel/application;1"]
.getService(Ci.steelIApplication);
Application.console.log('Bam!');

Related

Custom error message is not showed in the app

In the restful app I am implementing error handling, but I cannot see the error message being displayed in the frontend UI. Instead, I only see a different error message from the framework.
Although I can see that my custom error message error message being propagated to the frontend it appears to be subsequently overwritten with a different message from the framework.
So I am not sure if this is something with the versions I work with (ABAP-1909 and UI5-1.96.12) or it is my implementation issue.
Implementation type: Unmanaged scenario.
ABAP version: S/4 Hana On Prem 1909
UI5 Version: '1.107.1'
Code snippet:
APPEND VALUE #( %cid = <fs_lsi_create>-%cid
uuid = ls_lsi_crt-uuid
) TO failed-incidents.
APPEND VALUE #(
%cid = <fs_lsi_create>-%cid
%key-uuid = ls_lsi_crt-uuid
%msg = new_message( id = 'ZLSAPP_MSG'
number = 001
severity = if_abap_behv_message=>severity-error
v1 = <fs_lsi_create>-name )
uuid = ls_lsi_crt-uuid ) TO reported-incidents.
I was expecting to see the error message in a popup on the frontend application, but I see it only in the debugger console, it doesn't appear in the error popup screen.

How to resolve error 'this.fs.stat is not a function' when using LokiJS and Angular?

I'm getting the error ('this.fs.stat is not a function') on line 2256 of lokijs.js. Environment is Electron with Angular 5.x and LokiJS v1.5.3.
fs is set up on line 2244 of lokijs.js (this.fs = require('fs');) but when I examine this.fs in the browser tools immediately after that line executes, it is just an empty object.
I've been beating my head against LokiJS all afternoon and have managed to get this far, but have no idea where to go from here. fs has been in node since forever, so I don't think it's an issue with a node version.
I'm aware of the issues with require and webpack, but since this is happening in LokiJS, I'm not sure whether this is related and if so what the proper fix would be.
Any ideas/suggestions?
Thanks.
Update #1
Code:
import * as Loki from 'lokijs';
import { LokiFsAdapter } from 'lokijs';
this.adapter = new LokiFsAdapter();
this.db = new Loki('my.db', {
env: 'NODEJS',
autoload: true,
autosave: true,
verbose: true,
autoloadCallback: this.initCollections
});
This gets me the error I mentioned above. If I switch the first line to import { Loki } from 'lokijs'; I get this error instead: Uncaught (in promise): TypeError: lokijs_1.Loki is not a constructor

invalid method (createTableViewRow) passed to UIModule

i am having this error when i run my app on the device ( iPhone 7 ), but when i run it in the emulator works fine.
Its really strange.
The code is:
Ti.API.info( json );
var renglon = Ti.UI.createTableViewRow({
id: id,
width: Ti.UI.FILL,
height: '80dp',
});
In the emulator works OK, but in the device i got an error, the error appears just after the json is printed in the log.
[WARN] : Attempted to load TiUITableViewRowProxy: Could not find class definition.
[ERROR] : Script Error {
[ERROR] : column = 2875;
[ERROR] : line = 1;
[ERROR] : message = "invalid method (createTableViewRow) passed to UIModule";
[ERROR] : sourceURL = "file:///var/containers/Bundle/Application/B99CA23F-183D-4C5F-A5DC-FA9CFC614186/CarWash.app/src/vistas/personal.js";
[ERROR] : stack = "[native code]\nagregarRenglonPersonal#file:///var/containers/Bundle/Application/B99CA23F-183D-4C5F-A5DC- FA9CFC614186/CarWash.app/src/vistas/personal.js:1:2875\nonload#file:///var/contain ers/Bundle/Application/B99CA23F-183D-4C5F-A5DC- FA9CFC614186/CarWash.app/src/vistas/personal.js:1:3651";
[ERROR] : }
-- End application log -------------------------------------------------------
i'm using:
Titanium appcelerator studio build: 4.9.0.201705302345
SDK: 6.1.0GA
Thanks in advance.
We are run into the same error today!
Wrong source code in respect of the table view was the reason, a stupid C&P error:
var tableView = Ti.UI.createLabel({...});
instead of
var tableView = Ti.UI.createTableView({...});
First of all: i do not really like Appcelerator Studio, did you try compiling with the cli? appc run -p ios
If that does not work it would be intresting to see more code than the snippet you posted
Did you try with older sdks? If not then try this code with older sdk and still you get same error then i would like to see more code.

Firefox extension - Error: call to Function() blocked by CSP

I have the following simplified code:
main.js:
var data = require("sdk/self").data;
var tabs = require("sdk/tabs");
tabs.on('ready', function(tab) {
console.log("start");
let worker = tab.attach({
contentScriptFile: [
data.url("jquery.min.js"),
data.url("test.js")
],
});
worker.port.emit("start", data.load("popups/start.html"));
console.log("end");
});
test.js:
console.log("test.js");
self.port.on("start", function (content) {
console.log("I get the message");
$('body').append(content);
});
The problem:
This works just fine and everything is ok in most cases. In only one web site and specifically in well known github.com, it produces the following error:
console.log: test: start
console.log: test: end
console.error:
Message: Error: call to Function() blocked by CSP
console.error:
Message: TypeError: this.sandbox is undefined
Stack:
receive#resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/commonjs/sdk/content/worker-child.js:75:7
emitOnObject#resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/commonjs/sdk/event/core.js:112:9
emit#resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/commonjs/sdk/event/core.js:89:38
processMessageReceived#resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/commonjs/sdk/remote/child.js:54:38
Note 1: The problem is with the exchange of the message start. But why it is working everywhere else except the github.com/*?
Note 2: I'm using cfx, with jpm it works fine. Is any way to fix that or I have to update my extension to run with jpm?
cfx is probably including an old version of the SDK while jpm runs with the browser's built-in version. Try running with --strip-sdk.
That said, cfx is deprecated, you should use jpm.
Github uses CSP directives to block unsafe script execution including eval and new Function(), many other sites don't.
Newer SDK versions initialize the addon script sandbox differently so it is not affected by CSPs.

Angular in Rails throws an error in production `Error: [$injector:unpr] Unknown provider: e`

When running my app in development it works fine. but when deployed, it throws this error :
Error: [$injector:unpr] Unknown provider: e
The url to the app : http://shimizu.leafycode.com/panel/signin
The js files : https://gist.github.com/THPubs/3a9e088ad3410e18030c
I followed other stack-overflow answers and fixed my app accordingly but still the problem is there! Please help.
Your code is being minified and I can see at least one place in app.js where you are not using the array notation when calling .config and .run
So in your app.js update the line
.config(function($mdThemingProvider) {
to
.config(['$mdThemingProvider', function($mdThemingProvider) {
// ... Your code ...
}])
and the line
.run(function($rootScope, $templateCache) {
to
.run(['$rootScope', '$templateCache', function($rootScope, $templateCache) {
// .. Your code ...
}])
Double check other places in your code that you are injecting services.

Resources