Open Bug 1128443 Opened 9 years ago Updated 1 year ago

"WARNING: content window passed to PrivateBrowsingUtils.isWindowPrivate. Use isContentWindowPrivate instead" from browser.js

Categories

(Firefox :: Private Browsing, defect)

35 Branch
defect

Tracking

()

People

(Reporter: whimboo, Unassigned)

References

Details

(Keywords: regression, Whiteboard: [mozmill])

There are even more instances of usage of isWindowPrivate around in browser.js. I wonder why we haven't converted all of them at once when turning the flip in bug 1069059?

From one of the latest Nightly builds:

WARNING: content window passed to PrivateBrowsingUtils.isWindowPrivate. Use isContentWindowPrivate instead (but only for frame scripts).
pbu_isWindowPrivate@resource://gre/modules/PrivateBrowsingUtils.jsm:25:14
nsBrowserAccess.prototype.openURI@chrome://browser/content/browser.js:14057:21

Associated source:

    let isPrivate = PrivateBrowsingUtils.isWindowPrivate(aOpener || window);
    switch (aWhere) {

I also see lots of other calls like that, but not sure if all of them have to be converted too:

https://dxr.mozilla.org/mozilla-central/search?limit=100&redirect=false&q=isWindowPrivate%20path%3Abrowser%2F
The problem is that most of the instances you point out are fine. As long as the argument passed in is a chrome window, there's no problem.

I guess aOpener can be a content window. Mainly we just want to make sure it's not a CPOW. Mike, what's the state of that argument right now? Do we ever pass a CPOW there?
Flags: needinfo?(mconley)
My patch for bug 1047603 adds a check to ensure that aOpener is never a CPOW - that's just waiting on one last bit of review to land.

That function does not expect a CPOW as aOpener, but (until my patch lands) there are no protections preventing it from occurring.
Flags: needinfo?(mconley)
Mike, I assume this is fixed now? I cannot repro given that we no longer run Mozmill.
Flags: needinfo?(mconley)
I don't think this is an issue anymore. We've outlawed CPOW usage in browser code, so this would be throwing.
Flags: needinfo?(mconley)
Hm, wait, let me rephrase.

I don't think I've run into this warning for a while, but I suppose it's possible we might still run into them. As billm says, at any point, a content nsIDOMWindow or CPOW could be passed to the function. Luckily, in the CPOW case, we'll throw, and won't do synchronous messaging.
This currently happens if you press the "Help" button (or invoke its keyboard shortcut) in an about:preferences "subdialog" (Fonts, Colors, Languages, Connections, and Sanitize).
Severity: normal → S3

I can still reproduce this warning on Nightly 113.0a1 (2023-03-31) if I click one of the "Learn more" links from about:preferences.

WARNING: content window passed to PrivateBrowsingUtils.isWindowPrivate. Use isContentWindowPrivate instead (but only for frame scripts).
pbu_isWindowPrivate@resource://gre/modules/PrivateBrowsingUtils.sys.mjs:23:11
getTargetWindow@resource:///modules/URILoadingHelper.sys.mjs:644:57
openLinkIn@resource:///modules/URILoadingHelper.sys.mjs:467:16
openTrustedLinkIn@resource:///modules/URILoadingHelper.sys.mjs:716:10
openTrustedLinkIn@chrome://browser/content/utilityOverlay.js:124:20
handleEvent@chrome://global/content/elements/moz-support-link.mjs:72:26

You need to log in before you can comment on or make changes to this bug.