Closed Bug 53925 Opened 25 years ago Closed 25 years ago

Self-overwriting JavaScript works until M17, broken in M18

Categories

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

defect

Tracking

()

VERIFIED WONTFIX

People

(Reporter: Kanef, Assigned: jst)

Details

Attachments

(3 files)

To reproduce: Open the attached test case and press the button. If the test passes, the variables remain accessible throughout the execution of the function that is overwriting its own page. Netscape 4.75: Fails IE 5.0 (2022, Mac): Passes Mozilla M15 2000041805: Passes Mozilla M17 2000080712: Passes Mozilla M18 2000082310: Fails Mozilla M18 2000091509: Fails Mozilla M18 2000092220: Fails
Attached file Test case
Keywords: 4xp
Same results on windows 98 for 2000 092408. all/all
OS: Mac System 9.0 → All
Hardware: Macintosh → All
Here is a core JavaScript version of the testcase (no HTML) : var var1 = " seem "; var var2 = "passes the test."; rewrite_page(); function rewrite_page () { print("This test was failed by Mozilla 2000092220 and this browser"); print(", it would " + var1 + ', '); print(var2); } As long as we call the function rewrite_page() after the definition of var1 and var2, the test passes. The output is: This test was failed by Mozilla 2000092220 and this browser , it would seem , passes the test. If we put the call to rewrite_page() before the definition of var1 and var2, the test fails: This test was failed by Mozilla 2000092220 and this browser , it would undefined, undefined I don't see any JavaScript Engine problem here; reassigning to DOM Level 0 for a look. In the reporter's testcase, the calls to "print" I have used above are calls to "document.write" instead -
Assignee: rogerl → jst
Component: Javascript Engine → DOM Level 0
QA Contact: pschwartau → desale
The above test case shows: 1. During script loading, the rewrite works. 2. After script loading, via a setTimeout, it fails. 3. From a form's event handler, it fails.
Attached file onLoad test case
The "problem" here is that document.open() ends up calling JS_ClearScope() which basically ends up removing non-standard properties on the global object (the 'window'). While this might seem a bit weird, it is intentional and mozilla currently behaves the same way 4.x does. IOW, WONTFIX, there are easy workarounds for this problem that do work in both 4.x, IE and mozilla, for instance one could copy the value of the global variables into local variables before calling document.open() and then use the local variables from then on...
Status: NEW → RESOLVED
Closed: 25 years ago
Resolution: --- → WONTFIX
VERIFIED wontfix
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: