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

RESOLVED FIXED

Status

()

Core
DOM
RESOLVED FIXED
15 years ago
15 years ago

People

(Reporter: Tim, Assigned: Christopher Aillon (sabbatical, not receiving bugmail))

Tracking

({regression})

Trunk
regression
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(URL)

Attachments

(1 attachment)

556 bytes, patch
Christopher Aillon (sabbatical, not receiving bugmail)
: review+
Details | Diff | Splinter Review
(Reporter)

Description

15 years ago
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).
(Reporter)

Comment 1

15 years ago
Created attachment 127636 [details] [diff] [review]
Patch

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
Last Resolved: 15 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.