Confusion about 'module' imports

General discussion, compatibility and contributed extensions.

Moderators: satrow, Lootyhoof, Andrew Gilbertson

thosrtanner
Moon lover
Moon lover
Posts: 91
Joined: Sat, 10 May 2014, 18:19
Location: UK

Confusion about 'module' imports

Postby thosrtanner » Sat, 09 Dec 2017, 07:57

So I have an extension that includes a module which provides wrappers for alert, prompt and confirm which stick the name of my extension in the title bar. Because, well, I'm lazy and I find boxes coming up without any hint as to where they came from are rather worrying.

The code (from infoRSS) starts off like this:

Code: Select all

/* exported EXPORTED_SYMBOLS */
var EXPORTED_SYMBOLS = [
    "alert", /* exported alert */
    "prompt", /* exported prompt */
    "confirm", /* exported confirm */
];

function alert(msg)
{
    promptService.alert(null, inforssGetName(), msg);
}


and it seemed to work fine.

Today I installed s3.translator so I could see what I was filling in on that Japanese survey.

And all its prompts came up with an inforss prefix.

So what context are extensions run in? Is it a huge global one, where any function name can mess with any other extension? And if so, how the heck is one meant to protect against conflicts?

User avatar
JustOff
Localization Coordinator
Localization Coordinator
Posts: 1084
Joined: Thu, 03 Sep 2015, 19:47
Location: UA
Contact:

Re: Confusion about 'module' imports

Postby JustOff » Sat, 09 Dec 2017, 10:21

Overlay extensions (the ones that use chrome.manifest to extend existing XUL files) share common namespace so their developers must take special measures to avoid conflicts with the browser code and other add-ons. Obviously, infoRSS does not do this well.

PS: Restartless extensions (including Add-on SDK based) run in their own scope and do not have this problem.
Here are the add-ons I made in a spare time. That was fun!

User avatar
New Tobin Paradigm
Knows the dark side
Knows the dark side
Posts: 4034
Joined: Tue, 09 Oct 2012, 19:37

Re: Confusion about 'module' imports

Postby New Tobin Paradigm » Sat, 09 Dec 2017, 14:25

Bootstrap extensions also have some drawbacks as well.. Kinda depends on what you are ultimately wanting to do i suppose..
OH, BUT MY PRIDE! GRR! I WISH I WERE A CARROT!
[ ニュー・トビン・パラダイム ]

thosrtanner
Moon lover
Moon lover
Posts: 91
Joined: Sat, 10 May 2014, 18:19
Location: UK

Re: Confusion about 'module' imports

Postby thosrtanner » Sun, 10 Dec 2017, 07:19

I keep shying off making this restartless because the documentation is a bit "don't do this" + handwavy magic about how to get round it. But the first thing it says is that one of the issues is fixed by this: https://bugzilla.mozilla.org/show_bug.cgi?id=675372 which went into firestorm 38. Which is a bit after palemoon first forked. So does palemoon have that fix?

User avatar
JustOff
Localization Coordinator
Localization Coordinator
Posts: 1084
Joined: Thu, 03 Sep 2015, 19:47
Location: UA
Contact:

Re: Confusion about 'module' imports

Postby JustOff » Sun, 10 Dec 2017, 11:50

Yes, bug #675372 is the part of the Pale Moon 27 codebase. However, in most cases you can safely use the chrome:// protocol instead of the resource:// like it did before this bug was implemented.
Here are the add-ons I made in a spare time. That was fun!


Return to “Browser extensions”

Who is online

Users browsing this forum: No registered users and 4 guests