Closed Bug 132904 Opened 23 years ago Closed 23 years ago

Clearing timeout without setting one & without passing timeoutID throws exception.

Categories

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

defect

Tracking

()

VERIFIED FIXED
mozilla1.0

People

(Reporter: desale, Assigned: jst)

References

()

Details

(Whiteboard: [HAVE FIX])

Attachments

(2 files, 1 obsolete file)

If we use "clearTimeout()" method without passing "timeoutID" to it. [Which is wrong because "clearTimeout()" method expects "timeoutID" as argument in order to clear that particular timeout.] It throws an exception. Filing this bug is wrong in itself because throwing exception for it is correct thing to do. However 4.x browser works fine even if we use "clearTimeout()" method without passing "timeoutID", so it raises questions about all those webpages out there which use "clearTimeout()" method without passing "timeoutID" & without setting timeout. for examples, please have a look at "bugscape bug# 9521". I know best component to assign this bug to is "Evangelism", but I just talked to Johnney & he said he could fix it, so I'm assgining it to dom-level-0. STEPS TO REPRODUCE: 1] Visit http://bubblegum/desale/bug9521.html OR 1] Load testcase I'm going to attach. 2] Click button 'Try clearing Timeout without setting one' You will see alert showing exception we are catching. Please have a look at source of testcase & you will see that I'm calling cleartimeout() without passing timeoutID to it. [Absolutely wrong thing to do] Well Standards say we should pass timeoutID. So now we have to decide if we want to stick to standards or we want not to throw exception, so all those webpages out there work fine as they used to work with 4.x. Testcase attachment following.
nsbeta1, priority p2. ccing Bob, Arun, Lisa & paul.
Keywords: nsbeta1
Priority: -- → P2
IE doesn't throw an exception when calling clearTimeout with no argument either. Note that the test case throws an exception in IE due to it's use of 'start'. Do we know of any pages/apis which rely on this behavior? I haven't seen this in my incidents.
Transfering nsbeta1+ from the bugscape bug.
Status: NEW → ASSIGNED
Keywords: nsbeta14xp, mozilla1.0, nsbeta1+
OS: Windows NT → All
Hardware: PC → All
Target Milestone: --- → mozilla1.0
Attached patch Proposed fix.Splinter Review
This patch makes clearTimeout() and clearInterval() callable w/o an argument, or with any type of argument w/o us throwing an exception, just like 4x and IE do.
I've seen bugs on this earlier, I can't say how common it is, but it's easy enough to fix and it's one less backwards incompatibility to worry about, so I say let's fix it.
Whiteboard: [HAVE FIX]
I also think fixing this one would be right call since we move one step forward towards backward compatibility. I also say Lets fix it.
Keywords: 4xp, mozilla1.0, nsbeta1+nsbeta1
OS: All → Windows NT
Hardware: All → PC
Whiteboard: [HAVE FIX]
Target Milestone: mozilla1.0 → ---
Keywords: nsbeta14xp, mozilla1.0, nsbeta1+
OS: Windows NT → All
Hardware: PC → All
Whiteboard: [HAVE FIX]
Target Milestone: --- → mozilla1.0
Comment on attachment 75680 [details] [diff] [review] Proposed fix. jband says sr=jband
Attachment #75680 - Flags: superreview+
Comment on attachment 75680 [details] [diff] [review] Proposed fix. You might wanna keep the reference to bug 30700 (and this one). Either way r=sicking
Attachment #75680 - Flags: review+
See bug 58101 and all its duplicates for important examples of this problem -
Johnny: will this patch allow users to do clearTimeout(TimeoutID) where TimeoutID is uninitialized? i.e. where the variable provided contains the value |undefined|? That crops up from time to time ...
Yes, this patch takes care of that problem too.
Thank you for the fast action on this.
Comment on attachment 75680 [details] [diff] [review] Proposed fix. >+ /** >+ * These methods take one optional argument that's the timer ID to >+ * clear. Often in existing code these methods afre passed >+ * undefined, which is a nop so we need to support that as well. >+ */ Please fix this comment (s/afre/are), also is "nop" a real word? >+ if (argc < 1) { >+ // No arguments, return early. Is this what other browsers do? What's the point of calling it without argument if it does nothing?
Calling clearTimeout() w/o arguments is obviously pointless, but we need to not throw an exception to be compatible with other browsers.
Comment on attachment 75680 [details] [diff] [review] Proposed fix. a=dbaron for trunk checkin
Attachment #75680 - Flags: approval+
Fixed.
Status: ASSIGNED → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
Verified on 2002-05-23-08-trunk.
Status: RESOLVED → VERIFIED
Attached file _irrelevant_ (obsolete) —
Comment on attachment 8825096 [details] _irrelevant_ attached by mistake, marking as obsolete
Attachment #8825096 - Attachment description: avoid taking const references to fields behind accessors. → _irrelevant_
Attachment #8825096 - Attachment filename: Bug-132904---avoid-taking-const-references-to-fiel.patch → _irrelevant_
Attachment #8825096 - Attachment is obsolete: true
Attachment #8825096 - Attachment is patch: false
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: