mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-18 15:55:36 +00:00
Bug 1339066 - Don't add a private tab opened while viewing the normal-mode tab strip. r=sebastian
MozReview-Commit-ID: AZEZq4boaJW --HG-- extra : rebase_source : de6fad976ce5227af441a0c6386e36658bfe83c8
This commit is contained in:
parent
806e31d5b2
commit
4f68f40cfe
@ -90,6 +90,10 @@ public class TabStripView extends RecyclerView {
|
||||
}
|
||||
|
||||
/* package */ void addTab(Tab tab, int position) {
|
||||
if (tab.isPrivate() != isPrivate) {
|
||||
return;
|
||||
}
|
||||
|
||||
adapter.addTab(tab, position);
|
||||
position = position == -1 ? adapter.getItemCount() - 1 : position;
|
||||
if (position == 0 || position == adapter.getItemCount() - 1) {
|
||||
|
@ -106,6 +106,7 @@ skip-if = android_version == "18"
|
||||
[src/org/mozilla/gecko/tests/testReaderModeTitle.java]
|
||||
[src/org/mozilla/gecko/tests/testSessionHistory.java]
|
||||
[src/org/mozilla/gecko/tests/testStateWhileLoading.java]
|
||||
[src/org/mozilla/gecko/tests/testTabStripPrivacyMode.java]
|
||||
[src/org/mozilla/gecko/tests/testUnifiedTelemetryClientId.java]
|
||||
|
||||
[src/org/mozilla/gecko/tests/testAccessibleCarets.java]
|
||||
|
@ -22,6 +22,11 @@ public class TabStripComponent extends BaseComponent {
|
||||
super(testContext);
|
||||
}
|
||||
|
||||
public TabStripComponent assertTabCount(int count) {
|
||||
fAssertEquals("The tab strip tab count is " + count, count, getTabStripView().getAdapter().getItemCount());
|
||||
return this;
|
||||
}
|
||||
|
||||
public void switchToTab(int index) {
|
||||
// The tab strip is only available on tablets
|
||||
DeviceHelper.assertIsTablet();
|
||||
|
@ -38,6 +38,19 @@ public class GeckoClickHelper {
|
||||
sSolo.clickOnText(StringHelper.get().CONTEXT_MENU_ITEMS_IN_NORMAL_TAB[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Long press the link and select "Open Link in New Private Tab" from the context menu.
|
||||
*
|
||||
* The link should be positioned at the top of the page, at least 60px high and
|
||||
* aligned to the middle.
|
||||
*/
|
||||
public static void openCentralizedLinkInNewPrivateTab() {
|
||||
openLinkContextMenu();
|
||||
|
||||
// Click on "Open Link in New Private Tab"
|
||||
sSolo.clickOnText(StringHelper.get().CONTEXT_MENU_ITEMS_IN_NORMAL_TAB[1]);
|
||||
}
|
||||
|
||||
private static void openLinkContextMenu() {
|
||||
DisplayMetrics dm = new DisplayMetrics();
|
||||
sActivity.getWindowManager().getDefaultDisplay().getMetrics(dm);
|
||||
|
@ -0,0 +1,42 @@
|
||||
package org.mozilla.gecko.tests;
|
||||
|
||||
import org.mozilla.gecko.Actions;
|
||||
import org.mozilla.gecko.tests.helpers.DeviceHelper;
|
||||
import org.mozilla.gecko.tests.helpers.GeckoClickHelper;
|
||||
import org.mozilla.gecko.tests.helpers.GeckoHelper;
|
||||
import org.mozilla.gecko.tests.helpers.NavigationHelper;
|
||||
import org.mozilla.gecko.tests.helpers.WaitHelper;
|
||||
|
||||
/**
|
||||
* Make sure that a private tab opened while the tab strip is in normal mode does not get added to
|
||||
* the tab strip (bug 1339066).
|
||||
*/
|
||||
public class testTabStripPrivacyMode extends UITest {
|
||||
public void testTabStripPrivacyMode() {
|
||||
if (!DeviceHelper.isTablet()) {
|
||||
return;
|
||||
}
|
||||
|
||||
GeckoHelper.blockForReady();
|
||||
|
||||
final String normalModeUrl = mStringHelper.ROBOCOP_BIG_LINK_URL;
|
||||
NavigationHelper.enterAndLoadUrl(normalModeUrl);
|
||||
|
||||
final Actions.EventExpecter titleExpecter = mActions.expectGlobalEvent(Actions.EventType.UI, "Content:DOMTitleChanged");
|
||||
GeckoClickHelper.openCentralizedLinkInNewPrivateTab();
|
||||
|
||||
titleExpecter.blockForEvent();
|
||||
titleExpecter.unregisterListener();
|
||||
// In the passing version of this test the UI shouldn't change at all in response to the
|
||||
// new private tab, but to prevent a false positive when the private tab does get added to
|
||||
// the tab strip in error, sleep here to make sure the UI has time to update before we
|
||||
// check it.
|
||||
mSolo.sleep(250);
|
||||
|
||||
// Now make sure there's still only one tab in the tab strip, and that it's still the normal
|
||||
// mode tab.
|
||||
|
||||
mTabStrip.assertTabCount(1);
|
||||
mToolbar.assertTitle(normalModeUrl);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user