Bug 949471. history.state should be null, not undefined, when there is no state. r=smaug

This commit is contained in:
Boris Zbarsky 2013-12-12 16:11:56 -05:00
parent e330cbbc35
commit 3b392e4a53
4 changed files with 33 additions and 7 deletions

View File

@ -139,7 +139,7 @@ nsHistory::GetState(JSContext* aCx, ErrorResult& aRv) const
return jsData;
}
return JS::UndefinedValue();
return JS::NullValue();
}
void

View File

@ -19,6 +19,7 @@ support-files =
[test_gsp-quirks.html]
[test_gsp-standards.html]
[test_history_document_open.html]
[test_history_state_null.html]
[test_innersize_scrollport.html]
[test_messageChannel.html]
[test_messageChannel_cloning.html]

View File

@ -0,0 +1,25 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=949471
-->
<head>
<meta charset="utf-8">
<title>Test for Bug 949471</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="application/javascript">
/** Test for Bug 949471 **/
ise(history.state, null, "history.state should be null by default");
</script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=949471">Mozilla Bug 949471</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
</pre>
</body>
</html>

View File

@ -278,18 +278,18 @@ function runTest() {
iframeCw.history.back();
popstateExpected("Going back to page 0 should trigger a popstate.");
is(gLastPopStateEvent.state, null,
ise(gLastPopStateEvent.state, null,
"Going back to page 0 should pop a null state.");
is(iframeCw.history.state, null,
ise(iframeCw.history.state, null,
"Going back to page 0 should pop a null state.");
is(iframeCw.location.search, "",
ise(iframeCw.location.search, "",
"Going back to page 0 should clear the querystring.");
iframeCw.history.forward();
popstateExpected("Going forward to page 1 should trigger a popstate.");
is(JSON.stringify(gLastPopStateEvent.state), JSON.stringify(testObj1),
"Wrong state object popped after going forward to page 1.");
ok(gLastPopStateEvent.state === iframeCw.history.state,
ise(gLastPopStateEvent.state, iframeCw.history.state,
"Wrong state object in document after going forward to page 1.");
ok(iframeCw.location.toString().match(/file_bug500328_1.html$/),
"Going forward to page 1 should leave us at original page.");
@ -300,7 +300,7 @@ function runTest() {
popstateExpected("Going forward to page 2 should trigger a popstate.");
is(JSON.stringify(gLastPopStateEvent.state), JSON.stringify(testObj2),
"Wrong state object popped after going forward to page 2.");
ok(iframeCw.history.state === gLastPopStateEvent.state,
ise(iframeCw.history.state, gLastPopStateEvent.state,
"Wrong state object in document after going forward to page 2.");
ok(iframeCw.location.toString().match(/file_bug500328_1.html\?test1#foo$/),
"Going forward to page 2 took us to " + iframeCw.location.toString());
@ -329,7 +329,7 @@ function runTest() {
"search should be ?test1 after clicking link.");
is(iframeCw.location.hash, "#1",
"hash should be #1 after clicking link.");
ok(iframeCw.history.state === null,
ise(iframeCw.history.state, null,
"Wrong state object in document after clicking link to hash '#1'.");
/*