Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

For #13336: Open bookmarks in current tab #23169

Merged
merged 3 commits into from
Feb 3, 2022

Conversation

czlucius
Copy link
Contributor

@czlucius czlucius commented Jan 12, 2022

Pull Request checklist

  • Tests: This PR includes thorough tests or an explanation of why it does not
  • Screenshots: This PR includes screenshots or GIFs of the changes made or an explanation of why it does not
  • Accessibility: The code in this PR follows accessibility best practices or does not include any user facing features. In addition, it includes a screenshot of a successful accessibility scan to ensure no new defects are added to the product.

To download an APK when reviewing a PR:

  1. click on Show All Checks,
  2. click Details next to "Taskcluster (pull_request)" after it appears and then finishes with a green checkmark,
  3. click on the "Fenix - assemble" task, then click "Run Artifacts".
  4. the APK links should be on the left side of the screen, named for each CPU architecture

Hi there
These are my fixes to #13336, to open bookmarks in the current tab. I am not sure whether this change is approved, but as the issue is still open, I am submitting a draft PR.
May I ask the Fenix UX team for their approval on this change, or is the bookmarks opening in a new tab as intended? I can work on it to add other things if needed.
Thank you!

Here are the videos of the proposed change:

1.Screen_Recording_20220112-231257_Firefox.Preview.mp4

Bookmarklets also work:

Screen_Recording_20220112-231756_Firefox.Preview.mp4

@firefoxci-taskcluster
Copy link

No Taskcluster jobs started for this pull request
The `allowPullRequests` configuration for this repository (in `.taskcluster.yml` on the
default branch) does not allow starting tasks for this pull request.

Copy link
Contributor

@jonalmeida jonalmeida left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change looks good. You need to fix the tests (see the run-testDebugUnitTest task) and comment below. 🙂

