Closed Bug 104549 Opened 24 years ago Closed 21 years ago

Too many duplicate warnings in javascript console on referencing an undefined variable or object property with strict warnings enabled

Categories

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

defect
Not set
major

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: caillon, Unassigned)

References

()

Details

Attachments

(3 files)

Seen on Linux trunk 2001101212- 1. Ensure JS strict warnings are on 2. Clear JS Console 3. Click on the URL above Expected results in the JS Console: Warning: reference to undefined property document.all Actual: Warning: reference to undefined property document.all Warning: reference to undefined property document.all Warning: reference to undefined property document.all Warning: reference to undefined property document.all Warning: reference to undefined property document.all Warning: reference to undefined property document.all Warning: reference to undefined property document.all Warning: reference to undefined property document.all Warning: reference to undefined property document.all Warning: reference to undefined property document.all Warning: reference to undefined property document.all Warning: reference to undefined property document.all Warning: reference to undefined property document.all Warning: reference to undefined property document.all It's always displayed 14X. Doesn't matter which object you pass alert(); if the property you passed is undefined, you get 14 warnings.
Status: NEW → ASSIGNED
OS: Linux → All
Hardware: PC → All
Target Milestone: --- → mozilla1.1
Maybe I got the answer in the WDF-DOM mailing list. It appears we throw an alert for each letter of the string "[object Object]" Any idea why people?
*** Bug 111686 has been marked as a duplicate of this bug. ***
See also testcase for an HTML document http://bugzilla.mozilla.org/showattachment.cgi?attach_id=59023 We really are calling js_GetProperty 15 times, but only when strict mode is enabled (a "printf proof"). We get into some goofy state where js_GetPropery ultimately calls NS_ScriptErrorReporter, which wants to fire an event which needs to js_GetProperty again, which wants to call NS_ScriptErrorReporter (or something like that).
Not that it matters too much, but I count 13 each of blarfs and snarfs in jrgm's testcase, and 14 alls from the URL.
Summary: Warning: Too Many Warnings! calling alert() with an undefined object property → Warning: Too Many Warnings! referencing an undefined object property with JS strict warnings enabled
http://wickline.org/mozilla/2001120100/ another example case, originally for bug 113078
*** Bug 113078 has been marked as a duplicate of this bug. ***
jrgm, if that's the case, why aren't we getting a crash or something like that because of recursive function calls? Why exactly 13 warnings for each error?
Incidentally, this bug and bug 81279 combine to generate a sizable performance hit. The sooner we get either one of these two bugs fixed, the better.
I think I already gave the reason in my comment #1, but I never got around to figure out why it is doing that.
Summary: Warning: Too Many Warnings! referencing an undefined object property with JS strict warnings enabled → Warning: Too Many Warnings! referencing an undefined object property with JavaScript strict warnings enabled
In my experience, this error also shows up for XUL documents, and for *any* "reference to undefined variable" error, which makes using the JS console for debugging a bit annoying, especially if you're a novice js programmer who hits this kind of warning often ;) Changing the subject to include more search-friendly words - I almost gave up and filed a dupe.
Summary: Warning: Too Many Warnings! referencing an undefined object property with JavaScript strict warnings enabled → duplicate warnings in javascript console on reference of undefined variable or property with strict warnings enabled
sballard: when changing summaries on bugs that have been around a while, please try not to remove any words from the original bug summary. People who have queried with certain words may now find their queries are turning up blank. For example, I query on this bug with "Too Many Warnings" and you've just removed that. I have no objections to rewording or making additions to any summary for clarity, but please keep as much of the original summary as possible to prevent future lectures ;)
Summary: duplicate warnings in javascript console on reference of undefined variable or property with strict warnings enabled → Too many duplicate warnings in javascript console on referencing an undefined variable or object property with strict warnings enabled
Sorry! I should have thought of that. I was worried that the summary was getting excessively long already and the words "too many" seemed redundant; didn't occur to me that people might already know the bug by those words.
*** Bug 122250 has been marked as a duplicate of this bug. ***
cc'ing Bob from the duplicate bug -
I'm not sure I'd call that "reduced" compared to the testcase that's already in the URL of this bug :)
Oops! Missed that.
*** Bug 138694 has been marked as a duplicate of this bug. ***
I think this bug is so heavy... because many pages use "if(document.all),if(document.layer),etc... ". When use these width setTimeout or setInterval, ...like freez.
Increasing severity to major. This hits anyone who is trying to debug their scripts via the JS Console. Also see Comment #20 -
Severity: normal → major
Target Milestone: mozilla1.1alpha → ---
Blocks: 78179
Mass-reassigning bugs to dom_bugs@netscape.com
Assignee: jst → dom_bugs
Status: ASSIGNED → NEW
*** Bug 214611 has been marked as a duplicate of this bug. ***
Shouldn't this have Component "JavaScript Console"? I searched before filing the dupe, but couldn't imagine it would live in another component. And FWIW, I'm getting exactly *12* warnings. It may be of interest that this code: <script> var x; self.undefinedProperty; </script> yields 11 warnings for "QueryInterface" + 1 warning for "undefinedProperty" (current Linux nightly, not in 1.4). This is because of |var x| and has not this special behavior when used in data:text/html,<script>var x; self.undefinedProperty;</script> I will attach it as testcase.
Hmm, the special behavior with QueryInterface does not show up in the testcase, but it does when I view it as a local file.
Ignore comment 26. I tested with Mozilla 1.4 by accident.
http://lxr.mozilla.org/mozilla/source/dom/src/base/nsJSEnvironment.cpp#139 : 181 static PRInt32 errorDepth; // Recursion prevention 182 errorDepth++; 183 184 nsCOMPtr<nsIPresContext> presContext; 185 docShell->GetPresContext(getter_AddRefs(presContext)); 186 187 if(presContext && errorDepth < 2) { 188 nsScriptErrorEvent errorevent; 189 errorevent.eventStructType = NS_EVENT; 190 errorevent.message = NS_SCRIPT_ERROR; 191 192 errorevent.fileName = fileName.get(); 193 errorevent.errorMsg = msg.get(); 194 errorevent.lineNr = report ? report->lineno : 0; 195 196 // HandleDOMEvent() must be synchronous for the recursion block 197 // (errorDepth) to work. 198 globalObject->HandleDOMEvent(presContext, &errorevent, nsnull, 199 NS_EVENT_FLAG_INIT, &status); 200 } 201 202 errorDepth--; Is this the problem? Is HandleDOMEvent() actually synchronous? Is a static variable guaranteed to be 0 initially?
*** Bug 219957 has been marked as a duplicate of this bug. ***
> Is HandleDOMEvent() actually synchronous? Is a static variable guaranteed to be > 0 initially? Yes and yes. /be
WFM with a current nightly build. See also http://bugzilla.mozilla.org/show_bug.cgi?id=220603#c22.
This does indeed seem to be fixed by the bug 220603 changes....
Status: NEW → RESOLVED
Closed: 21 years ago
Resolution: --- → WORKSFORME
I no longer see the problem since using Mozilla 1.6.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: