Closed
Bug 231396
Opened 22 years ago
Closed 22 years ago
JS syntax error in XBL binding is not reported
Categories
(Core :: XBL, defect)
Tracking
()
RESOLVED
INVALID
People
(Reporter: WeirdAl, Assigned: hyatt)
Details
(Keywords: testcase)
Attachments
(1 file)
1.34 KB,
application/vnd.mozilla.xul+xml
|
Details |
A simple JavaScript syntax error in an XBL binding causes the entire binding to
fall apart. But the syntax error is never reported to anyone. JS Console never
gets it, the debug terminal never gets it, and Venkman never notices it.
Testcase coming up.
Reporter | ||
Comment 1•22 years ago
|
||
![]() |
||
Comment 2•22 years ago
|
||
Brendan, what's XBL doing wrong here?
Comment 3•22 years ago
|
||
Need to JS_SetErrorReporter on whatever context XBL uses, if it isn't using a
DOM context (created by code in dom/src/base/nsJSEnvironment.cpp).
/be
Reporter | ||
Comment 4•22 years ago
|
||
After #mozilla explained to me what brendan was saying, I took a look at LXR.
In the XBL source code, only nsXBLDocumentInfo.cpp uses JS_SetErrorReporter, on
lines 183 and 204.
The JSContext (through a context variable) apparently enters the picture in
several files: nsXBLProtoImpl.cpp#110, nsXBLProtoImplField.cpp#106,
nsXBLProtoImplMethod.cpp#171, #266, nsXBLProtoImplProperty.cpp#202, #275, #317
are most directly related to this bug on first inspection.
From those, I notice that nsXBLProtoImpl::InstallImplementation calls the
relevant functions which define the context variable via
nsXBLProtoImpl::InitTargetObjects() and later through the InstallMember method
of nsXBLProtoImplMethod, nsXBLProtoImplProperty, and nsXBLProtoImplField (as
appropriate for the method, property or field being added, I gather).
This leads me to suggest that perhaps nsXBLProtoImpl::InitTargetObjects() is the
right place to add the JS_SetErrorReporter() code. I don't want to do it, as
I'm still learning C++.
I didn't bother to check XBL handlers (nsXBLPrototypeHandler.cpp#412) for the
same syntax glitch in my testcase, but I believe those fail to report syntax
errors too.
Am I close, or is this another red herring?
Comment 5•22 years ago
|
||
If XBL creates its own JSContext, where? That is the place to add one, and only
one, JS_SetErrorReporter call. You shouldn't set an error reporter on every
call to bind to an object, e.g. -- all but the first would be redundant,
*assuming* the same, XBL-private, JSContext is being used.
If XBL creates a JSContext on the fly to do something, throws it away, and
repeats, then again: you want to find the JS_NewContext call and add a call to
JS_SetErrorReporter soon after.
/be
Reporter | ||
Comment 6•22 years ago
|
||
LXR doesn't see JS_NewContext anywhere in XBL code. :( Oh, well. This stuff is out of
my ballpark anyway, and I am trying to learn.
Reporter | ||
Comment 7•22 years ago
|
||
Comment 8•22 years ago
|
||
Ok, someone needs to breakpoint NS_ScriptErrorReporter and see why it doesn't do
its thing when called from XBL. Or if it's not called, why not -- harder, bonus
points ;-).
/be
![]() |
||
Comment 9•22 years ago
|
||
See also
http://lxr.mozilla.org/seamonkey/source/content/xbl/src/nsXBLDocumentInfo.cpp#183
and
http://lxr.mozilla.org/seamonkey/source/content/xbl/src/nsXBLDocumentInfo.cpp#204
Though in this case, assuming I set up my breakpoints right, neither
XBL_ProtoErrorReporter nor NS_ScriptErrorReporter is called when that page is
loaded.
![]() |
||
Comment 10•22 years ago
|
||
Note that when I checked in the patch in bug 127567 I _did_ most definitely test
JS error reporting at least for chrome XBL fields. And it worked.
Comment 11•22 years ago
|
||
I shoulda lxr'd. I don't see why there need to be two calls to
JS_SetErrorReporter in xbl. The CreateScriptContext call passes null instead of
a global, to bypass the usual DOM window-ish global setup; well and good. But
that means that NS_CreateScriptContext does not call back through
aGlobal->SetContext, so there's no point in nsXBLDocGlobalObject::SetContext
calling JS_SetErrorReporter.
The JS_SetErrorReporter call in nsXBLDocGlobalObject::GetContext's bootstrapping
case is enough.
Sorry, that's all nit-picking, probably not related to the bug. Is it possible
that the error is being raised before the error reporter has been set? Try a
breakpoint in js_ErrorToException.
/be
Reporter | ||
Comment 12•22 years ago
|
||
be: I'm thinking the same thing, but for a different reason: I don't know the
order of operations when it comes to XBL. That is, the order in which
functions are called, from the moment a CSS -moz-binding rule is discovered to
the binding being fully applied and the constructors firing. It doesn't make
sense any other way for XBL to report some JS errors but not syntax errors
unless the error reporter is set much later than it should be.
Reporter | ||
Comment 13•22 years ago
|
||
Please note bug 232095, which has another JS syntax error in XBL test page, on a
binding which is called twice, and leads to a crash therein.
![]() |
||
Comment 14•22 years ago
|
||
Um. That testcase DOES NOT APPLY THE BINDING TO ANYTHING. If I add a CSS rule
to apply the binding to <foo> then I get errors in the JS console.
Is there a testcase that actually shows a problem?
Reporter | ||
Comment 15•22 years ago
|
||
I am feeling about two millimeters tall right now. Major apologies to everyone
for wasting their time.
Status: NEW → RESOLVED
Closed: 22 years ago
Resolution: --- → INVALID
You need to log in
before you can comment on or make changes to this bug.
Description
•