nsIConsoleService does not work properly

RESOLVED WONTFIX

Status

()

Core
General
RESOLVED WONTFIX
4 years ago
4 years ago

People

(Reporter: Alice0775 White, Unassigned)

Tracking

({addon-compat, regression})

21 Branch
x86_64
Windows 7
addon-compat, regression
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

4 years ago
Build Identifier:
http://hg.mozilla.org/mozilla-central/rev/b03bb3ce8cee
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:22.0) Gecko/20130318 Firefox/22.0 ID:20130318030947

Executing the following code in ScratchPad(chrome privilege) should appear an alert box.
However since Aurora20.0a2, alert box does not pop up anymore.

//begin---------------------------
function myLogToConsole(aMessage, aSourceName, aSourceLine, aLineNumber,
                        aColumnNumber, aFlags, aCategory) {
  var consoleService = Components.classes["@mozilla.org/consoleservice;1"]
                                 .getService(Components.interfaces.nsIConsoleService);
  var scriptError = Components.classes["@mozilla.org/scripterror;1"]
                              .createInstance(Components.interfaces.nsIScriptError);
  scriptError.init(aMessage, aSourceName, aSourceLine, aLineNumber,
                   aColumnNumber, aFlags, aCategory);
  consoleService.logMessage(scriptError);
}

var errorListener = {
  QueryInterface: XPCOMUtils.generateQI([Components.interfaces.nsIConsoleListener,
                                         Components.interfaces.nsISupports]),
  observe: function(message) {
    if ("QueryInterface" in message) {
      var error = message.QueryInterface(Components.interfaces.nsIScriptError);
      alert(error.errorMessage);
    }
  }
}

var consoleService = Components.classes["@mozilla.org/consoleservice;1"]
                     .getService(Components.interfaces.nsIConsoleService);
consoleService.registerListener(errorListener);

myLogToConsole("my message", "", "", "",  "", 1, "myerror");

consoleService.unregisterListener(errorListener);
//end---------------------------



If I changed last line
>> consoleService.unregisterListener(errorListener);
to
>> setTimeout(function(){ consoleService.unregisterListener(errorListener);}, 0);

then it works as expected.
(Reporter)

Comment 1

4 years ago
Err
s/However since Aurora20.0a2/However since Aurora21.0a2/
This was a purposeful change with bug 831428.  See in particular bug 831428 comment 9.

I believe this bug as filed is wontfix.
(Reporter)

Comment 3

4 years ago
Stylish 1.3.1( https://addons.mozilla.org/en-US/firefox/addon/stylish/ ) is affected.
See forum http://forums.mozillazine.org/viewtopic.php?f=23&t=2680325
Hmm.  We didn't have any addon messaging about this, did we?  We probably should.
Flags: needinfo?(jorge)
Flags: needinfo?(benjamin)
Keywords: addon-compat
(In reply to Boris Zbarsky (:bz) from comment #4)
> Hmm.  We didn't have any addon messaging about this, did we?  We probably
> should.

Not yet, no. I flagged bug 831428 for addon-compat and we will definitely include it in our messaging.
Flags: needinfo?(jorge)
Yes, this was an intentional change. I didn't expect that anything other than unit tests could possibly depend on the current behavior, but apparently they do!
Status: NEW → RESOLVED
Last Resolved: 4 years ago
Flags: needinfo?(benjamin)
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.