Closed Bug 212532 Opened 21 years ago Closed 21 years ago

Getting window.history returns null after the first attempt (bug 209866 regression)

Categories

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

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: timwatt, Assigned: caillon)

References

()

Details

(Keywords: regression)

Attachments

(1 file)

Bug 209866 is responsible for getting window.history to fail after the first
get. This is due to:
http://lxr.mozilla.org/seamonkey/source/dom/src/base/nsGlobalWindow.cpp#1106 - 

1100   if (!mHistory && mDocShell) {
1101     mHistory = new HistoryImpl(mDocShell);
1102     if (!mHistory) {
1103       return NS_ERROR_OUT_OF_MEMORY;
1104     }
1105 
1106     NS_ADDREF(*aHistory = mHistory);
1107   }

(the assignment should happen outside of the if).
Patch coming up (gotta test it first).
Attached patch PatchSplinter Review
Moves the addref/assignment outside of the if.	Appears to fix the problem.
Quick testcase (forgot to post that):
1) access javascript:history
  (expect "[object History]")
2) access the same URL again
  (expect the same thing)

Before this patch, step 2 yields "null". After it, "[object History]".
Attachment #127636 - Flags: superreview+
Attachment #127636 - Flags: review?(caillon)
Attachment #127636 - Flags: review?(caillon) → review+
Comment on attachment 127636 [details] [diff] [review]
Patch

r=biesi if you make that NS_IF_ADDREF
Checking in dom/src/base/nsGlobalWindow.cpp;
/cvsroot/mozilla/dom/src/base/nsGlobalWindow.cpp,v  <--  nsGlobalWindow.cpp
new revision: 1.606; previous revision: 1.605
done

(with NS_ADDREF -> NS_IF_ADDREF change done)
Status: NEW → RESOLVED
Closed: 21 years ago
Resolution: --- → FIXED
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: