Closed Bug 1498432 Opened 6 years ago Closed 3 years ago

A tab discarded immediately after creation, loaded, and then discarded again has an incorrect URL when queried.

Categories

(Firefox :: Session Restore, defect, P3)

63 Branch
defect

Tracking

()

RESOLVED FIXED
88 Branch
Tracking Status
firefox88 --- fixed

People

(Reporter: anonymous30901032, Assigned: robwu)

References

(Blocks 2 open bugs)

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:63.0) Gecko/20100101 Firefox/63.0

Steps to reproduce:

1) In about:debugging, open a console by clicking 'Debug' on an extension like uBlock Origin that can 'Access browser tabs'.

2) Input the following code: 

    browser.tabs.create({
        url: "https://www.google.com",
        active: false
    }).then(tab => {
        browser.tabs.discard(tab.id);
        console.log("tab id = " + tab.id);
        console.log("tab index = " + tab.index);
    });

3) Select the new tab, let it finish loading, and then deselect it. 
    
4) Replace tabIndex with the index of the new tab and run the next line:

    browser.tabs.query({
        index: tabIndex,
        currentWindow: true
    }).then(tabs => console.log("tab url = " + tabs[0].url));
    
5) Replace tabId with the id of the new tab and run the next line:    

    browser.tabs.discard(tabId);

6) Repeat step 4 (the url should be "about:blank").

***

This bug seems to be related to https://bugzilla.mozilla.org/show_bug.cgi?id=1422588
Summary: A tab discarded immediately after creation, loaded, and then discarded again has an incorrect title when queried. → A tab discarded immediately after creation, loaded, and then discarded again has an incorrect URL when queried.
Component: Untriaged → Tabbed Browser

(In reply to anon from comment #0)

  1. Repeat step 4 (the url should be "about:blank").

I'm not sure why you expect this. about:blank isn't loaded there, in fact nothing at all is loaded, so I think we want to return the URL that's going to be loaded when selecting the tab.

Status: UNCONFIRMED → RESOLVED
Closed: 5 years ago
Resolution: --- → INVALID

Sorry, I didn't explain it correctly. On step 6, the url that is returned is "about:blank". I expected it to be "https://www.google.com".

Status: RESOLVED → REOPENED
Ever confirmed: true
Resolution: INVALID → ---
Component: Tabbed Browser → Session Restore
See Also: → 1522184
Status: REOPENED → NEW
Priority: -- → P3
See Also: → 1528895
See Also: → 1511756

While investigating a different bug, I found a typo in the code that causes this bug (and the other duplicates).

From https://bugzilla.mozilla.org/show_bug.cgi?id=1694699#c21:

currentURI usually returns the tab's URL, but in the case of discarded tabs, a value is fetched from SessionStore and cached as _cachedCurrentURI. This getter assumes that the following three values are equivalent (and synchronized):

  • browser._cachedCurrentURI
  • SessionStore.getLazyTabValue(aTab, "url")
  • browser.currentURI (non-lazy version)

(...)

  • When undiscarding a tab, the cached value is not correctly erased (so when the tab is discarded again, an incorrect value may be used). In _insertBrowser in tabbrowser.js, aTab should be browser.
Assignee: nobody → rob
Status: NEW → ASSIGNED
Pushed by rob@robwu.nl:
https://hg.mozilla.org/integration/autoland/rev/9ce142e600af
Correctly delete _cachedCurrentURI r=Gijs

Backed out 2 changesets (bug 1498432, bug 1680279) for causing bc failures in browser_ext_tabs_discard_reversed.js
Backout link: https://hg.mozilla.org/integration/autoland/rev/ab3f023535ea70eaa8dd35b3c4833db2a7fa480e
Push with failures, failure log.

Flags: needinfo?(rob)
See Also: → 1696815

It's a Fission-only bug; I've skipped the test (filed bug 1696815) and am going to reland without fixing that unrelated issue. The depth of the bug stack is already much more than I signed up for when I optimistically started with fixing one small thing.

Flags: needinfo?(rob)
Pushed by rob@robwu.nl:
https://hg.mozilla.org/integration/autoland/rev/c021c6541346
Correctly delete _cachedCurrentURI r=Gijs
Status: ASSIGNED → RESOLVED
Closed: 5 years ago3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 88 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: