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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:11:46+00:00 2026-05-31T05:11:46+00:00

I have a problem that I have been struggling with for a few days

  • 0

I have a problem that I have been struggling with for a few days now.

I am writing a userInput recording system for firefox with a view to using it to record tests for a web-based application.

I am recording onchange events on form fields and saving them in a store using a contentScript with added listeners to each field’s onchange event.

field.addEventListener('change', recordFieldChange);

I am also recording user js confirm responses using an observer-service based override of the window.confirm methods.

var obs = require("observer-service");

obs.add("content-document-global-created", observeWindow);

function observeWindow(subject) {
  var window = subject.wrappedJSObject;
  var standardConfirm = window.confirm;

  window.confirm = function(pMessage) {
    response = standardConfirm(pMessage);
    recordConfirm(response);
    return response;
  }
};

The trouble I am having is that any confirm responses where the confirm is triggered by a field change are recorded before the field change, which is the wrong order for running a test.

I think this is because the page’s onchange is evaluated before the addon contentscript, is there any way to change this order?

I am hoping for a solution or work around that doesn’t use time-outs or changing the basic page content.
I also need to able to record confirms caused by other events like page loads.

  • 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-31T05:11:46+00:00Added an answer on May 31, 2026 at 5:11 am

    The problem is that the page and your content script register event handlers on the same element – and the order in which they will be called is undefined (however, I think that Firefox consistently calls onchange before any listeners added via addEventListener). You need to get the change event before the web page does and triggers additional actions. The solution would be catching the event during the capture phase at the top level. In the capture phase the event “sinks in” to the actual element and triggers capturing event listeners before the bubble phase starts and the event goes up again triggering regular event listeners. Something like this should work:

    window.addEventListener("change", recordFieldChange, true);
    
    function recordFieldChange(event)
    {
      var field = event.target;
      ...
    }
    

    This no longer registers the event listener at the individual field but rather at the window level. Note that this won’t help much if the web page listens for a different event like input or keypress.

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

Sidebar

Related Questions

I have been struggling with this problem for a few days now and I
I've been struggling with a problem that I have for days now and I
I have been struggling with a problem for a couple of days now with
I have been struggling with a problem in the past few days. I really
I've been struggling with this query for a few days now. I'm using PHP/MySQL.
I've seen that a few instances of this problem have been raised already. However,
So, for the past few days I have been struggling to understand how to
I have been struggling with a problem that only happens when the database has
I've been struggling for a couple of days now with this problem on QTcpSockets
I have been struggling with this for several days now and I ran out

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.