privateBrowsingId flag lost when userContextId is set for new browser windows

RESOLVED FIXED in Firefox 66

Status

()

defect
P3
normal
RESOLVED FIXED
8 months ago
6 months ago

People

(Reporter: robwu, Assigned: robwu)

Tracking

(Blocks 1 bug)

62 Branch
Firefox 66
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(firefox66 fixed)

Details

Attachments

(1 attachment)

Assignee

Description

8 months ago
In bug 1501006, I found that if userContextId is set, then privateBrowsingId is lost. Although container tabs are currently not supported in PBM, it would be nice to still support them when permanent private mode is enabled (bug 1320757). This bug blocks that.

Here are the minimal reproduction steps:

STR:
1. Start Firefox and enable chrome debugging (devtools.chrome.enabled=true at about:config , or the debugging checkbox at about:debugging ).
2. Open a new private window with an initial tab, by running the following code in the global JS console (Ctrl-Shift-J):

{
 let args = Cc["@mozilla.org/array;1"].createInstance(Ci.nsIMutableArray);
 let url = Cc["@mozilla.org/supports-string;1"].createInstance(Ci.nsISupportsString);
 url.data = "http://example.org/";
 let userContextId = Cc["@mozilla.org/supports-PRUint32;1"].createInstance(Ci.nsISupportsPRUint32);
 userContextId.data = 1;
 args.appendElement(url);
 args.appendElement(null);
 args.appendElement(null);
 args.appendElement(null);
 args.appendElement(null);
 args.appendElement(null);
 args.appendElement(userContextId);
 args.appendElement(Services.scriptSecurityManager.getSystemPrincipal());
 args.appendElement(Services.scriptSecurityManager.getSystemPrincipal());
 Services.ww.openWindow(null, "chrome://browser/content/browser.xul", "_blank", "chrome,dialog=no,all,private", args);
}

3. Open the content toolbox for the new window (menu: Tools > Web Developer > Browser Content Toolbox), and run:

tabs[0].content.document.nodePrincipal.origin

Expected:
- "http://example.com^userContextId=1&privateBrowsingId=1"

Actual:
- "http://example.com^userContextId=1"


I reproduced this on Firefox 62.0.3 and Firefox Nightly 65 (buildID 20181022220734).

Additional information, as of the fix for bug 1415333, if I open the browser toolbox (Ctrl-Alt-Shift-I) and put a breakpoint at [1] (before STR step 2), and then run:
    userContextId = 0;
  when the breakpoint is triggered (after STR step 2), then the expected result occurs.
  Doing this causes the following line to be skipped:
    browser.webNavigation.setOriginAttributesBeforeLoading({ userContextId });
  It seems that privateBrowsingId is cleared by the line following [1].
  Before bug 1415333, skipping the line would result in a (private) tab without userContextId.

[1]: https://searchfox.org/mozilla-central/rev/fcfb479e6ff63aea017d063faa17877ff750b4e5/browser/base/content/browser.js#1078
Assignee

Updated

8 months ago
Assignee: nobody → rob
Status: NEW → ASSIGNED
Priority: -- → P3

Comment 2

6 months ago
Pushed by rob@robwu.nl:
https://hg.mozilla.org/integration/autoland/rev/4b9c119d25c3
Preserve privateBrowsingId OA when userContextId is set r=Gijs

Comment 3

6 months ago
bugherder
Status: ASSIGNED → RESOLVED
Closed: 6 months ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 66
You need to log in before you can comment on or make changes to this bug.