Bug 680257 - Always call nsDocShell::ScrollToAnchor on short-circuited loads, so as to make sure the target pseudo-class is updated correctly. r=bz
This commit is contained in:
@@ -8452,13 +8452,13 @@ nsDocShell::InternalLoad(nsIURI * aURI,
|
|||||||
GetCurScrollPos(ScrollOrientation_X, &cx);
|
GetCurScrollPos(ScrollOrientation_X, &cx);
|
||||||
GetCurScrollPos(ScrollOrientation_Y, &cy);
|
GetCurScrollPos(ScrollOrientation_Y, &cy);
|
||||||
|
|
||||||
// We scroll whenever we're not doing a history load. Note that
|
// ScrollToAnchor doesn't necessarily cause us to scroll the window;
|
||||||
// sometimes we might scroll even if we don't fire a hashchange
|
// the function decides whether a scroll is appropriate based on the
|
||||||
// event! See bug 653741.
|
// arguments it receives. But even if we don't end up scrolling,
|
||||||
if (!aSHEntry) {
|
// ScrollToAnchor performs other important tasks, such as informing
|
||||||
rv = ScrollToAnchor(curHash, newHash, aLoadType);
|
// the presShell that we have a new hash. See bug 680257.
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
rv = ScrollToAnchor(curHash, newHash, aLoadType);
|
||||||
}
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
mLoadType = aLoadType;
|
mLoadType = aLoadType;
|
||||||
mURIResultedInDocument = PR_TRUE;
|
mURIResultedInDocument = PR_TRUE;
|
||||||
|
|||||||
@@ -120,6 +120,8 @@ _TEST_FILES = \
|
|||||||
file_bug669671.sjs \
|
file_bug669671.sjs \
|
||||||
test_bug675587.html \
|
test_bug675587.html \
|
||||||
test_bfcache_plus_hash.html \
|
test_bfcache_plus_hash.html \
|
||||||
|
test_bug680257.html \
|
||||||
|
file_bug680257.html \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
|
ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
|
||||||
|
|||||||
16
docshell/test/file_bug680257.html
Normal file
16
docshell/test/file_bug680257.html
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<style type='text/css'>
|
||||||
|
a { color: black; }
|
||||||
|
a:target { color: red; }
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body onload='(opener || parent).popupLoaded()'>
|
||||||
|
|
||||||
|
<a id='a' href='#a'>link</a>
|
||||||
|
<a id='b' href='#b'>link2</a>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
59
docshell/test/test_bug680257.html
Normal file
59
docshell/test/test_bug680257.html
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html>
|
||||||
|
<!--
|
||||||
|
https://bugzilla.mozilla.org/show_bug.cgi?id=680257
|
||||||
|
-->
|
||||||
|
<head>
|
||||||
|
<title>Test for Bug 680257</title>
|
||||||
|
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||||
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=680257">Mozilla Bug 680257</a>
|
||||||
|
|
||||||
|
<script type="application/javascript;version=1.7">
|
||||||
|
|
||||||
|
SimpleTest.waitForExplicitFinish();
|
||||||
|
|
||||||
|
var popup = window.open('file_bug680257.html');
|
||||||
|
|
||||||
|
// The popup will call into popupLoaded() once it loads.
|
||||||
|
function popupLoaded() {
|
||||||
|
// runTests() needs to be called from outside popupLoaded's onload handler.
|
||||||
|
// Otherwise, the navigations we do in runTests won't create new SHEntries.
|
||||||
|
SimpleTest.executeSoon(runTests);
|
||||||
|
}
|
||||||
|
|
||||||
|
function runTests() {
|
||||||
|
checkPopupLinkStyle(false, 'Initial');
|
||||||
|
|
||||||
|
popup.location.hash = 'a';
|
||||||
|
checkPopupLinkStyle(true, 'After setting hash');
|
||||||
|
|
||||||
|
popup.history.back();
|
||||||
|
checkPopupLinkStyle(false, 'After going back');
|
||||||
|
|
||||||
|
popup.history.forward();
|
||||||
|
checkPopupLinkStyle(true, 'After going forward');
|
||||||
|
|
||||||
|
popup.close();
|
||||||
|
SimpleTest.finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkPopupLinkStyle(isTarget, desc) {
|
||||||
|
var link = popup.document.getElementById('a');
|
||||||
|
var style = popup.getComputedStyle(link);
|
||||||
|
var color = style.getPropertyValue('color');
|
||||||
|
|
||||||
|
// Color is red if isTarget, black otherwise.
|
||||||
|
if (isTarget) {
|
||||||
|
is(color, 'rgb(255, 0, 0)', desc);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
is(color, 'rgb(0, 0, 0)', desc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user