Closed Bug 874554 Opened 11 years ago Closed 7 years ago

require("sdk/tabs").open doesn't allow to open in the current window while being in private window

Categories

(Add-on SDK Graveyard :: General, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED INCOMPLETE

People

(Reporter: ochameau, Assigned: evold)

References

Details

Attachments

(1 file, 1 obsolete file)

We are facing this limitation in the Simulator:
  https://github.com/mozilla/r2d2b2g/issues/246
  https://github.com/mozilla/r2d2b2g/pull/542/files

The existing code of high level Windows.open method doesn't allow to just open a document in the currently focused top level window.

Scenario:
* open firefox
* open a private window
* call require("sdk/windows").browserWindow.open("http://mozilla.org")

Current:
* See mozilla.org being loaded in background window

Expected:
* See mozilla.org being loaded in the current window (that appear to be private)

I'd imagine that is we do not pass any isPrivate argument, we should try to open in any particular mode but just open in the currently focused window. Especially when the addon has private-browsing permission.
Flags: needinfo?(evold)
Priority: -- → P1
Assignee: nobody → evold
Pointer to Github pull-request
Flags: needinfo?(evold)
Attachment #754646 - Flags: review?(poirot.alex)
Attachment #754646 - Flags: feedback?(rFobic)
Oh sorry, my report doesn't make any sense... I meant tabs.open instead of windows.open!
Third step is:
 * call require("sdk/tabs").open("http://mozilla.org")

So Erik, I'm not sure you changed anything related to Windows behavior? Is non-private argument change anything? Otherwise, we can still land your unit test.
Summary: require("sdk/windows").browserWindow.open doesn't allow to open in the current window while being in private window → require("sdk/tabs").open doesn't allow to open in the current window while being in private window
(In reply to Alexandre Poirot (:ochameau) from comment #2)
> Oh sorry, my report doesn't make any sense... I meant tabs.open instead of
> windows.open!
> Third step is:
>  * call require("sdk/tabs").open("http://mozilla.org")
> 
> So Erik, I'm not sure you changed anything related to Windows behavior? Is
> non-private argument change anything? Otherwise, we can still land your unit
> test.

Ah this is another bug then, I noticed that it is possible for one to open a private window with the code that you provided when they do not have permission to do so...
(In reply to Erik Vold [:erikvold] [:ztatic] from comment #3)
> (In reply to Alexandre Poirot (:ochameau) from comment #2)
> > Oh sorry, my report doesn't make any sense... I meant tabs.open instead of
> > windows.open!
> > Third step is:
> >  * call require("sdk/tabs").open("http://mozilla.org")
> > 
> > So Erik, I'm not sure you changed anything related to Windows behavior? Is
> > non-private argument change anything? Otherwise, we can still land your unit
> > test.
> 
> Ah this is another bug then, I noticed that it is possible for one to open a
> private window with the code that you provided when they do not have
> permission to do so...

I made this bug 876821
So I'm seeing this error:

TypeError: activeWindow is null
resource://gre/modules/commonjs/sdk/tabs/tabs-firefox.js 31

I guess we could open a new non-private window first.
Depends on: 876821
Attachment #754646 - Attachment is obsolete: true
Attachment #754646 - Flags: review?(poirot.alex)
Attachment #754646 - Flags: feedback?(rFobic)
Attachment #755054 - Flags: review?(poirot.alex)
Attachment #755054 - Flags: feedback?(rFobic)
Comment on attachment 755054 [details]
Pointer to Github pull request: https://github.com/mozilla/addon-sdk/pull/1011

Looks good with comment improvement in tests.

But this patch will fix the assertion you have seen ,but not change much to my initial report.
The tab still open in the background window if the current one is private and I omitted to pass `isPrivate`.
Also, the user expectation for the simulator addon is to open the simulator page in the current window, no matter what is its private state.
Do you think we can achieve this via the high level tab.open API?

We had the report of a user setting "never remember history" in settings panel. What it actually does is to always be in private mode!!! With such option toggled, your menuitems library is completely disabled, as it relies on WindowTracker :/
The only way out of this is to give private-browsing permission to the addon.

I tend to think we should soften strict rules around private browsing and especially if the addon has the permission.
Attachment #755054 - Flags: review?(poirot.alex) → review+
(In reply to Alexandre Poirot (:ochameau) from comment #7)
> Comment on attachment 755054 [details]
> Pointer to Github pull request:
> https://github.com/mozilla/addon-sdk/pull/1011
> 
> Looks good with comment improvement in tests.
> 
> But this patch will fix the assertion you have seen ,but not change much to
> my initial report.
> The tab still open in the background window if the current one is private
> and I omitted to pass `isPrivate`.
> Also, the user expectation for the simulator addon is to open the simulator
> page in the current window, no matter what is its private state.
> Do you think we can achieve this via the high level tab.open API?
> 
> We had the report of a user setting "never remember history" in settings
> panel. What it actually does is to always be in private mode!!! With such
> option toggled, your menuitems library is completely disabled, as it relies
> on WindowTracker :/

Ugh that's pretty awful... I'll verify this and I think it should be a separate bug if this is so..

> The only way out of this is to give private-browsing permission to the addon.
> 
> I tend to think we should soften strict rules around private browsing and
> especially if the addon has the permission.

I guess we could allow tabs.open to open in the most recent window regardless of private state if the isPrivate flag is omitted.  This would mean that tab.window should be broken for that tab through.
(In reply to Erik Vold [:erikvold] [:ztatic] from comment #8)
> I guess we could allow tabs.open to open in the most recent window
> regardless of private state if the isPrivate flag is omitted.  

IMO, if no isPrivate flag is set or it is set to false (and permanent private browsing is not enabled), it should open the tab in the most recent non-private window, opening a new non-private window if none exists.
 
If isPrivate is set to true (and permanent private browsing is not enabled), it should open the tab in the most recent private window, opening a new one if none exists.

If permanent private browsing is enabled, the tab should go in the most recent private window, regardless of the isPrivate flag. (And I guess on OSX, open a new private window if all windows are closed?)


Thoughts?
(In reply to Wes Kocher (:KWierso) from comment #9)
> (In reply to Erik Vold [:erikvold] [:ztatic] from comment #8)
> > I guess we could allow tabs.open to open in the most recent window
> > regardless of private state if the isPrivate flag is omitted.  
> 
> IMO, if no isPrivate flag is set or it is set to false (and permanent
> private browsing is not enabled), it should open the tab in the most recent
> non-private window, opening a new non-private window if none exists.
>  
> If isPrivate is set to true (and permanent private browsing is not enabled),
> it should open the tab in the most recent private window, opening a new one
> if none exists.
> 
> If permanent private browsing is enabled, the tab should go in the most
> recent private window, regardless of the isPrivate flag. (And I guess on
> OSX, open a new private window if all windows are closed?)
> 
> 
> Thoughts?

This makes the most sense to me, if a add-on dev wants a super UX then they should support private-browsing imo.
Comment on attachment 755054 [details]
Pointer to Github pull request: https://github.com/mozilla/addon-sdk/pull/1011

I don't think it really needs another review, also by brief look I did not seem to see any API changes. As of global private browsing mode and stuff I think we'll have a broader discussion with other teams what we expect behavior should be as this becomes quite ridiculous.
Attachment #755054 - Flags: feedback?(rFobic)
Commit pushed to master at https://github.com/mozilla/addon-sdk

https://github.com/mozilla/addon-sdk/commit/73742801c68af15f227aaec039f0ec288c028ba2
Bug 874554:
- adding a test for opening a new non-private window when there is only a private window open
- newly opened windows use a non-private flag by default now
Commits pushed to master at https://github.com/mozilla/addon-sdk

https://github.com/mozilla/addon-sdk/commit/edb96df02993c4dc192eb394a4d441bad3eba265
Bug 874554: tabs.open dnw when the active window was private or when there was no active window

Conflicts:
	test/private-browsing/windows.js

https://github.com/mozilla/addon-sdk/commit/d201e4f2f075c8c15486001eb4c5a644e858da7a
Merge pull request #1011 from erikvold/874554-3

Bug 874554: tabs.open dnw when there was no active window r=@ochameau
Commits pushed to integration at https://github.com/mozilla/addon-sdk

https://github.com/mozilla/addon-sdk/commit/edb96df02993c4dc192eb394a4d441bad3eba265
Bug 874554: tabs.open dnw when the active window was private or when there was no active window

https://github.com/mozilla/addon-sdk/commit/d201e4f2f075c8c15486001eb4c5a644e858da7a
Merge pull request #1011 from erikvold/874554-3
I'm going through the list of open bugs that github robot has commented in. Is this bug fixed, Alex?
Flags: needinfo?(poirot.alex)
It looks like my original bug report is still not being addressed as described in comment 7.
Flags: needinfo?(poirot.alex)
Afaict Alex suggests that if private browsing is supported, and the add-on dev omits the `private` flag when using `tabs.open` then the tab should be opened in the current active window regardless whether it is private or not.  I don't see an issue with that, are you ok with this Irakli?

However I think that if private-browsing is not supported by the add-on then tabs should never be opened in a private window.

Is that about right Alex?
Flags: needinfo?(rFobic)
Flags: needinfo?(poirot.alex)
Yes, you are describing correctly what I suggested. I can easily agree that it looks bad if we want to be strict and clear about private browsing.
But we should also be carefull about the final addon behaviors we are introcuding!!
Here, when I switched to the simulator I switched from SDK developer to SDK user and I quickly realized how bad the private browsing story was when using high level API. I ended up using low level API (because I knew exactly what was going on) and toggled the private permission. But keep it mind that's just a workaround. The simulator doesn't need to do anything with private contents, it only needs to be able to display a menuitem in Firefox menu and eventually open the dashboard in the current window, no matter if its private or not. I will never require to access or set any private data.

But I think most addons won't do any of these two things. We will just end up with poor quality addons, or make addon devs frustated when they try to fix these things.

Let me repeat the typical bad scenario we faced in the simulator:
A bunch of users toggled the "never remember my history" firefox setting. It actually switchs the default firefox window to private mode! So we ended up loosing our menuitem in the Firefox menu. And when we managed to make the menu to work again, it would open a new non-private window just for the dashboard.
Flags: needinfo?(poirot.alex)
I do understand points that Alex is making and they make sense to me. Also if I recall it correctly, the main intention for omitting private windows from `WindowTracker` was to avoid adding widgets, panels, context menus, to such windows. Now that I think about it I think it's totally reasonable to expose access to private windows and tabs just don't include them in page-mods and don't add widgets etc.. unless add-on is opted-in.

I don't remember bug number, but there is one which suggests to let users enable / disable support for private browsing per add-on. I think that's a lot better solution and if users opt-in widgets and other APIs should just handle private windows as is.
Flags: needinfo?(rFobic)
But again, I think more general document UX perspective how things should work in private windows would be super useful.
Flags: needinfo?(evold)
+1 for some ux decision here, I don't think we should expose private windows/tabs to add-ons that haven't request private-browsing permission however.
Flags: needinfo?(evold)
Priority: P1 → --
https://bugzilla.mozilla.org/show_bug.cgi?id=1399562
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: