Closed Bug 242489 Opened 20 years ago Closed 13 years ago

routeEvent should warn to JS console that it's not implemented

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
normal

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: bzbarsky, Unassigned)

Details

Attachments

(1 file)

See discussion in bug 242429
This is implemented by nsHTMLDocument and nsGlobalWindow.  The basic idea is to
get the console service and log some (localized) warning message to it. 
Something similar to what the code at RectArea::ParseCoords does (with a
"warning" flag).
Keywords: helpwanted
Whiteboard: [good first bug]
Wouldn't the patch in bug 82878 along with a queryable keyword be a better
solution to this problem?
Myk, wrong bug?
Indeed.  Sorry about that.
Note that at this point it would be better to use
nsContentUtils::ReportToConsole instead of copying the RectArea code.
I see that both
<http://lxr.mozilla.org/seamonkey/source/dom/src/base/nsGlobalWindow.cpp#2970>
and
<http://lxr.mozilla.org/seamonkey/source/content/html/document/src/nsHTMLDocument.cpp#2828>
have "implemented" routeEvent; must the nsContentUtils::ReportToConsole be
implemented both places, or can I for example get a reference to nsGlobalWindow
from nsHTMLDocument ?
I noticed that mScriptGlobalObject in nsHTMLDocument is a reference to the
nsGlobalWindow (nsGlobalWindow.h implements nsIScriptGlobalObject) - thanks to
Neil for confirming that.

So I guess that means we can do (in nsHTMLDocument):
  nsCOMPtr<nsGlobalWindow> gW = do_QueryInterface(mScriptGlobalObject);
  gW->routeEvent(aEvt);

Or ? But the QI above doesn't work.. Any pointers ?
You can't QI to a concrete class.  You could QI to nsIDOMJSWindow, though, since
that's where routeEvent is defined.

Note that it's possible for a document to have no script global object, though.
 So it would make more sense for both method to call a static nsContentUtils
method or something.  Though using ReportToConsole() shouldn't take more than a
line or two of code, so it may be OK to just put it in both places.
Attached patch work in progressSplinter Review
Work in progress

Do I need to check for sourceURI or doc ? If they are null, I guess we should
just report it with no source file ?

Can I get the source location anywhere - I saw nsJSUtils::GetCallingLocation,
for example, can I use that?

Am I using the right report category ("content javascript") ?

I believe the actual warning message needs some work as well :)
Assignee: general → bugmail
Status: NEW → ASSIGNED
bz: Any hints on how to get the linenumber, etc here ?
I noticed also that the last patch has an unused nsresult.
You may try to get the current stack frame off nsIXPConnect and getting the line
number from that... I'm not sure whether that will give you the start of the
function, though.

Chances are, there is no good way to get a line number here.

I'm not sure what else you're having trouble getting; could you elaborate?
have you looked at DumpJSStack() (fanout is painful), i can't remember if it does what you want or not.
This bug seems to have been solved already. Please close.
QA Contact: ian → general
Assignee: vhaarr+bmo → nobody
Status: ASSIGNED → RESOLVED
Closed: 13 years ago
Keywords: helpwanted
OS: Linux → All
Hardware: x86 → All
Resolution: --- → WORKSFORME
Whiteboard: [good first bug]
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: