:target pseudo-class not updating when pressing back button

VERIFIED FIXED in Firefox 7

Status

()

Core
Document Navigation
VERIFIED FIXED
6 years ago
4 years ago

People

(Reporter: Matt Cosentino, Assigned: Justin Lebar (not reading bugmail))

Tracking

({qawanted, regression})

Trunk
mozilla9
qawanted, regression
Points:
---
Bug Flags:
in-testsuite +

Firefox Tracking Flags

(firefox5 unaffected, firefox6 wontfix, firefox7- fixed, firefox8- fixed, firefox9- fixed)

Details

Attachments

(1 attachment, 1 obsolete attachment)

(Reporter)

Description

6 years ago
User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0) Gecko/20100101 Firefox/6.0
Build ID: 20110811165603

Steps to reproduce:

Here is a jsfiddle that demonstrates the problem.

http://jsfiddle.net/gvFPv/2/


Actual results:

Clicking on the "a" link correctly applies the :target pseudo-class to the "a" link.  Clicking on the "b" link then applies the pseudo-class to the "b" link and removes it from the "a" link.  Pressing the back button does not update the pseudo-class on either link.


Expected results:

When pressing the back button it should remove the pseudo-class from the "b" link and apply it to the "a" link.  This works in Firefox 3.6 and it works in Chrome, but it does not work in Firefox 6.  I haven't tested 4 or 5, so I'm not sure when this regressed.
This regressed with Version 6. 5 is WFM.
Keywords: regressionwindow-wanted

Comment 2

6 years ago
Regression window(cached m-c hourly):
Works:
http://hg.mozilla.org/mozilla-central/rev/837f762860af
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0a1) Gecko/20110524 Firefox/6.0a1 ID:20110524085016
Fails:
http://hg.mozilla.org/mozilla-central/rev/0fad9fa9fa3f
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0a1) Gecko/20110524 Firefox/7.0a1 ID:20110524105711
Pushlog:
http://hg.mozilla.org/mozilla-central/pushloghtml?fromchange=837f762860af&tochange=0fad9fa9fa3f

Suspected:
575362d9b92e	Justin Lebar — Bug 653741 - You should be able to scoll back to the current anchor by focusing the location bar and pressing <enter>. r=bz
Blocks: 653741
Status: UNCONFIRMED → NEW
Component: General → Document Navigation
Ever confirmed: true
Keywords: regressionwindow-wanted → regression
Product: Firefox → Core
QA Contact: general → docshell
(Assignee)

Comment 3

6 years ago
I guess ScrollToAnchor also updates the :target?  That would be unfortunate.
(Assignee)

Updated

6 years ago
Assignee: nobody → justin.lebar+bug
(Assignee)

Comment 4

6 years ago
Created attachment 554947 [details] [diff] [review]
Patch v1
(Assignee)

Comment 5

6 years ago
Nominating for tracking 7, 8, 9.  :target isn't widely used AFAIK, but this bug breaks it pretty hard.
(Assignee)

Updated

6 years ago
status-firefox5: --- → unaffected
status-firefox6: --- → affected
status-firefox7: --- → affected
status-firefox8: --- → affected
status-firefox9: --- → affected
tracking-firefox7: --- → ?
tracking-firefox8: --- → ?
tracking-firefox9: --- → ?
(Assignee)

Comment 6

6 years ago
Pushed patch v1 to try:

http://tbpl.allizom.org/?tree=Try&usebuildbot=1&rev=2be0bae7f070
(Assignee)

Comment 7

6 years ago
Created attachment 554949 [details] [diff] [review]
Patch v2 (with tests)
(Assignee)

Updated

6 years ago
Attachment #554947 - Attachment is obsolete: true
(Assignee)

Comment 8

6 years ago
Forgot to include the tests last time.

http://tbpl.allizom.org/?tree=Try&usebuildbot=1&rev=fd83538ee308
(Assignee)

Comment 9

6 years ago
Comment on attachment 554949 [details] [diff] [review]
Patch v2 (with tests)

Looks good on try so far.

I think this change is safe, assuming

  !aSHEntry iff aLoadType == LOAD_HISTORY  (1),

because in ScrollToAnchor, we always pass FALSE as the second argument to shell->GoToAnchor (indicating that we should not scroll to the anchor) if aLoadType == LOAD_HISTORY, and because ScrollToAnchor doesn't do anything other than call shell->GoToAnchor and, if the hash is empty, call SetCurScrollPosEx(0,0).

If (1) does not hold, then I'm confused about why I wrote the condition around ScrollToAnchor as |!aSHEntry| in the first place.
Attachment #554949 - Flags: review?(bzbarsky)
(Assignee)

Comment 10

6 years ago
...and because SetCurScrollPosEx is not called if aLoadType is HISTORY or RELOAD.  But this is all probably clearer if you just look at the code.  :)
(1) as written above is certainly false.  !aSHEntry is true for non-history loads (e.g. LOAD_NORMAL, LOAD_LINK, etc).

I believe that |aSHEntry iff (aLoadType == LOAD_HISTORY || aLoadType == LOAD_RELOAD_NORMAL)| is true, however, and I would think that's what you really care about here, no?
Comment on attachment 554949 [details] [diff] [review]
Patch v2 (with tests)

r=me if you fix the commit message to not have try gunk in it.

Thank you for adding tests for this!
Attachment #554949 - Flags: review?(bzbarsky) → review+
(Assignee)

Comment 13

6 years ago
> I believe that |aSHEntry iff (aLoadType == LOAD_HISTORY || aLoadType == 
> LOAD_RELOAD_NORMAL)| is true, however, and I would think that's what you really 
> care about here, no?

