Closed Bug 361271 Opened 18 years ago Closed 15 years ago

JavaScript functions are not defined at page load even though they have been declared

Categories

(Core :: General, defect)

defect
Not set
major

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: mozilla, Unassigned)

References

()

Details

Attachments

(1 file)

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1) Gecko/20061010 Firefox/2.0 Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1) Gecko/20061010 Firefox/2.0 This is an intermittent problem that only appears at certain times. The system complains about JavaScript functions not being defined but this is false as the functions have been declared earlier. Seems to be a timing issue on page load Reproducible: Sometimes Steps to Reproduce: 1. Visit above page and press F5 to refresh whilst moving the mouse over the link 2. 3.
Confirmed, moving the mouse over and out on the link while pressing F5 consistently triggered an error for me. This doesn't make much sense, the script inside the onmouseover HTML event handler shouldn't be able to run before the script itself has been rendered. Perhaps this happens while the page is unloading, with the script functions being removed before the bound event handlers?
WFM, Mac trunk.
Component: Error Console → General
QA Contact: javascript.console → general
This is confirmed. I have noticed on several sites.
I have added some random text to increase the download time of the page. This helps to demonstrate the problem. It appears as though the function is not available until the end of the document. This shows up regularly on bigger pages. The more content the page contains the worse the problem becomes. Hope this helps, Andy
Severity: normal → major
Version: unspecified → 2.0 Branch
We think this is the same bug as reported for the Prototype.js framework: http://dev.rubyonrails.org/ticket/5393
I've confirmed this bug first occurring in Firefox version 1.5.0.1rc1. However, this is obviously more related to the core changes at the time (which seem to be related to 1.8.1). I haven't been able to find an immediately-suspicious ticket. If there's any topic that this relates to, in particular, it's the execution of DOM events (either they're occurring too early, or their global context isn't being set properly). Although, I don't see any tickets that deal with that specific issue (for that particular release), so some hunting will still have to occur.
Product: Firefox → Core
QA Contact: general → general
Version: 2.0 Branch → Trunk
Attaching a revised version of the original test that uses mousemove events instead of mouse over, which makes reproducing the problem easier. (I usually 2-3 "customFunction is not defined" errors.) This test demonstrates that event handlers are getting triggered without the scope-chain properly configured. In this case, the 'window' object does not appear to be in the scope chain, which is why "customFunction()" causes a ReferenceError, but "window.customFunction()" doesn't.
DUP of Bug 252542 (Reload case)? Test case is very similar to this bug's one. See also Bug 199430 (load of new URL by FORM case).
The testcase works for me, and these symptoms were fixed, as bugs cited in comment 8 say. Resolving.
Status: UNCONFIRMED → RESOLVED
Closed: 15 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: