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 8427827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:53:09+00:00 2026-06-10T04:53:09+00:00

I am developing an extension on Firefox’s Addon SDK (v1.9). My extension blocks or

  • 0

I am developing an extension on Firefox’s Addon SDK (v1.9). My extension blocks or allows resources by implementing nsIContentPolicy and testing their URIs against a database of URIs to block.

Problem

I need to have access to the tab object (if available) from the shouldLoad function of nsIContentPolicy.

I assume the part to use for this is the “context” parameter on the shouldLoad function which is nsISupports. I have tried using getTabForWindow(win) with no luck since context is not nsIDOMWindow (Identify tab that made request in Firefox Addon SDK)

  • 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-06-10T04:53:11+00:00Added an answer on June 10, 2026 at 4:53 am

    The context parameter is either a document or an element. Getting from there to a window isn’t hard:

    var {Ci} = require("chrome");
    if (!(context instanceof Ci.nsIDOMWindow))
    {
      // If this is an element, get the corresponding document
      if (context instanceof Ci.nsIDOMNode && context.ownerDocument)
        context = context.ownerDocument;
    
      // Now we should have a document, get its window
      if (context instanceof Ci.nsIDOMDocument)
        context = context.defaultView;
      else
        context = null;
    }
    
    // If we have a window now - get the tab
    if (context)
    {
      var tabsLib = require("tabs/tab.js");
      return tabsLib.getTabForWindow(context.top);
    }
    else
      return null;
    

    For reference: Node, Document,window.

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

Sidebar

Related Questions

I am developing a Firefox extension on the Addon SDK (V1.9). Objective I need
I find myself developing a Firefox Addon with the ADD-ON SDK . Is it
In a Firefox extension I am currently developing using the addon builder , I
While developing a firefox extension, I create a wizard window from overlay.js using: this.wizard
I am developing a Firefox extension and I need to perform some high-speed calculations
I'm developing a Firefox extension, and I have a toolbar button that displays an
I am developing a firefox extension, i need to detect which operating system firefox
I am developing a firefox extension and ideally would be able to get the
I'm developing a firefox extension and i want to simulate :hover state of an
I am developing a FireFox extension when I do xhr to the Secure server

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.