Yes, indeed!

> Thank you for adding tests for this!

I didn't realize I had a choice.  :)

Inbound - http://hg.mozilla.org/integration/mozilla-inbound/rev/ea8d99353056
Flags: in-testsuite+
Whiteboard: [inbound]
(Assignee)

Comment 14

6 years ago
WRT branches, we can't just back out bug 653741, because that itself was a regression fix.  I think we definitely want this on Aurora.  Beta is a tougher call.  This code is obviously fragile, and although it seems from comment 9 and comment 11 that this change is safe, it could be that one of our assumptions is wrong in an edge case.

The likely failure mode is that we'd regress some other edge case, so maybe this known fix outweighs the possibility of creating another, similar bug.
(Assignee)

Updated

6 years ago
Attachment #554949 - Flags: approval-mozilla-beta?
Attachment #554949 - Flags: approval-mozilla-aurora?
http://hg.mozilla.org/mozilla-central/rev/ea8d99353056
Status: NEW → RESOLVED
Last Resolved: 6 years ago
OS: Windows 7 → All
Hardware: x86_64 → All
Resolution: --- → FIXED
Whiteboard: [inbound]
Target Milestone: --- → mozilla9
Version: 6 Branch → Trunk
Comment on attachment 554949 [details] [diff] [review]
Patch v2 (with tests)

Discussed in triage - approving this for both, but it would help if you could give QA some information about how to watch for regressions here. We'll be eager to back this out of beta if those regressions show up, but we need to know what to look for.
Attachment #554949 - Flags: approval-mozilla-beta?
Attachment #554949 - Flags: approval-mozilla-beta+
Attachment #554949 - Flags: approval-mozilla-aurora?
Attachment #554949 - Flags: approval-mozilla-aurora+
Keywords: qawanted
(Assignee)

Comment 17

6 years ago
Regressions would likely be apparent when navigating between two history entries which share a document.  For instance, when navigating between foo.html and foo.html#bar, or if foo.html calls history.pushState, navigating between those two history entries.
(Assignee)

Updated

6 years ago
status-firefox6: affected → wontfix
status-firefox9: affected → fixed
(Assignee)

Comment 18

6 years ago
Pushed to branches: Aurora (FF8) and Beta (FF7):

http://hg.mozilla.org/releases/mozilla-aurora/rev/636ee9539d54
http://hg.mozilla.org/releases/mozilla-beta/rev/fbcd27571662
status-firefox7: affected → fixed
status-firefox8: affected → fixed
(Assignee)

Comment 19

6 years ago
Thank you for the bug report, Matt!
(In reply to Justin Lebar [:jlebar] from comment #18)
> http://hg.mozilla.org/releases/mozilla-beta/rev/fbcd27571662

Backed out because of mochitest-plain-2 perma-orange.
status-firefox7: fixed → affected
Keywords: qawanted

Updated

6 years ago
Keywords: qawanted
(Assignee)

Comment 21

6 years ago
In particular, the test for this bug is timing out, beta only.

http://tinderbox.mozilla.org/showlog.cgi?log=Mozilla-Beta/1314145114.1314147541.7504.gz
(Assignee)

Comment 22

6 years ago
I think the test failure on beta is because my mochitest doesn't include Mochikit/packed.js, which is gone in trunk but not yet in beta.

Try: http://tbpl.allizom.org/?tree=Try&usebuildbot=1&rev=4b67045e0865
(Assignee)

Comment 23

6 years ago
With test fix this was green on try.  Pushed to beta:

http://hg.mozilla.org/releases/mozilla-beta/rev/dddb008734ee
status-firefox7: affected → fixed

Updated

6 years ago
Duplicate of this bug: 682935

Updated

6 years ago
tracking-firefox7: ? → -
tracking-firefox8: ? → -
tracking-firefox9: ? → -

Comment 25

6 years ago
Verified as fixed on:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:7.0) Gecko/20100101 Firefox/7.0
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:8.0a2) Gecko/20110831 Firefox/8.0a2
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:9.0a1) Gecko/20110831 Firefox/9.0a1

Mozilla/5.0 (X11; Linux i686; rv:7.0) Gecko/20100101 Firefox/7.0
Mozilla/5.0 (X11; Linux i686; rv:8.0a2) Gecko/20110901 Firefox/8.0a2
Mozilla/5.0 (X11; Linux i686; rv:9.0a1) Gecko/20110831 Firefox/9.0a1

Mozilla/5.0 (Windows NT 5.1; rv:7.0) Gecko/20100101 Firefox/7.0
Mozilla/5.0 (Windows NT 5.1; rv:8.0a2) Gecko/20110828 Firefox/8.0a2
Mozilla/5.0 (Windows NT 5.1; rv:9.0a1) Gecko/20110829 Firefox/9.0a1

Mozilla/5.0 (Windows NT 6.1; rv:7.0) Gecko/20100101 Firefox/7.0
Mozilla/5.0 (Windows NT 6.1; rv:8.0a2) Gecko/20110825 Firefox/8.0a2
Mozilla/5.0 (Windows NT 6.1; rv:9.0a1) Gecko/20110825 Firefox/9.0a1

Steps:
1. Open http://jsfiddle.net/gvFPv/2/
2. Click on the "a" link, then click on the "b" link.
3. Click on the back button.
Clicking on the "a" link applies the :target pseudo-class to the "a" link.  Clicking on the "b" link applies the pseudo-class to the "b" link and removes it from the "a" link. When clicking the back button the pseudo-class is applied to the "a" link and it is removed from the "b" link.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.