Information about porting extension

Add-ons for Pale Moon and other applications
General discussion, compatibility, contributed extensions, themes, plugins, and more.

Moderators: FranklinDM, Lootyhoof

MonoS

Information about porting extension

Unread post by MonoS » 2021-11-10, 19:06

As the Open Casting Call for extension was closed and i wrongly allowed Pale Moon to update to latest version i'd like to receive some information on how to port the only extension i used daily, but i've never developed any XUL add-ons so i don't know where to start, i'm a developer by trade, so it should be much difficult.
Adding Pale Moon GUID i can see that the addon is mostly working except for some functionality, so i'd like to start a debugger and see what is failing, i hope that a guide on how to debug XUL addons (as i think it is) or a list of all compatibility fixes that where removed on 29.2 should suffice i guess, i've tried to open about:debugging, but it seems to be a debugger for the new kind of add-ons, so mine was not listed.

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 35477
Joined: 2011-08-28, 17:27
Location: Motala, SE
Contact:

Re: Information about porting extension

Unread post by Moonchild » 2021-11-10, 19:49

The error console is your friend.
Developer tools -> error console.
"Sometimes, the best way to get what you want is to be a good person." -- Louis Rossmann
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite

MonoS

Re: Information about porting extension

Unread post by MonoS » 2021-11-10, 20:14

Thanks moonchild, sadly it doesn't seems to return any error.
My plugin use a jar file inside chrome subfolder, if a add some console.log() to that should i be able to printf-debug it?

vannilla
Moon Magic practitioner
Moon Magic practitioner
Posts: 2183
Joined: 2018-05-05, 13:29

Re: Information about porting extension

Unread post by vannilla » 2021-11-10, 20:19

It depends on how the jar file is handled.
Unpacking it also means you need to repack it using the appropriate format, so make sure you do things properly or it won't work.

New Tobin Paradigm

Re: Information about porting extension

Unread post by New Tobin Paradigm » 2021-11-10, 20:33

console.log is a chromeism for the web. Only the DevTools Browser or Web Consoles can pick it up not the Toolkit Error Console.

U'd be better importing Services.jsm and using Services.console.logStringMessage(). That will work in any XUL-Based application built with our platform.

MonoS

Re: Information about porting extension

Unread post by MonoS » 2021-11-10, 22:48

@vannilla: i think it's a zip file? I'm opening it with 7-zip. I don't have any kind of expertise in XUL developement.
@Tobin: Should i "import Services.jsm" inside the .js file i want to debug?

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 35477
Joined: 2011-08-28, 17:27
Location: Motala, SE
Contact:

Re: Information about porting extension

Unread post by Moonchild » 2021-11-10, 23:02

MonoS wrote:
2021-11-10, 22:48
Should i "import Services.jsm" inside the .js file i want to debug?

Code: Select all

Components.utils.import("resource://gre/modules/Services.jsm");
"Sometimes, the best way to get what you want is to be a good person." -- Louis Rossmann
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite

vannilla
Moon Magic practitioner
Moon Magic practitioner
Posts: 2183
Joined: 2018-05-05, 13:29

Re: Information about porting extension

Unread post by vannilla » 2021-11-10, 23:12

MonoS wrote:
2021-11-10, 22:48
i think it's a zip file? I'm opening it with 7-zip. I don't have any kind of expertise in XUL developement.
Not really, no.
7-zip does a lot of magic, and I do mean a lot. It does so much magic Harry Potter is a noob (I'm exaggerating to make a point here) so even if 7-zip can open it, it means nothing; you have to examine the file itself using other tools.
In theory, the jar file can be extracted and simply left as-is, but then you'd have to edit the extension to not rely on that jar file but rather to directly read the files in the XPI, which is a similar but slightly different process.
I'm not versed with jar files inside extensions because it's a very old technique that's not necessary anymore, so I can't really help out too much; all I can suggest is to first try a normal zip then renamed to jar (e.g. foo.zip renamed to foo.jar) and if that doesn't work, use the actual jar tool from Java's development suite and see if that works out. The two formats are similar but different enough that one tool can't handle the other, unless it uses the same magic as 7-zip.

User avatar
moonbat
Knows the dark side
Knows the dark side
Posts: 4942
Joined: 2015-12-09, 15:45
Contact:

Re: Information about porting extension

Unread post by moonbat » 2021-11-11, 01:22

You can repackage the extension by extracting the contents of the jar file at the same location where they are found, then you'll also have to change chrome.manifest to include the direct path to the resource without the /path/somefile.jar!<internal path inside jar> notation. I've done exactly that for some of the extensions I've forked.
"One hosts to look them up, one DNS to find them and in the darkness BIND them."

Image
Linux Mint 21 Xfce x64 on HP i5-5200 laptop, 12 GB RAM.
AutoPageColor|PermissionsPlus|PMPlayer|Pure URL|RecordRewind|TextFX

vannilla
Moon Magic practitioner
Moon Magic practitioner
Posts: 2183
Joined: 2018-05-05, 13:29

Re: Information about porting extension

Unread post by vannilla » 2021-11-11, 01:28

moonbat wrote:
2021-11-11, 01:22
You can repackage the extension by extracting the contents of the jar file at the same location where they are found
Not if the extension reads the actual packed jar file using e.g. XHR on itself.
I've seen it being done, so don't exclude this extension can do the same.

New Tobin Paradigm

Re: Information about porting extension

Unread post by New Tobin Paradigm » 2021-11-11, 01:38

Then.. change it lol. The whole reason for the chrome being jar'd was an obsolete practice when extensions were not kept packed. It makes little sense to use the jar reader to stream into an xpi and then into a jar inside. Been that way since gecko/2.

User avatar
moonbat
Knows the dark side
Knows the dark side
Posts: 4942
Joined: 2015-12-09, 15:45
Contact:

Re: Information about porting extension

Unread post by moonbat » 2021-11-11, 01:47

Yeah, you can tell an extension being ported is quite old when it uses jars inside.
"One hosts to look them up, one DNS to find them and in the darkness BIND them."

Image
Linux Mint 21 Xfce x64 on HP i5-5200 laptop, 12 GB RAM.
AutoPageColor|PermissionsPlus|PMPlayer|Pure URL|RecordRewind|TextFX

MonoS

Re: Information about porting extension

Unread post by MonoS » 2021-11-11, 18:28

@Moonchild: thank you for the information, i was able to start debugging with this :)

@Vannilla & tobin: unpacking the jar and modifying the manifest was sufficient to make it run with some modification

@moonbat: i don't think so, last update was on July 2016

MonoS

Re: Information about porting extension

Unread post by MonoS » 2021-11-12, 19:49

I wanted to update all of you to let you know that i was able to fix my extension, i'm sorry i won't share the fixed version as it's not an open source extension afaik.

Thank you all for the support :)

Locked