mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
merge m-c to fx-team
This commit is contained in:
commit
64bc1c8f16
@ -38,10 +38,13 @@ let gDrag = {
|
||||
|
||||
// Mark nodes as being dragged.
|
||||
let selector = ".newtab-site, .newtab-control, .newtab-thumbnail";
|
||||
let nodes = aSite.node.parentNode.querySelectorAll(selector);
|
||||
let parentCell = aSite.node.parentNode;
|
||||
let nodes = parentCell.querySelectorAll(selector);
|
||||
for (let i = 0; i < nodes.length; i++)
|
||||
nodes[i].setAttribute("dragged", "true");
|
||||
|
||||
parentCell.setAttribute("dragged", "true");
|
||||
|
||||
this._setDragData(aSite, aEvent);
|
||||
|
||||
// Store the cursor offset.
|
||||
@ -88,7 +91,7 @@ let gDrag = {
|
||||
* @param aEvent The 'dragend' event.
|
||||
*/
|
||||
end: function Drag_end(aSite, aEvent) {
|
||||
let nodes = aSite.node.parentNode.querySelectorAll("[dragged]");
|
||||
let nodes = gGrid.node.querySelectorAll("[dragged]")
|
||||
for (let i = 0; i < nodes.length; i++)
|
||||
nodes[i].removeAttribute("dragged");
|
||||
|
||||
|
@ -153,6 +153,7 @@ _BROWSER_FILES = \
|
||||
browser_bug743421.js \
|
||||
browser_bug749738.js \
|
||||
browser_bug763468.js \
|
||||
browser_bug767836.js \
|
||||
browser_canonizeURL.js \
|
||||
browser_customize.js \
|
||||
browser_findbarClose.js \
|
||||
|
93
browser/base/content/test/browser_bug767836.js
Normal file
93
browser/base/content/test/browser_bug767836.js
Normal file
@ -0,0 +1,93 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// initialization
|
||||
const pb = Cc["@mozilla.org/privatebrowsing;1"].
|
||||
getService(Ci.nsIPrivateBrowsingService);
|
||||
const PREF = "browser.newtab.url";
|
||||
const NEWTABURL = Services.prefs.getCharPref(PREF) || "about:blank";
|
||||
const TESTURL = "http://example.com/";
|
||||
|
||||
function test() {
|
||||
|
||||
waitForExplicitFinish();
|
||||
// check whether the mode that we start off with is normal or not
|
||||
ok(!pb.privateBrowsingEnabled, "private browsing is disabled");
|
||||
// check whether any custom new tab url has been configured
|
||||
ok(!Services.prefs.prefHasUserValue(PREF), "No custom newtab url is set");
|
||||
|
||||
openNewTab(function () {
|
||||
// Check the new tab opened while in normal mode
|
||||
is(gBrowser.selectedBrowser.currentURI.spec, NEWTABURL,
|
||||
"URL of NewTab should be browser.newtab.url in Normal mode");
|
||||
// Set the custom newtab url
|
||||
Services.prefs.setCharPref(PREF, TESTURL);
|
||||
ok(Services.prefs.prefHasUserValue(PREF), "Custom newtab url is set");
|
||||
|
||||
// Open a newtab after setting the custom newtab url
|
||||
openNewTab(function () {
|
||||
is(gBrowser.selectedBrowser.currentURI.spec, TESTURL,
|
||||
"URL of NewTab should be the custom url");
|
||||
|
||||
// clear the custom url preference
|
||||
Services.prefs.clearUserPref(PREF);
|
||||
ok(!Services.prefs.prefHasUserValue(PREF), "No custom newtab url is set");
|
||||
|
||||
// enter private browsing mode
|
||||
togglePrivateBrowsing(function () {
|
||||
ok(pb.privateBrowsingEnabled, "private browsing is enabled");
|
||||
|
||||
// Open a new tab page in private browsing mode
|
||||
openNewTab(function () {
|
||||
// Check the new tab opened while in private browsing mode
|
||||
is(gBrowser.selectedBrowser.currentURI.spec, "about:privatebrowsing",
|
||||
"URL of NewTab should be about:privatebrowsing in PB mode");
|
||||
|
||||
Services.prefs.setCharPref(PREF, TESTURL);
|
||||
ok(Services.prefs.prefHasUserValue(PREF), "Custom newtab url is set");
|
||||
|
||||
// Open a newtab after setting the custom newtab url
|
||||
openNewTab(function () {
|
||||
is(gBrowser.selectedBrowser.currentURI.spec, TESTURL,
|
||||
"URL of NewTab should be the custom url");
|
||||
|
||||
Services.prefs.clearUserPref(PREF);
|
||||
ok(!Services.prefs.prefHasUserValue(PREF), "No custom newtab url is set");
|
||||
|
||||
// exit private browsing mode
|
||||
togglePrivateBrowsing(function () {
|
||||
ok(!pb.privateBrowsingEnabled, "private browsing is disabled");
|
||||
|
||||
gBrowser.removeTab(gBrowser.selectedTab);
|
||||
gBrowser.removeTab(gBrowser.selectedTab);
|
||||
finish();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function togglePrivateBrowsing(aCallback) {
|
||||
let topic = "private-browsing-transition-complete";
|
||||
|
||||
Services.obs.addObserver(function observe() {
|
||||
Services.obs.removeObserver(observe, topic);
|
||||
executeSoon(aCallback);
|
||||
}, topic, false);
|
||||
|
||||
pb.privateBrowsingEnabled = !pb.privateBrowsingEnabled;
|
||||
}
|
||||
|
||||
function openNewTab(aCallback) {
|
||||
// Open a new tab
|
||||
BrowserOpenTab();
|
||||
|
||||
let browser = gBrowser.selectedBrowser;
|
||||
browser.addEventListener("load", function onLoad() {
|
||||
browser.removeEventListener("load", onLoad, true);
|
||||
executeSoon(aCallback);
|
||||
}, true);
|
||||
}
|
@ -16,6 +16,7 @@ _BROWSER_FILES = \
|
||||
browser_newtab_disable.js \
|
||||
browser_newtab_drag_drop.js \
|
||||
browser_newtab_drop_preview.js \
|
||||
browser_newtab_focus.js \
|
||||
browser_newtab_private_browsing.js \
|
||||
browser_newtab_reset.js \
|
||||
browser_newtab_tabsync.js \
|
||||
|
54
browser/base/content/test/newtab/browser_newtab_focus.js
Normal file
54
browser/base/content/test/newtab/browser_newtab_focus.js
Normal file
@ -0,0 +1,54 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
/*
|
||||
* These tests make sure that focusing the 'New Tage Page' works as expected.
|
||||
*/
|
||||
function runTests() {
|
||||
// Focus count in new tab page.
|
||||
// 28 = 9 * 3 + 1 = 9 sites and 1 toggle button, each site has a link, a pin
|
||||
// and a remove button.
|
||||
let FOCUS_COUNT = 28;
|
||||
if ("nsILocalFileMac" in Ci) {
|
||||
// 19 = Mac doesn't focus links, so 9 focus targets less than Windows/Linux.
|
||||
FOCUS_COUNT = 19;
|
||||
}
|
||||
|
||||
// Create a new tab page.
|
||||
setLinks("0,1,2,3,4,5,6,7,8");
|
||||
setPinnedLinks("");
|
||||
yield addNewTabPageTab();
|
||||
gURLBar.focus();
|
||||
|
||||
// Count the focus with the enabled page.
|
||||
yield countFocus(FOCUS_COUNT);
|
||||
|
||||
// Disable page and count the focus with the disabled page.
|
||||
NewTabUtils.allPages.enabled = false;
|
||||
yield countFocus(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Focus the urlbar and count how many focus stops to return again to the urlbar.
|
||||
*/
|
||||
function countFocus(aExpectedCount) {
|
||||
let focusCount = 0;
|
||||
let contentDoc = getContentDocument();
|
||||
|
||||
window.addEventListener("focus", function onFocus() {
|
||||
let focusedElement = document.commandDispatcher.focusedElement;
|
||||
if (focusedElement && focusedElement.classList.contains("urlbar-input")) {
|
||||
window.removeEventListener("focus", onFocus, true);
|
||||
is(focusCount, aExpectedCount, "Validate focus count in the new tab page.");
|
||||
executeSoon(TestRunner.next);
|
||||
} else {
|
||||
if (focusedElement && focusedElement.ownerDocument == contentDoc &&
|
||||
focusedElement instanceof HTMLElement) {
|
||||
focusCount++;
|
||||
}
|
||||
document.commandDispatcher.advanceFocus();
|
||||
}
|
||||
}, true);
|
||||
|
||||
document.commandDispatcher.advanceFocus();
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
# -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
# -*- Mode: javascript; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
@ -12,7 +12,8 @@ XPCOMUtils.defineLazyGetter(this, "BROWSER_NEW_TAB_URL", function () {
|
||||
const TOPIC = "private-browsing-transition-complete";
|
||||
|
||||
function getNewTabPageURL() {
|
||||
if (("gPrivateBrowsingUI" in window)) {
|
||||
if (("gPrivateBrowsingUI" in window) &&
|
||||
!Services.prefs.prefHasUserValue(PREF)) {
|
||||
// gPrivateBrowsingUI may not be initialized yet, in that case we'll
|
||||
// update BROWSER_NEW_TAB_URL when it gets initialized.
|
||||
if (!gPrivateBrowsingUI.initialized)
|
||||
|
@ -2823,6 +2823,108 @@ let SessionStoreInternal = {
|
||||
this._sendRestoreCompletedNotifications();
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets the tabs restoring order with the following priority:
|
||||
* Selected tab, pinned tabs, visible tabs, unhidden tabs and hidden tabs.
|
||||
* @param aTabBrowser
|
||||
* Tab browser object
|
||||
* @param aTabs
|
||||
* Array of tab references
|
||||
* @param aTabData
|
||||
* Array of tab data
|
||||
* @param aSelectedTab
|
||||
* Index of selected tab
|
||||
*/
|
||||
_setTabsRestoringOrder : function ssi__setTabsRestoringOrder(
|
||||
aTabBrowser, aTabs, aTabData, aSelectedTab) {
|
||||
// Temporally store the pinned tabs before moving the hidden tabs and
|
||||
// optimizing the visible tabs. In case the selected tab is a pinned tab,
|
||||
// the index is also stored.
|
||||
let pinnedTabs = aTabData.filter(function (aData) aData.pinned).length;
|
||||
let pinnedTabsArray = [];
|
||||
let pinnedTabsDataArray = [];
|
||||
let pinnedSelectedTab = null;
|
||||
if (pinnedTabs && aTabs.length > 1) {
|
||||
for (let t = aTabs.length - 1; t >= 0; t--) {
|
||||
if (aTabData[t].pinned) {
|
||||
pinnedTabsArray.unshift(aTabs.splice(t, 1)[0]);
|
||||
pinnedTabsDataArray.unshift(aTabData.splice(t, 1)[0]);
|
||||
if (aSelectedTab) {
|
||||
if (aSelectedTab > (t + 1))
|
||||
--aSelectedTab;
|
||||
else if (aSelectedTab == (t + 1)) {
|
||||
aSelectedTab = null;
|
||||
pinnedSelectedTab = 1;
|
||||
}
|
||||
} else if (pinnedSelectedTab)
|
||||
++pinnedSelectedTab;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Without the pinned tabs, we move the hidden tabs to the end of the list
|
||||
// and optimize the visible tabs.
|
||||
let unhiddenTabs = aTabData.filter(function (aData) !aData.hidden).length;
|
||||
if (unhiddenTabs && aTabs.length > 1) {
|
||||
// Load hidden tabs last, by pushing them to the end of the list.
|
||||
for (let t = 0, tabsToReorder = aTabs.length - unhiddenTabs; tabsToReorder > 0; ) {
|
||||
if (aTabData[t].hidden) {
|
||||
aTabs = aTabs.concat(aTabs.splice(t, 1));
|
||||
aTabData = aTabData.concat(aTabData.splice(t, 1));
|
||||
if (aSelectedTab && aSelectedTab > t)
|
||||
--aSelectedTab;
|
||||
--tabsToReorder;
|
||||
continue;
|
||||
}
|
||||
++t;
|
||||
}
|
||||
|
||||
// Determine if we can optimize & load visible tabs first
|
||||
let maxVisibleTabs = Math.ceil(aTabBrowser.tabContainer.mTabstrip.scrollClientSize /
|
||||
aTabs[unhiddenTabs - 1].getBoundingClientRect().width);
|
||||
|
||||
// Make sure we restore visible tabs first, if there are enough
|
||||
if (aSelectedTab && maxVisibleTabs < unhiddenTabs && aSelectedTab > 1) {
|
||||
let firstVisibleTab = 0;
|
||||
if (unhiddenTabs - maxVisibleTabs > aSelectedTab) {
|
||||
// aSelectedTab is leftmost since we scroll to it when possible
|
||||
firstVisibleTab = aSelectedTab - 1;
|
||||
} else {
|
||||
// aSelectedTab is rightmost or no more room to scroll right
|
||||
firstVisibleTab = unhiddenTabs - maxVisibleTabs;
|
||||
}
|
||||
aTabs = aTabs.splice(firstVisibleTab, maxVisibleTabs).concat(aTabs);
|
||||
aTabData = aTabData.splice(firstVisibleTab, maxVisibleTabs).concat(aTabData);
|
||||
aSelectedTab -= firstVisibleTab;
|
||||
}
|
||||
}
|
||||
|
||||
// Load the pinned tabs at the beginning of the list and restore the
|
||||
// selected tab index.
|
||||
if (pinnedTabsArray) {
|
||||
// Restore the selected tab index.
|
||||
if (pinnedSelectedTab) {
|
||||
aSelectedTab = pinnedSelectedTab;
|
||||
} else {
|
||||
aSelectedTab += pinnedTabsArray.length;
|
||||
}
|
||||
// Load the pinned tabs at the beginning of the list.
|
||||
for (let t = pinnedTabsArray.length - 1; t >= 0; t--) {
|
||||
aTabs.unshift(pinnedTabsArray.splice(t, 1)[0]);
|
||||
aTabData.unshift(pinnedTabsDataArray.splice(t, 1)[0]);
|
||||
}
|
||||
}
|
||||
|
||||
// Load the selected tab to the first position.
|
||||
if (aSelectedTab-- && aTabs[aSelectedTab]) {
|
||||
aTabs.unshift(aTabs.splice(aSelectedTab, 1)[0]);
|
||||
aTabData.unshift(aTabData.splice(aSelectedTab, 1)[0]);
|
||||
aTabBrowser.selectedTab = aTabs[0];
|
||||
}
|
||||
|
||||
return [aTabs, aTabData];
|
||||
},
|
||||
|
||||
/**
|
||||
* Manage history restoration for a window
|
||||
* @param aWindow
|
||||
@ -2875,48 +2977,9 @@ let SessionStoreInternal = {
|
||||
return;
|
||||
}
|
||||
|
||||
let unhiddenTabs = aTabData.filter(function (aData) !aData.hidden).length;
|
||||
|
||||
if (unhiddenTabs && aTabs.length > 1) {
|
||||
// Load hidden tabs last, by pushing them to the end of the list
|
||||
for (let t = 0, tabsToReorder = aTabs.length - unhiddenTabs; tabsToReorder > 0; ) {
|
||||
if (aTabData[t].hidden) {
|
||||
aTabs = aTabs.concat(aTabs.splice(t, 1));
|
||||
aTabData = aTabData.concat(aTabData.splice(t, 1));
|
||||
if (aSelectTab > t)
|
||||
--aSelectTab;
|
||||
--tabsToReorder;
|
||||
continue;
|
||||
}
|
||||
++t;
|
||||
}
|
||||
|
||||
// Determine if we can optimize & load visible tabs first
|
||||
let maxVisibleTabs = Math.ceil(tabbrowser.tabContainer.mTabstrip.scrollClientSize /
|
||||
aTabs[unhiddenTabs - 1].getBoundingClientRect().width);
|
||||
|
||||
// make sure we restore visible tabs first, if there are enough
|
||||
if (maxVisibleTabs < unhiddenTabs && aSelectTab > 1) {
|
||||
let firstVisibleTab = 0;
|
||||
if (unhiddenTabs - maxVisibleTabs > aSelectTab) {
|
||||
// aSelectTab is leftmost since we scroll to it when possible
|
||||
firstVisibleTab = aSelectTab - 1;
|
||||
} else {
|
||||
// aSelectTab is rightmost or no more room to scroll right
|
||||
firstVisibleTab = unhiddenTabs - maxVisibleTabs;
|
||||
}
|
||||
aTabs = aTabs.splice(firstVisibleTab, maxVisibleTabs).concat(aTabs);
|
||||
aTabData = aTabData.splice(firstVisibleTab, maxVisibleTabs).concat(aTabData);
|
||||
aSelectTab -= firstVisibleTab;
|
||||
}
|
||||
}
|
||||
|
||||
// make sure to restore the selected tab first (if any)
|
||||
if (aSelectTab-- && aTabs[aSelectTab]) {
|
||||
aTabs.unshift(aTabs.splice(aSelectTab, 1)[0]);
|
||||
aTabData.unshift(aTabData.splice(aSelectTab, 1)[0]);
|
||||
tabbrowser.selectedTab = aTabs[0];
|
||||
}
|
||||
// Sets the tabs restoring order.
|
||||
[aTabs, aTabData] =
|
||||
this._setTabsRestoringOrder(tabbrowser, aTabs, aTabData, aSelectTab);
|
||||
|
||||
// Prepare the tabs so that they can be properly restored. We'll pin/unpin
|
||||
// and show/hide tabs as necessary. We'll also set the labels, user typed
|
||||
|
@ -8,15 +8,23 @@ function test() {
|
||||
requestLongerTimeout(3);
|
||||
|
||||
// builds the tests state based on a few parameters
|
||||
function buildTestState(num, selected, hidden) {
|
||||
let state = { windows: [ { "tabs": [], "selected": selected } ] };
|
||||
function buildTestState(num, selected, hidden, pinned) {
|
||||
let state = { windows: [ { "tabs": [], "selected": selected + 1 } ] };
|
||||
while (num--) {
|
||||
state.windows[0].tabs.push({entries: [{url: "http://example.com/"}]});
|
||||
state.windows[0].tabs.push({
|
||||
entries: [
|
||||
{ url: "http://example.com/?t=" + state.windows[0].tabs.length }
|
||||
]
|
||||
});
|
||||
let i = state.windows[0].tabs.length - 1;
|
||||
if (hidden.length > 0 && i == hidden[0]) {
|
||||
state.windows[0].tabs[i].hidden = true;
|
||||
hidden.splice(0, 1);
|
||||
}
|
||||
if (pinned.length > 0 && i == pinned[0]) {
|
||||
state.windows[0].tabs[i].pinned = true;
|
||||
pinned.splice(0, 1);
|
||||
}
|
||||
}
|
||||
return state;
|
||||
}
|
||||
@ -24,56 +32,128 @@ function test() {
|
||||
let tests = [
|
||||
{ testNum: 1,
|
||||
totalTabs: 13,
|
||||
selectedTab: 1,
|
||||
selectedTab: 0,
|
||||
shownTabs: 6,
|
||||
hiddenTabs: [],
|
||||
pinnedTabs: [],
|
||||
order: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
|
||||
},
|
||||
{ testNum: 2,
|
||||
totalTabs: 13,
|
||||
selectedTab: 13,
|
||||
selectedTab: 12,
|
||||
shownTabs: 6,
|
||||
hiddenTabs: [],
|
||||
pinnedTabs: [],
|
||||
order: [12, 7, 8, 9, 10, 11, 0, 1, 2, 3, 4, 5, 6]
|
||||
},
|
||||
{ testNum: 3,
|
||||
totalTabs: 13,
|
||||
selectedTab: 4,
|
||||
selectedTab: 3,
|
||||
shownTabs: 6,
|
||||
hiddenTabs: [],
|
||||
pinnedTabs: [],
|
||||
order: [3, 4, 5, 6, 7, 8, 0, 1, 2, 9, 10, 11, 12]
|
||||
},
|
||||
{ testNum: 4,
|
||||
totalTabs: 13,
|
||||
selectedTab: 11,
|
||||
selectedTab: 10,
|
||||
shownTabs: 6,
|
||||
hiddenTabs: [],
|
||||
pinnedTabs: [],
|
||||
order: [10, 7, 8, 9, 11, 12, 0, 1, 2, 3, 4, 5, 6]
|
||||
},
|
||||
{ testNum: 5,
|
||||
totalTabs: 13,
|
||||
selectedTab: 13,
|
||||
selectedTab: 12,
|
||||
shownTabs: 6,
|
||||
hiddenTabs: [0, 4, 9],
|
||||
pinnedTabs: [],
|
||||
order: [12, 6, 7, 8, 10, 11, 1, 2, 3, 5, 0, 4, 9]
|
||||
},
|
||||
{ testNum: 6,
|
||||
totalTabs: 13,
|
||||
selectedTab: 4,
|
||||
selectedTab: 3,
|
||||
shownTabs: 6,
|
||||
hiddenTabs: [1, 7, 12],
|
||||
pinnedTabs: [],
|
||||
order: [3, 4, 5, 6, 8, 9, 0, 2, 10, 11, 1, 7, 12]
|
||||
},
|
||||
{ testNum: 7,
|
||||
totalTabs: 13,
|
||||
selectedTab: 4,
|
||||
selectedTab: 3,
|
||||
shownTabs: 6,
|
||||
hiddenTabs: [0, 1, 2],
|
||||
pinnedTabs: [],
|
||||
order: [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 0, 1, 2]
|
||||
},
|
||||
{ testNum: 8,
|
||||
totalTabs: 13,
|
||||
selectedTab: 0,
|
||||
shownTabs: 6,
|
||||
hiddenTabs: [],
|
||||
pinnedTabs: [0],
|
||||
order: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
|
||||
},
|
||||
{ testNum: 9,
|
||||
totalTabs: 13,
|
||||
selectedTab: 1,
|
||||
shownTabs: 6,
|
||||
hiddenTabs: [],
|
||||
pinnedTabs: [0],
|
||||
order: [1, 0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
|
||||
},
|
||||
{ testNum: 10,
|
||||
totalTabs: 13,
|
||||
selectedTab: 3,
|
||||
shownTabs: 6,
|
||||
hiddenTabs: [2],
|
||||
pinnedTabs: [0,1],
|
||||
order: [3, 0, 1, 4, 5, 6, 7, 8, 9, 10, 11, 12, 2]
|
||||
},
|
||||
{ testNum: 11,
|
||||
totalTabs: 13,
|
||||
selectedTab: 12,
|
||||
shownTabs: 6,
|
||||
hiddenTabs: [],
|
||||
pinnedTabs: [0,1,2],
|
||||
order: [12, 0, 1, 2, 7, 8, 9, 10, 11, 3, 4, 5, 6]
|
||||
},
|
||||
{ testNum: 12,
|
||||
totalTabs: 13,
|
||||
selectedTab: 6,
|
||||
shownTabs: 6,
|
||||
hiddenTabs: [3,4,5],
|
||||
pinnedTabs: [0,1,2],
|
||||
order: [6, 0, 1, 2, 7, 8, 9, 10, 11, 12, 3, 4, 5]
|
||||
},
|
||||
{ testNum: 13,
|
||||
totalTabs: 13,
|
||||
selectedTab: 1,
|
||||
shownTabs: 6,
|
||||
hiddenTabs: [3,4,5],
|
||||
pinnedTabs: [0,1,2],
|
||||
order: [1, 0, 2, 6, 7, 8, 9, 10, 11, 12, 3, 4, 5]
|
||||
},
|
||||
{ testNum: 14,
|
||||
totalTabs: 13,
|
||||
selectedTab: 2,
|
||||
shownTabs: 6,
|
||||
hiddenTabs: [],
|
||||
pinnedTabs: [0,1,2],
|
||||
order: [2, 0, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
|
||||
},
|
||||
{ testNum: 15,
|
||||
totalTabs: 13,
|
||||
selectedTab: 3,
|
||||
shownTabs: 6,
|
||||
hiddenTabs: [1,4],
|
||||
pinnedTabs: [0,1,2],
|
||||
order: [3, 0, 1, 2, 5, 6, 7, 8, 9, 10, 11, 12, 4]
|
||||
}
|
||||
];
|
||||
|
||||
let tabMinWidth = parseInt(getComputedStyle(gBrowser.selectedTab, null).minWidth);
|
||||
let tabMinWidth =
|
||||
parseInt(getComputedStyle(gBrowser.selectedTab, null).minWidth);
|
||||
let testIndex = 0;
|
||||
|
||||
function runNextTest() {
|
||||
@ -84,41 +164,46 @@ function test() {
|
||||
|
||||
info ("Starting test " + (++testIndex));
|
||||
let test = tests.shift();
|
||||
let state = buildTestState(test.totalTabs, test.selectedTab, test.hiddenTabs);
|
||||
let state = buildTestState(test.totalTabs, test.selectedTab,
|
||||
test.hiddenTabs, test.pinnedTabs);
|
||||
let tabbarWidth = Math.floor((test.shownTabs - 0.5) * tabMinWidth);
|
||||
let win = openDialog(location, "_blank", "chrome,all,dialog=no");
|
||||
let actualOrder = [];
|
||||
let tabsRestored = [];
|
||||
|
||||
win.addEventListener("SSTabRestoring", function onSSTabRestoring(aEvent) {
|
||||
let tab = aEvent.originalTarget;
|
||||
let currentIndex = Array.indexOf(win.gBrowser.tabs, tab);
|
||||
actualOrder.push(currentIndex);
|
||||
let tabLink = tab.linkedBrowser.currentURI.spec;
|
||||
let tabIndex =
|
||||
tabLink.substring(tabLink.indexOf("?t=") + 3, tabLink.length);
|
||||
|
||||
if (actualOrder.length < state.windows[0].tabs.length)
|
||||
// we need to compare with the tab's restoring index, no with the
|
||||
// position index, since the pinned tabs change the positions in the
|
||||
// tabbar.
|
||||
tabsRestored.push(tabIndex);
|
||||
|
||||
if (tabsRestored.length < state.windows[0].tabs.length)
|
||||
return;
|
||||
|
||||
// all of the tabs should be restoring or restored by now
|
||||
is(actualOrder.length, state.windows[0].tabs.length,
|
||||
is(tabsRestored.length, state.windows[0].tabs.length,
|
||||
"Test #" + testIndex + ": Number of restored tabs is as expected");
|
||||
|
||||
is(actualOrder.join(" "), test.order.join(" "),
|
||||
is(tabsRestored.join(" "), test.order.join(" "),
|
||||
"Test #" + testIndex + ": 'visible' tabs restored first");
|
||||
|
||||
// Cleanup.
|
||||
// cleanup
|
||||
win.removeEventListener("SSTabRestoring", onSSTabRestoring, false);
|
||||
win.close();
|
||||
executeSoon(runNextTest);
|
||||
}, false);
|
||||
|
||||
win.addEventListener("load", function onLoad(aEvent) {
|
||||
win.removeEventListener("load", onLoad, false);
|
||||
executeSoon(function () {
|
||||
let extent = win.outerWidth - win.gBrowser.tabContainer.mTabstrip.scrollClientSize;
|
||||
let windowWidth = tabbarWidth + extent;
|
||||
win.resizeTo(windowWidth, win.outerHeight);
|
||||
ss.setWindowState(win, JSON.stringify(state), true);
|
||||
});
|
||||
}, false);
|
||||
whenWindowLoaded(win, function(aEvent) {
|
||||
let extent =
|
||||
win.outerWidth - win.gBrowser.tabContainer.mTabstrip.scrollClientSize;
|
||||
let windowWidth = tabbarWidth + extent;
|
||||
win.resizeTo(windowWidth, win.outerHeight);
|
||||
ss.setWindowState(win, JSON.stringify(state), true);
|
||||
});
|
||||
};
|
||||
|
||||
runNextTest();
|
||||
|
@ -56,7 +56,7 @@
|
||||
-moz-margin-end: 0;
|
||||
}
|
||||
|
||||
.newtab-cell:hover:not(:empty) {
|
||||
.newtab-cell:hover:not(:empty):not([dragged]) {
|
||||
border-color: rgba(8,22,37,.25) rgba(8,22,37,.27) rgba(8,22,37,.3);
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@
|
||||
-moz-margin-end: 0;
|
||||
}
|
||||
|
||||
.newtab-cell:hover:not(:empty) {
|
||||
.newtab-cell:hover:not(:empty):not([dragged]) {
|
||||
border-color: rgba(8,22,37,.25) rgba(8,22,37,.27) rgba(8,22,37,.3);
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@
|
||||
-moz-margin-end: 0;
|
||||
}
|
||||
|
||||
.newtab-cell:hover:not(:empty) {
|
||||
.newtab-cell:hover:not(:empty):not([dragged]) {
|
||||
border-color: rgba(8,22,37,.25) rgba(8,22,37,.27) rgba(8,22,37,.3);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user