Issues using nsIConsoleService

RESOLVED INVALID

Status

()

Core
XPCOM
RESOLVED INVALID
7 years ago
6 years ago

People

(Reporter: vb4guy, Unassigned)

Tracking

5 Branch
x86
Windows XP
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

7 years ago
User-Agent:       Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)
Build Identifier: Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20100101 Firefox/5.0

1. nsIConsoleService.registerListener() works perfectly but then firefox hangs at 100% CPU if I close out of the browser without explicitly calling nsIConsoleService.unregisterListener().  The same happens if I try refresing the browser.

2. Unable to clear the error console:
    netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");

    console.clear(); // This doesn't work either

    var consoleService = Components.classes["@mozilla.org/consoleservice;1"].getService(Components.interfaces.nsIConsoleService);
    consoleService.reset(); // This doesn't work


Reproducible: Always
(Reporter)

Updated

7 years ago
OS: Mac OS X → Windows XP
Version: unspecified → 2.0 Branch

Updated

7 years ago
Version: 2.0 Branch → 5 Branch
Mihai, can we please confirm this?

Comment 2

7 years ago
Also adding ddahl for comment.
1. Must be a platform bug that the nsIConsoleService does not properly clean up its registered listeners. Nonetheless, The author should unregister its own listener.

2. In what context do you try to execute the given code?
(Reporter)

Comment 4

7 years ago
1. Yes, if I explicitly unregister the listener in the window.onunload event then Firefox won't lock up.  BTW, I am running Window XP (SP3).  Now if I duplicate this issue in FF6, the browser still hangs and CPU is 100% but the web console says: "attempt to run compile-and-go script on a cleared scope."

2. Refer to my example above.  Basically, I have a bunch of stuff in the web console and calling console.clear() or consoleService.reset() doesn't appear to do anything.

Comment 5

7 years ago
(In reply to comment #4)
> 1. Yes, if I explicitly unregister the listener in the window.onunload event
> then Firefox won't lock up.  BTW, I am running Window XP (SP3).  Now if I
> duplicate this issue in FF6, the browser still hangs and CPU is 100% but the
> web console says: "attempt to run compile-and-go script on a cleared scope."
> 
> 2. Refer to my example above.  Basically, I have a bunch of stuff in the web
> console and calling console.clear() or consoleService.reset() doesn't appear
> to do anything.

Please attach your code, including the listener you are registering and unregistering.
(Reporter)

Comment 6

7 years ago
Created attachment 549266 [details] [diff] [review]
Debug class

To call you need to first define: var Cosmos = function() { };

Then include a reference to the attached JS file.  To add register a listener call: Cosmos.Debug.AddListener(function(message) { alert(message); });

Then call console.log("something"); and it will invoke the listener function.

There is a temp fix in the Class which will unregister the listener when window.onunload is invoked, so you would need to remark that logic in the Cosmos.Debug class in order to duplicate the bug.
Attachment #549266 - Attachment is patch: true
Attachment #549266 - Attachment mime type: application/octet-stream → text/plain
Status: UNCONFIRMED → NEW
Component: Developer Tools → XPCOM
Ever confirmed: true
Product: Firefox → Core
QA Contact: developer.tools → xpcom
moving to core::xpcom.

Comment 8

6 years ago
I don't understand what this testcase is about yet. Is this meant to be a content webpage using .enablePrivilege? If so, when the page is unloaded the content function (which is still a console listener) will throw every time, because you aren't allowed to run functions on an unloaded window. This throws yet another console error, which repeats infinitely.

Now console service had some protection against this kind of recursion, it just happened to be broken. I just fixed it in bug 675221, but this is really just a bug in your code, I think...
Status: NEW → RESOLVED
Last Resolved: 6 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.