@@ -77,7 +77,7 @@ class DefaultBookmarkController(
val flags = EngineSession.LoadUrlFlags.select(EngineSession.LoadUrlFlags.ALLOW_JAVASCRIPT_URL)
openInNewTabAndShow(
item.url!!,
true,
false, // See https://github.com/mozilla-mobile/fenix/issues/13336
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to add a reference to the issue here. The commit message contains a reference to it already.

Suggested change
false, // See https://github.com/mozilla-mobile/fenix/issues/13336
false,

@czlucius
Copy link
Contributor Author

@jonalmeida
I've removed the comment already.
The test that fails is

TEST: handleBookmarkTapped should open the bookmark

According to the test at BookmarkControllerTest, it checks if a bookmark is opened in a new tab:

@Test
fun `handleBookmarkTapped should load the bookmark in a new tab`() {
var invokePendingDeletionInvoked = false
val flags = EngineSession.LoadUrlFlags.select(EngineSession.LoadUrlFlags.ALLOW_JAVASCRIPT_URL)
createController(
invokePendingDeletion = {
invokePendingDeletionInvoked = true
}
).handleBookmarkTapped(item)
assertTrue(invokePendingDeletionInvoked)
verify {
homeActivity.openToBrowserAndLoad(
item.url!!,
true,
BrowserDirection.FromBookmarks,
flags = flags
)
}
}

However, this issue is for the bookmark to open in the current tab, so the test is failing

@jonalmeida jonalmeida added the pr:needs-changes PRs that need some changes/fixes before they can land label Jan 13, 2022
@jonalmeida
Copy link
Contributor

That's correct! The verify was asserting that we always opened in a new tab, and this the behaviour you've changed, so we just need to fix the test to verify the new behaviour. 🙂

@czlucius
Copy link
Contributor Author

Ok, I've corrected the test.

@czlucius
Copy link
Contributor Author

czlucius commented Jan 14, 2022

About the new behaviour of opening in the current tab, since Fenix doesn't associate the home screen with a physical tab, I found out that this will cause a problem: If the user opens a new tab(clicks New Tab), then subsequently opens the bookmark, the bookmark would open in the previous tab, which may not be the intended action the user wanted to take. How should we fix this side effect? (is there a method to find out whether the user is on the home screen page of a new tab? - there could be other instances where the home screen is launched without the intention to open a new tab, e.g. the home button)
Thanks.

@czlucius
Copy link
Contributor Author

I've modified the test, but it's still failing

@czlucius
Copy link
Contributor Author

@jonalmeida
May I ask why is the test failing even when both values (the one in the test, and the one in the BookmarkController class) are false? I've tried this out on my machine, this does not happen when both are true. Is there something else that I am missing here?
Thanks.

@jonalmeida
Copy link
Contributor

@czlucius there were two tests that were failing:

  • handleBookmarkTapped should open the bookmark
  • handleBookmarkTapped should load the bookmark in a new tab

You fixed one correctly, you just need to fix the other. 🙂

@czlucius
Copy link
Contributor Author

I've fixed the tests already.

About the new behaviour of opening in the current tab, since Fenix doesn't associate the home screen with a physical tab, I found out that this will cause a problem: If the user opens a new tab(clicks New Tab), then subsequently opens the bookmark, the bookmark would open in the previous tab, which may not be the intended action the user wanted to take. How should we fix this side effect? (is there a method to find out whether the user is on the home screen page of a new tab? - there could be other instances where the home screen is launched without the intention to open a new tab, e.g. the home button) Thanks.

What do we do about this?

handleBookmarkTapped should load the bookmark in a new tab

Should I also change the test name to reflect the new behavior?

Thank you.

@maverick74
Copy link

@jonalmeida @czlucius isn't there a way to, for example, know if the home button is visible?
If we could know, it could be used to either load the bookmark on a new tab or in the present tab...

@czlucius
Copy link
Contributor Author

czlucius commented Jan 26, 2022

@jonalmeida what do I do to continue from here?
Thanks.

@jonalmeida
Copy link
Contributor

Sorry, I lost track of the message thread!

I've fixed the tests already.

🎉

About the new behaviour of opening in the current tab, since Fenix doesn't associate the home screen with a physical tab, I found out that this will cause a problem: If the user opens a new tab(clicks New Tab), then subsequently opens the bookmark, the bookmark would open in the previous tab, which may not be the intended action the user wanted to take. How should we fix this side effect? (is there a method to find out whether the user is on the home screen page of a new tab? - there could be other instances where the home screen is launched without the intention to open a new tab, e.g. the home button) Thanks.

What do we do about this?

Interesting. There is no concept of a "new tab" in Fenix, it's just the home screen. When the bookmark is opened, does it switch to that tab that it loads in? If so, I think that would be acceptable behaviour for now given how Fenix currently works. We can also discuss this further with UX in a separate issue as well.

handleBookmarkTapped should load the bookmark in a new tab

Should I also change the test name to reflect the new behavior?

Yes please! The name of the test should reflect the behaviour of it. If we're changing the behaviour, someone else coming back to this code in the future will be very confused why it says something and does something else. 🙂

@czlucius
Copy link
Contributor Author

Ok 👍

@czlucius
Copy link
Contributor Author

Interesting. There is no concept of a "new tab" in Fenix, it's just the home screen. When the bookmark is opened, does it switch to that tab that it loads in? If so, I think that would be acceptable behaviour for now given how Fenix currently works. We can also discuss this further with UX in a separate issue as well.

Your comment got me to think about if the user has 0 tabs(starting from a clean state), then this behaviour will attempt to open the bookmark in a nonexistent current tab, which may result in a crash or no-op. I shall go test this behaviour later.

@czlucius
Copy link
Contributor Author

czlucius commented Jan 27, 2022

Interesting. There is no concept of a "new tab" in Fenix, it's just the home screen. When the bookmark is opened, does it switch to that tab that it loads in? If so, I think that would be acceptable behaviour for now given how Fenix currently works. We can also discuss this further with UX in a separate issue as well.

Your comment got me to think about if the user has 0 tabs(starting from a clean state), then this behaviour will attempt to open the bookmark in a nonexistent current tab, which may result in a crash or no-op. I shall go test this behaviour later.

Quite interestingly, the code still works well when I open a bookmark when number of tabs is 0. I guess openToBrowserAndLoad already has edge case that settled

@jonalmeida
Copy link
Contributor

Your comment got me to think about if the user has 0 tabs(starting from a clean state), then this behaviour will attempt to open the bookmark in a nonexistent current tab, which may result in a crash or no-op. I shall go test this behaviour later.

This is good train of thought to consider and even better that it is already handled by the openToBrowserAndLoad method.

@jonalmeida
Copy link
Contributor

jonalmeida commented Jan 27, 2022

@czlucius I tried out the patch and it looks good! However there is one more entry point into bookmarks from the home screen's "Recent bookmarks". I wonder if you're interested in also fixing that too? Otherwise, we can file a separate bug for it.

I'm also happy to land this as is, and if you're still interested in picking up the other issue as a follow-up. 🙂

@czlucius
Copy link
Contributor Author

I think the recent bookmarks from the home screen is somewhat related to this issue: #20012

If bookmarks were to open in the current tab, but top sites still open in a new tab, the behaviour will be quite confusing.

Furthermore, the home screen is also shown when the user explicitly clicks "New tab", and opening the recent bookmark in the current tab would not be the intended behaviour in this case.
Perhaps another issue can be filed about this, and I can look into it?

Thanks.

@czlucius
Copy link
Contributor Author

@jonalmeida
If the fix is good as it is now, you can merge it(and maybe open a new issue for the home screen one - maybe for top sites, bookmarks and also collections?)

The minor flaw that I described earlier is illustrated in this recording:

Screen_Recording_20220130-225842_Firefox.Preview.mp4

Thanks.

@czlucius czlucius marked this pull request as ready for review January 30, 2022 15:08
@czlucius czlucius requested review from a team as code owners January 30, 2022 15:08
@Cheap-Skate
Copy link

@jonalmeida If the fix is good as it is now, you can merge it(and maybe open a new issue for the home screen one - maybe for top sites, bookmarks and also collections?)

Please open this issue & Thanks for your efforts so far 👍!!

@jonalmeida jonalmeida added pr:needs-landing PRs that are ready to land [Will be merged by Mergify] and removed pr:needs-changes PRs that need some changes/fixes before they can land labels Feb 3, 2022
@gabrielluong gabrielluong added pr:needs-landing-squashed PRs that are ready to land (squashed) [Will be merged by Mergify] and removed pr:needs-landing PRs that are ready to land [Will be merged by Mergify] labels Feb 3, 2022
@czlucius
Copy link
Contributor Author

czlucius commented Feb 3, 2022

#2871 is related as well, and since this is fixed, that issue may be fixed too

@czlucius
Copy link
Contributor Author

czlucius commented Feb 7, 2022

@jonalmeida
The issue that I stated above is being reported by some users:
#23595

Is there a method that returns whether the home screen is opened? We could open in new or current tab based on this value.

Thanks!

@maverick74
Copy link

Created bug #23609 to address top sites behavior

@Cheap-Skate
Copy link

#23659 another one reporting the new behavior as a bug

@czlucius
Copy link
Contributor Author

@jonalmeida this seems to be causing problems, as seen in #23595, #23659, and #23746. I think this should be looked into(before this gets into release).

@maverick74
Copy link

@czlucius i think you missed bug #20012

@czlucius
Copy link
Contributor Author

No, I was talking about the problems caused by changing the behavior to open bookmarks in the current tab.

@maverick74
Copy link

Oh! My mistake then! Sorry.
But, i think 20012 should be addressed (after the ones you mentioned) as well to avoid more confusion with this change

rocketsroger added a commit that referenced this pull request Feb 22, 2022
mergify bot pushed a commit that referenced this pull request Feb 23, 2022
mergify bot pushed a commit that referenced this pull request Feb 23, 2022
This reverts commit e73deb2.

(cherry picked from commit d1c0e9b)
rocketsroger added a commit that referenced this pull request Feb 23, 2022
This reverts commit e73deb2.

(cherry picked from commit d1c0e9b)

Co-authored-by: Roger Yang <[email protected]>
pkirakosyan pushed a commit to gexsi/user-agent-android that referenced this pull request Mar 10, 2022
…le#23169)

* For mozilla-mobile#13336: Open bookmarks in current tab

* For mozilla-mobile#13336: Fix tests to verify bookmark opening in current tab

* Change test name for handleBookmarkTapped
pedroldk pushed a commit to pedroldk/fenix that referenced this pull request Mar 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
pr:needs-landing-squashed PRs that are ready to land (squashed) [Will be merged by Mergify]
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants