Closed
Bug 957479
Opened 11 years ago
Closed 11 years ago
history.pushState({}, '', url) throws when called after document.open()
Categories
(Core :: DOM: Navigation, defect)
Core
DOM: Navigation
Tracking
()
RESOLVED
FIXED
mozilla29
People
(Reporter: shogun70, Assigned: bzbarsky, Mentored)
References
Details
Attachments
(1 file)
8.08 KB,
patch
|
smaug
:
review+
|
Details | Diff | Splinter Review |
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:27.0) Gecko/20100101 Firefox/27.0 (Beta/Release)
Build ID: 20131216183647
Steps to reproduce:
1. Create a HTML file on the server with the following content:
<!DOCTYPE html><title>Old document</title><h1>Old document</h1>
<script>
function rewrite() {
var url = document.URL;
document.open();
document.write('<!DOCTYPE html><title>New document</title><h1>New document</h1>');
document.close();
try { history.pushState({}, '', url); }
catch(error) { alert('history.pushState() failed'); }
}
document.addEventListener('DOMContentLoaded', rewrite);
</script>
2. In Firefox navigate to the URL for the HTML file.
Actual results:
The document is rewritten from "old" to "new" markup.
An alert box states 'history.pushState() failed'.
Expected results:
The document is rewritten from "old" to "new" markup.
No alert box.
Assignee | ||
Comment 1•11 years ago
|
||
Sean, thank you for filing this and for the testcase!
So as expected the issue is that nsDocShell::AddState is working with mCurrentURI which in this case is a wyciwyg URI.
Olli, do you think it makes more sense to work with the document URI instead or to work with the result of calling CreateExposableURI on mCurrentURI? Note that the former is likely much faster, and I expect the result to be the same in wyciwyg cases, but not error page cases... On the other hand, I don't expect much push/replaceState on error pages, right?
Status: UNCONFIRMED → NEW
Component: Untriaged → Document Navigation
Ever confirmed: true
Flags: needinfo?(bugs)
OS: Mac OS X → All
Product: Firefox → Core
Hardware: x86 → All
Version: 27 Branch → Trunk
Assignee | ||
Comment 2•11 years ago
|
||
Attachment #8358515 -
Flags: review?(bugs)
Assignee | ||
Updated•11 years ago
|
Assignee: nobody → bzbarsky
Status: NEW → ASSIGNED
Assignee | ||
Updated•11 years ago
|
Flags: needinfo?(bugs)
Updated•11 years ago
|
Attachment #8358515 -
Flags: review?(bugs) → review+
Assignee | ||
Comment 3•11 years ago
|
||
Flags: in-testsuite+
Target Milestone: --- → mozilla29
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Assignee | ||
Updated•11 years ago
|
Mentor: bzbarsky
You need to log in
before you can comment on or make changes to this bug.
Description
•