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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:32:56+00:00 2026-06-10T00:32:56+00:00

I am building an extension with Firefox’s ADD ON SDK (v1.9) that will be

  • 0

I am building an extension with Firefox’s ADD ON SDK (v1.9) that will be able to read all HTTP requests / responses and calculate the time they took to load. This includes not only the main frame but any other loading file (sub frame, script, css, image, etc.).

So far, I am able to use the “observer-service” module to listen for:

  • “http-on-modify-request” when a HTTP request is created.
  • “http-on-examine-response” when a HTTP response is received
  • “http-on-examine-cached-response” when a HTTP response is received entirely from cache
  • “http-on-examine-merged-response” when a HTTP response is received partially from cache

My application follows the following sequence:

  1. A request is created and registered through the observer.
  2. I save the current time and mark it as start_time of the request load.
  3. A response for a request is received and registered through one of the observers.
  4. I save the current time and use the previously saved time to calculate load time of the request.

Problem:
I am not able to link the start and end times of the load since I cannot find a request ID (or other unique value) that will tie the request with the response.
I am currently using the URL of the request / response to tie them together but this is not correct since it will raise a “race condition” if two or more equal urls are loading at the same time. Google Chrome solves this issue by providing unique requestIds, but I have not been able to find a similar functionality on Firefox.

  • 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-10T00:32:57+00:00Added an answer on June 10, 2026 at 12:32 am

    I am aware of two ways to recognize a channel that you receive in this observer. The “old” solution is to use nsIWritablePropertyBag interface to attach data to the channel:

    var {Ci} = require("chrome");
    var channelId = 0;
    
    ...
    
    // Attach channel ID to a channel
    if (channel instanceof Ci.nsIWritablePropertyBag)
      channel.setProperty("myExtension-channelId", ++channelId);
    
    ...
    
    // Read out channel ID for a channel
    if (channel instanceof Ci.nsIPropertyBag)
      console.log(channel.getProperty("myExtension-channelId"));
    

    The other solution would be using WeakMap API (only works properly starting with Firefox 13):

    var channelMap = new WeakMap();
    var channelId = 0;
    
    ...
    
    // Attach channel ID to a channel
    channelMap.set(channel, ++channelId);
    
    ...
    
    // Read out channel ID for a channel
    console.log(channelMap.get(channel));
    

    I’m not sure whether WeakMap is available in the context of Add-on SDK modules, you might have to “steal” it from a regular JavaScript module:

    var {Cu} = require("chrome");
    var {WeakMap} = Cu.import("resource://gre/modules/FileUtils.jsm", null);
    

    Obviously, in both cases you can attach more data to the channel than a simple number.

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

Sidebar

Related Questions

how do I insert a listener to Firefox http requests and responses, so that
I am building a simple Firefox extension using the Add-on SDK 1.0. Scouring the
I am building an extension where I want to be able to add a
I'm building a Firefox Extension that, among other things, needs to replace body background
I am building and extension with Firefox's Addon SDK (v1.9). My application is supposed
I'm building a firefox extension, and essentially, I want to add in a button
I am building a Firefox extension and have come a long way. One of
I am building a firefox extension. In this extension, I want to see the
I am building a chrome extension and I need to be able to execute
I'm building a Firefox extension and would like to allow the user to delete

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.