Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6369509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:48:52+00:00 2026-05-25T00:48:52+00:00

I am working on Firefox addon on Mac OS, where I want to notify

  • 0

I am working on Firefox addon on Mac OS, where I want to notify my XPCOM component when user disables the add-on.This is working except for the event is posted more than once(equal to the number of FF Windows open), this is happening since the AddonManager.addAddonListener(nsListener); is called on the onload(window.addEventListener(“load”, function(e) { TopWnd.onLoad(e); }, false);) in browser overlay js for all windows and the event “onDisabling” is called in each window.

var nsListener = {
    onDisabling: function(addon, needsRestart) 
{
        if (addon.id.toLowerCase() == "XXXXXXX") 
{
        var observerService = Components.classes["@mozilla.org/observer-service;1"]
                            .getService(Components.interfaces.nsIObserverService);
            if (observerService) {
                observerService.notifyObservers(null, "ext-disable", "Ext is disabled");
            }

        }
    }

}

To avoid notifying XPCOM component from all windows, I want to determine if the current opened tab/window is the add-on page and only then add the AddonManager.addAddonListener(nsListener); or notify only from that page.What is the best way to determine if the current window/tab is add-on page.

Please help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T00:48:53+00:00Added an answer on May 25, 2026 at 12:48 am

    I think that this approach is wrong. You shouldn’t register this listener in each window, it should be registered only once in a central place. You avoid the problem with multiple windows then and also the problem that sometimes no windows are open (possible on Mac OS X). It would make sense to register that listener directly in your XPCOM component. However, if for some reason this isn’t possible – you can still have a JavaScript module that each window will import and that will register this listener (a JavaScript module loads only once, no matter how often it is imported, so only one listener will be registered).

    Side-notes: Don’t use generic topic names like ext-disabled (assuming that this is really the topic you are using), other extensions might decide to use the same name and there will be a huge mess. Use something that relates to the name of your extension so that it won’t be chosen by other developers. Also, using observer service to communicate with your own XPCOM component is strange to say the least, why not get an instance of that XPCOM component and call its methods directly?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on the firefox addon. In this i have to add the
I used to use an add-on for firefox called measureit. Now its not working
Good day everyone. I am working on a Firefox extension, and I want to
Hi Javascript gurus, I have this Javascript code which is working fine on Firefox
The firefox add-on I am working on is best viewed in fullscreen mode. (I
I have this code. The code below is working in Firefox, but it is
I'm working on a firefox addon and one thing i'm unsure on is how
Pixel Perfect https://addons.mozilla.org/en-US/firefox/addon/pixel-perfect/ Is not working any more on FF6 and seams that they
I'm working on developing a Firefox add-on using the Add-on SDK . I changed
this code is working on firefox and ie var j$dialog = j$('<div><embed width=100% height=80%

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.