Last Comment Bug 852220 - nsIConsoleService does not work properly
: nsIConsoleService does not work properly
Status: RESOLVED WONTFIX
: addon-compat, regression
Product: Core
Classification: Components
Component: General (show other bugs)
: 21 Branch
: x86_64 Windows 7
: -- normal (vote)
: ---
Assigned To: Nobody; OK to take it and work on it
:
Mentors:
Depends on:
Blocks: 831428
  Show dependency treegraph
 
Reported: 2013-03-18 11:06 PDT by Alice0775 White
Modified: 2013-03-18 22:56 PDT (History)
3 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments

Description Alice0775 White 2013-03-18 11:06:17 PDT
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.
Comment 1 Alice0775 White 2013-03-18 11:07:54 PDT
Err
s/However since Aurora20.0a2/However since Aurora21.0a2/
Comment 2 Boris Zbarsky [:bz] (Out June 25-July 6) 2013-03-18 11:40:13 PDT
This was a purposeful change with bug 831428.  See in particular bug 831428 comment 9.

I believe this bug as filed is wontfix.
Comment 3 Alice0775 White 2013-03-18 12:00:55 PDT
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
Comment 4 Boris Zbarsky [:bz] (Out June 25-July 6) 2013-03-18 12:31:25 PDT
Hmm.  We didn't have any addon messaging about this, did we?  We probably should.
Comment 5 Jorge Villalobos [:jorgev] 2013-03-18 14:05:06 PDT
(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.
Comment 6 Benjamin Smedberg [:bsmedberg] 2013-03-18 22:56:09 PDT
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!

Note You need to log in before you can comment on or make changes to this bug.