Backed out 8 changesets (bug 1081542) for causing bc failures in browser_cancel_starting_autoscrolling_requested_by_background_tab.js CLOSED TREE

Backed out changeset 3cc96704d17f (bug 1081542)
Backed out changeset 9f3fe37b77ca (bug 1081542)
Backed out changeset 8d495120e6d2 (bug 1081542)
Backed out changeset ade6db42285d (bug 1081542)
Backed out changeset 56fb245cd38e (bug 1081542)
Backed out changeset c4530ae2b9e3 (bug 1081542)
Backed out changeset 758ad04a330e (bug 1081542)
Backed out changeset deb46de7b01c (bug 1081542)
This commit is contained in:
Cristian Tuns 2024-02-27 04:05:22 -05:00
parent 894d71085b
commit 4e97787e18
17 changed files with 174 additions and 364 deletions

View File

@ -900,6 +900,8 @@ pref("browser.tabs.warnOnClose", false);
pref("browser.tabs.warnOnCloseOtherTabs", true);
pref("browser.tabs.warnOnOpen", true);
pref("browser.tabs.maxOpenBeforeWarn", 15);
pref("browser.tabs.loadInBackground", true);
pref("browser.tabs.opentabfor.middleclick", true);
pref("browser.tabs.loadDivertedInBackground", false);
pref("browser.tabs.loadBookmarksInBackground", false);
pref("browser.tabs.loadBookmarksInTabs", false);

View File

@ -6061,7 +6061,7 @@ nsBrowserAccess.prototype = {
aName = "",
aCsp = null,
aSkipLoad = false,
aWhere = undefined
aForceLoadInBackground = false
) {
let win, needToFocusWin;
@ -6084,20 +6084,11 @@ nsBrowserAccess.prototype = {
return win.gBrowser.selectedBrowser;
}
// OPEN_NEWTAB_BACKGROUND and OPEN_NEWTAB_FOREGROUND are used by
// `window.open` with modifiers.
// The last case is OPEN_NEWTAB, which is used by:
// * a link with `target="_blank"`, without modifiers
// * `window.open` without features, without modifiers
let loadInBackground;
if (aWhere === Ci.nsIBrowserDOMWindow.OPEN_NEWTAB_BACKGROUND) {
let loadInBackground = Services.prefs.getBoolPref(
"browser.tabs.loadDivertedInBackground"
);
if (aForceLoadInBackground) {
loadInBackground = true;
} else if (aWhere === Ci.nsIBrowserDOMWindow.OPEN_NEWTAB_FOREGROUND) {
loadInBackground = false;
} else {
loadInBackground = Services.prefs.getBoolPref(
"browser.tabs.loadDivertedInBackground"
);
}
let tab = win.gBrowser.addTab(aURI ? aURI.spec : "about:blank", {
@ -6274,8 +6265,7 @@ nsBrowserAccess.prototype = {
}
break;
case Ci.nsIBrowserDOMWindow.OPEN_NEWTAB:
case Ci.nsIBrowserDOMWindow.OPEN_NEWTAB_BACKGROUND:
case Ci.nsIBrowserDOMWindow.OPEN_NEWTAB_FOREGROUND: {
case Ci.nsIBrowserDOMWindow.OPEN_NEWTAB_BACKGROUND: {
// If we have an opener, that means that the caller is expecting access
// to the nsIDOMWindow of the opened tab right away. For e10s windows,
// this means forcing the newly opened browser to be non-remote so that
@ -6286,6 +6276,8 @@ nsBrowserAccess.prototype = {
let userContextId = aOpenWindowInfo
? aOpenWindowInfo.originAttributes.userContextId
: openingUserContextId;
let forceLoadInBackground =
aWhere == Ci.nsIBrowserDOMWindow.OPEN_NEWTAB_BACKGROUND;
let browser = this._openURIInNewTab(
aURI,
referrerInfo,
@ -6299,7 +6291,7 @@ nsBrowserAccess.prototype = {
"",
aCsp,
aSkipLoad,
aWhere
forceLoadInBackground
);
if (browser) {
browsingContext = browser.browsingContext;
@ -6400,8 +6392,7 @@ nsBrowserAccess.prototype = {
if (
aWhere != Ci.nsIBrowserDOMWindow.OPEN_NEWTAB &&
aWhere != Ci.nsIBrowserDOMWindow.OPEN_NEWTAB_BACKGROUND &&
aWhere != Ci.nsIBrowserDOMWindow.OPEN_NEWTAB_FOREGROUND
aWhere != Ci.nsIBrowserDOMWindow.OPEN_NEWTAB_BACKGROUND
) {
dump("Error: openURIInFrame can only open in new tabs or print");
return null;
@ -6415,6 +6406,9 @@ nsBrowserAccess.prototype = {
? aParams.openerOriginAttributes.userContextId
: Ci.nsIScriptSecurityManager.DEFAULT_USER_CONTEXT_ID;
var forceLoadInBackground =
aWhere == Ci.nsIBrowserDOMWindow.OPEN_NEWTAB_BACKGROUND;
return this._openURIInNewTab(
aURI,
aParams.referrerInfo,
@ -6428,7 +6422,7 @@ nsBrowserAccess.prototype = {
aName,
aParams.csp,
aSkipLoad,
aWhere
forceLoadInBackground
);
},

View File

@ -11,7 +11,6 @@ add_task(async function () {
const tests = [
["OPEN_NEWTAB", false],
["OPEN_NEWTAB_BACKGROUND", true],
["OPEN_NEWTAB_FOREGROUND", false],
];
for (const [flag, isBackground] of tests) {

View File

@ -5,274 +5,171 @@
"use strict";
// Opening many windows take long time on some configuration.
requestLongerTimeout(6);
requestLongerTimeout(4);
const TEST_URL =
"https://example.com/browser/browser/base/content/test/tabs/file_window_open.html";
add_task(async function () {
await BrowserTestUtils.withNewTab(
"https://example.com/browser/browser/base/content/test/tabs/file_window_open.html",
async function (browser) {
const metaKey = AppConstants.platform == "macosx" ? "metaKey" : "ctrlKey";
const normalEvent = {};
const shiftEvent = { shiftKey: true };
const metaEvent = { [metaKey]: true };
const metaShiftEvent = { [metaKey]: true, shiftKey: true };
const metaKey = AppConstants.platform == "macosx" ? "metaKey" : "ctrlKey";
const tests = [
// type, id, options, result
["mouse", "#instant", normalEvent, "tab"],
["mouse", "#instant", shiftEvent, "window"],
["mouse", "#instant", metaEvent, "tab-bg"],
["mouse", "#instant", metaShiftEvent, "tab"],
const normalEvent = {};
const shiftEvent = { shiftKey: true };
const metaEvent = { [metaKey]: true };
const metaShiftEvent = { [metaKey]: true, shiftKey: true };
["mouse", "#instant-popup", normalEvent, "popup"],
["mouse", "#instant-popup", shiftEvent, "window"],
["mouse", "#instant-popup", metaEvent, "tab-bg"],
["mouse", "#instant-popup", metaShiftEvent, "tab"],
const altEvent = { altKey: true };
const altShiftEvent = { altKey: true, shiftKey: true };
const altMetaEvent = { altKey: true, [metaKey]: true };
const altMetaShiftEvent = { altKey: true, [metaKey]: true, shiftKey: true };
["mouse", "#delayed", normalEvent, "tab"],
["mouse", "#delayed", shiftEvent, "window"],
["mouse", "#delayed", metaEvent, "tab-bg"],
["mouse", "#delayed", metaShiftEvent, "tab"],
const middleEvent = { button: 1 };
const middleShiftEvent = { button: 1, shiftKey: true };
const middleMetaEvent = { button: 1, [metaKey]: true };
const middleMetaShiftEvent = { button: 1, [metaKey]: true, shiftKey: true };
["mouse", "#delayed-popup", normalEvent, "popup"],
["mouse", "#delayed-popup", shiftEvent, "window"],
["mouse", "#delayed-popup", metaEvent, "tab-bg"],
["mouse", "#delayed-popup", metaShiftEvent, "tab"],
add_task(async function testMouse() {
await BrowserTestUtils.withNewTab(TEST_URL, async function (browser) {
const tests = [
// type, id, options, result
["mouse", "#instant", normalEvent, "tab"],
["mouse", "#instant", shiftEvent, "window"],
["mouse", "#instant", metaEvent, "tab-bg"],
["mouse", "#instant", metaShiftEvent, "tab"],
// NOTE: meta+keyboard doesn't activate.
["mouse", "#instant-popup", normalEvent, "popup"],
["mouse", "#instant-popup", shiftEvent, "window"],
["mouse", "#instant-popup", metaEvent, "tab-bg"],
["mouse", "#instant-popup", metaShiftEvent, "tab"],
["VK_SPACE", "#instant", normalEvent, "tab"],
["VK_SPACE", "#instant", shiftEvent, "window"],
["mouse", "#delayed", normalEvent, "tab"],
["mouse", "#delayed", shiftEvent, "window"],
["mouse", "#delayed", metaEvent, "tab-bg"],
["mouse", "#delayed", metaShiftEvent, "tab"],
["VK_SPACE", "#instant-popup", normalEvent, "popup"],
["VK_SPACE", "#instant-popup", shiftEvent, "window"],
["mouse", "#delayed-popup", normalEvent, "popup"],
["mouse", "#delayed-popup", shiftEvent, "window"],
["mouse", "#delayed-popup", metaEvent, "tab-bg"],
["mouse", "#delayed-popup", metaShiftEvent, "tab"],
];
await runWindowOpenTests(browser, tests);
});
});
["VK_SPACE", "#delayed", normalEvent, "tab"],
["VK_SPACE", "#delayed", shiftEvent, "window"],
add_task(async function testAlt() {
// Alt key shouldn't affect the behavior.
await BrowserTestUtils.withNewTab(TEST_URL, async function (browser) {
const tests = [
["mouse", "#instant", altEvent, "tab"],
["mouse", "#instant", altShiftEvent, "window"],
["mouse", "#instant", altMetaEvent, "tab-bg"],
["mouse", "#instant", altMetaShiftEvent, "tab"],
["VK_SPACE", "#delayed-popup", normalEvent, "popup"],
["VK_SPACE", "#delayed-popup", shiftEvent, "window"],
["mouse", "#instant-popup", altEvent, "popup"],
["mouse", "#instant-popup", altShiftEvent, "window"],
["mouse", "#instant-popup", altMetaEvent, "tab-bg"],
["mouse", "#instant-popup", altMetaShiftEvent, "tab"],
["KEY_Enter", "#link-instant", normalEvent, "tab"],
["KEY_Enter", "#link-instant", shiftEvent, "window"],
["mouse", "#delayed", altEvent, "tab"],
["mouse", "#delayed", altShiftEvent, "window"],
["mouse", "#delayed", altMetaEvent, "tab-bg"],
["mouse", "#delayed", altMetaShiftEvent, "tab"],
["KEY_Enter", "#link-instant-popup", normalEvent, "popup"],
["KEY_Enter", "#link-instant-popup", shiftEvent, "window"],
["mouse", "#delayed-popup", altEvent, "popup"],
["mouse", "#delayed-popup", altShiftEvent, "window"],
["mouse", "#delayed-popup", altMetaEvent, "tab-bg"],
["mouse", "#delayed-popup", altMetaShiftEvent, "tab"],
];
await runWindowOpenTests(browser, tests);
});
});
["KEY_Enter", "#link-delayed", normalEvent, "tab"],
["KEY_Enter", "#link-delayed", shiftEvent, "window"],
add_task(async function testMiddleMouse() {
// Middle click is equivalent to meta key.
await BrowserTestUtils.withNewTab(TEST_URL, async function (browser) {
const tests = [
["mouse", "#instant", middleEvent, "tab-bg"],
["mouse", "#instant", middleShiftEvent, "tab"],
["mouse", "#instant", middleMetaEvent, "tab-bg"],
["mouse", "#instant", middleMetaShiftEvent, "tab"],
["KEY_Enter", "#link-delayed-popup", normalEvent, "popup"],
["KEY_Enter", "#link-delayed-popup", shiftEvent, "window"],
["mouse", "#instant-popup", middleEvent, "tab-bg"],
["mouse", "#instant-popup", middleShiftEvent, "tab"],
["mouse", "#instant-popup", middleMetaEvent, "tab-bg"],
["mouse", "#instant-popup", middleMetaShiftEvent, "tab"],
// Trigger user-defined shortcut key, where modifiers shouldn't affect.
["mouse", "#delayed", middleEvent, "tab-bg"],
["mouse", "#delayed", middleShiftEvent, "tab"],
["mouse", "#delayed", middleMetaEvent, "tab-bg"],
["mouse", "#delayed", middleMetaShiftEvent, "tab"],
["x", "#instant", normalEvent, "tab"],
["x", "#instant", shiftEvent, "tab"],
["x", "#instant", metaEvent, "tab"],
["x", "#instant", metaShiftEvent, "tab"],
["mouse", "#delayed-popup", middleEvent, "tab-bg"],
["mouse", "#delayed-popup", middleShiftEvent, "tab"],
["mouse", "#delayed-popup", middleMetaEvent, "tab-bg"],
["mouse", "#delayed-popup", middleMetaShiftEvent, "tab"],
];
await runWindowOpenTests(browser, tests);
});
});
["y", "#instant", normalEvent, "popup"],
["y", "#instant", shiftEvent, "popup"],
["y", "#instant", metaEvent, "popup"],
["y", "#instant", metaShiftEvent, "popup"],
];
for (const [type, id, event, result] of tests) {
const eventStr = JSON.stringify(event);
add_task(async function testBackgroundPrefTests() {
await SpecialPowers.pushPrefEnv({
set: [["browser.tabs.loadInBackground", false]],
});
let openPromise;
if (result == "tab" || result == "tab-bg") {
openPromise = BrowserTestUtils.waitForNewTab(
gBrowser,
"about:blank",
true
);
} else {
openPromise = BrowserTestUtils.waitForNewWindow({
url: "about:blank",
});
}
await BrowserTestUtils.withNewTab(TEST_URL, async function (browser) {
const tests = [
["mouse", "#instant", metaEvent, "tab"],
["mouse", "#instant", metaShiftEvent, "tab-bg"],
];
await runWindowOpenTests(browser, tests);
});
if (type == "mouse") {
BrowserTestUtils.synthesizeMouseAtCenter(id, { ...event }, browser);
} else {
// Make sure the keyboard activates a simple button on the page.
await ContentTask.spawn(browser, id, elementId => {
content.document.querySelector("#focus-result").value = "";
content.document.querySelector("#focus-check").focus();
});
BrowserTestUtils.synthesizeKey("VK_SPACE", {}, browser);
await ContentTask.spawn(browser, {}, async () => {
await ContentTaskUtils.waitForCondition(
() =>
content.document.querySelector("#focus-result").value === "ok"
);
});
await SpecialPowers.popPrefEnv();
});
// Once confirmed the keyboard event works, send the actual event
// that calls window.open.
await ContentTask.spawn(browser, id, elementId => {
content.document.querySelector(elementId).focus();
});
BrowserTestUtils.synthesizeKey(type, { ...event }, browser);
}
add_task(async function testSpaceKey() {
await BrowserTestUtils.withNewTab(TEST_URL, async function (browser) {
const tests = [
// NOTE: meta+keyboard doesn't activate.
const openedThing = await openPromise;
["VK_SPACE", "#instant", normalEvent, "tab"],
["VK_SPACE", "#instant", shiftEvent, "window"],
if (result == "tab" || result == "tab-bg") {
const newTab = openedThing;
["VK_SPACE", "#instant-popup", normalEvent, "popup"],
["VK_SPACE", "#instant-popup", shiftEvent, "window"],
if (result == "tab") {
Assert.equal(
gBrowser.selectedTab,
newTab,
`${id} with ${type} and ${eventStr} opened a foreground tab`
);
} else {
Assert.notEqual(
gBrowser.selectedTab,
newTab,
`${id} with ${type} and ${eventStr} opened a background tab`
);
}
["VK_SPACE", "#delayed", normalEvent, "tab"],
["VK_SPACE", "#delayed", shiftEvent, "window"],
gBrowser.removeTab(newTab);
} else {
const newWindow = openedThing;
["VK_SPACE", "#delayed-popup", normalEvent, "popup"],
["VK_SPACE", "#delayed-popup", shiftEvent, "window"],
];
await runWindowOpenTests(browser, tests);
});
});
const tabs = newWindow.document.getElementById("TabsToolbar");
if (result == "window") {
ok(
!tabs.collapsed,
`${id} with ${type} and ${eventStr} opened a regular window`
);
} else {
ok(
tabs.collapsed,
`${id} with ${type} and ${eventStr} opened a popup window`
);
}
add_task(async function testEnterKey() {
await BrowserTestUtils.withNewTab(TEST_URL, async function (browser) {
const tests = [
["KEY_Enter", "#link-instant", normalEvent, "tab"],
["KEY_Enter", "#link-instant", shiftEvent, "window"],
const closedPopupPromise = BrowserTestUtils.windowClosed(newWindow);
newWindow.close();
await closedPopupPromise;
["KEY_Enter", "#link-instant-popup", normalEvent, "popup"],
["KEY_Enter", "#link-instant-popup", shiftEvent, "window"],
["KEY_Enter", "#link-delayed", normalEvent, "tab"],
["KEY_Enter", "#link-delayed", shiftEvent, "window"],
["KEY_Enter", "#link-delayed-popup", normalEvent, "popup"],
["KEY_Enter", "#link-delayed-popup", shiftEvent, "window"],
];
await runWindowOpenTests(browser, tests);
});
});
add_task(async function testUserDefinedShortcut() {
await BrowserTestUtils.withNewTab(TEST_URL, async function (browser) {
const tests = [
// Trigger user-defined shortcut key, where modifiers shouldn't affect.
["x", "#instant", normalEvent, "tab"],
["x", "#instant", shiftEvent, "tab"],
["x", "#instant", metaEvent, "tab"],
["x", "#instant", metaShiftEvent, "tab"],
["y", "#instant", normalEvent, "popup"],
["y", "#instant", shiftEvent, "popup"],
["y", "#instant", metaEvent, "popup"],
["y", "#instant", metaShiftEvent, "popup"],
];
await runWindowOpenTests(browser, tests);
});
});
async function runWindowOpenTests(browser, tests) {
for (const [type, id, event, result] of tests) {
let eventStr = JSON.stringify(event);
let openPromise;
if (result == "tab" || result == "tab-bg") {
openPromise = BrowserTestUtils.waitForNewTab(
gBrowser,
"about:blank",
true
);
} else {
openPromise = BrowserTestUtils.waitForNewWindow({
url: "about:blank",
});
}
if (type == "mouse") {
BrowserTestUtils.synthesizeMouseAtCenter(id, { ...event }, browser);
} else {
// Make sure the keyboard activates a simple button on the page.
await ContentTask.spawn(browser, id, elementId => {
content.document.querySelector("#focus-result").value = "";
content.document.querySelector("#focus-check").focus();
});
BrowserTestUtils.synthesizeKey("VK_SPACE", {}, browser);
await ContentTask.spawn(browser, {}, async () => {
await ContentTaskUtils.waitForCondition(
() => content.document.querySelector("#focus-result").value === "ok"
);
});
// Once confirmed the keyboard event works, send the actual event
// that calls window.open.
await ContentTask.spawn(browser, id, elementId => {
content.document.querySelector(elementId).focus();
});
BrowserTestUtils.synthesizeKey(type, { ...event }, browser);
}
const openedThing = await openPromise;
if (result == "tab" || result == "tab-bg") {
const newTab = openedThing;
if (result == "tab") {
Assert.equal(
gBrowser.selectedTab,
newTab,
`${id} with ${type} and ${eventStr} opened a foreground tab`
);
} else {
Assert.notEqual(
gBrowser.selectedTab,
newTab,
`${id} with ${type} and ${eventStr} opened a background tab`
);
}
gBrowser.removeTab(newTab);
} else {
const newWindow = openedThing;
const tabs = newWindow.document.getElementById("TabsToolbar");
if (result == "window") {
ok(
!tabs.collapsed,
`${id} with ${type} and ${eventStr} opened a regular window`
);
} else {
ok(
tabs.collapsed,
`${id} with ${type} and ${eventStr} opened a popup window`
);
}
const closedPopupPromise = BrowserTestUtils.windowClosed(newWindow);
newWindow.close();
await closedPopupPromise;
// Make sure the focus comes back to this window before proceeding
// to the next test.
if (Services.focus.focusedWindow != window) {
const focusBack = BrowserTestUtils.waitForEvent(window, "focus", true);
window.focus();
await focusBack;
// Make sure the focus comes back to this window before proceeding
// to the next test.
if (Services.focus.focusedWindow != window) {
const focusBack = BrowserTestUtils.waitForEvent(
window,
"focus",
true
);
window.focus();
await focusBack;
}
}
}
}
}
}
);
});

View File

@ -11,23 +11,19 @@ div {
<body>
<div>
<input id="instant" type="button" value="instant no features"
onclick="window.open('about:blank', '_blank');"
onmousedown="if (event.button == 1) { window.open('about:blank', '_blank'); event.preventDefault(); }">
onclick="window.open('about:blank', '_blank');">
</div>
<div>
<input id="instant-popup" type="button" value="instant popup"
onclick="window.open('about:blank', '_blank', 'popup=true');"
onmousedown="if (event.button == 1) { window.open('about:blank', '_blank', 'popup=true'); }">
onclick="window.open('about:blank', '_blank', 'popup=true');">
</div>
<div>
<input id="delayed" type="button" value="delayed no features"
onclick="setTimeout(() => window.open('about:blank', '_blank'), 100);"
onmousedown="if (event.button == 1) { setTimeout(() => window.open('about:blank', '_blank'), 100); }">
onclick="setTimeout(() => window.open('about:blank', '_blank'), 100);">
</div>
<div>
<input id="delayed-popup" type="button" value="delayed popup"
onclick="setTimeout(() => window.open('about:blank', '_blank', 'popup=true'), 100);"
onmousedown="if (event.button == 1) { setTimeout(() => window.open('about:blank', '_blank', 'popup=true'), 100); }">
onclick="setTimeout(() => window.open('about:blank', '_blank', 'popup=true'), 100);">
<div>
<div>
<a id="link-instant" href=""

View File

@ -59,12 +59,8 @@ class UserActivation final : public nsISupports, public nsWrapperCache {
static constexpr uint8_t Meta = 0x20;
static constexpr uint8_t Control = 0x40;
static constexpr uint8_t Alt = 0x80;
static constexpr uint8_t MiddleMouse = 0x08;
static constexpr uint8_t Mask = 0xF8;
static_assert((uint8_t(State::EndGuard_) & ~Mask) ==
uint8_t(State::EndGuard_));
static constexpr uint8_t Mask = 0xF0;
constexpr Modifiers() = default;
explicit constexpr Modifiers(uint8_t aModifiers) : mModifiers(aModifiers) {}
@ -75,13 +71,11 @@ class UserActivation final : public nsISupports, public nsWrapperCache {
void SetMeta() { mModifiers |= Meta; }
void SetControl() { mModifiers |= Control; }
void SetAlt() { mModifiers |= Alt; }
void SetMiddleMouse() { mModifiers |= MiddleMouse; }
bool IsShift() const { return mModifiers & Shift; }
bool IsMeta() const { return mModifiers & Meta; }
bool IsControl() const { return mModifiers & Control; }
bool IsAlt() const { return mModifiers & Alt; }
bool IsMiddleMouse() const { return mModifiers & MiddleMouse; }
private:
uint8_t mModifiers = 0;

View File

@ -1131,13 +1131,6 @@ void EventStateManager::NotifyTargetUserActivation(WidgetEvent* aEvent,
if (inputEvent->IsAlt()) {
modifiers.SetAlt();
}
WidgetMouseEvent* mouseEvent = inputEvent->AsMouseEvent();
if (mouseEvent) {
if (mouseEvent->mButton == MouseButton::eMiddle) {
modifiers.SetMiddleMouse();
}
}
}
}
doc->NotifyUserGestureActivation(modifiers);

View File

@ -65,8 +65,6 @@ interface nsIBrowserDOMWindow : nsISupports
/**
* Open in a new content tab in the toplevel browser window corresponding to
* this nsIBrowserDOMWindow.
* Use browser.tabs.loadDivertedInBackground pref to choose whether to open
* in background tab or foreground tab.
*/
const short OPEN_NEWTAB = 3;
/**
@ -78,11 +76,6 @@ interface nsIBrowserDOMWindow : nsISupports
* corresponding to this nsIBrowserDOMWindow.
*/
const short OPEN_NEWTAB_BACKGROUND = 5;
/**
* Open in a new foreground content tab in the toplevel browser window
* corresponding to this nsIBrowserDOMWindow.
*/
const short OPEN_NEWTAB_FOREGROUND = 6;
/**
* Values for createContentWindow's and openURI's aFlags parameter.

View File

@ -5592,7 +5592,6 @@ mozilla::ipc::IPCResult ContentParent::CommonCreateWindow(
MOZ_ASSERT(aOpenLocation == nsIBrowserDOMWindow::OPEN_NEWTAB ||
aOpenLocation == nsIBrowserDOMWindow::OPEN_NEWTAB_BACKGROUND ||
aOpenLocation == nsIBrowserDOMWindow::OPEN_NEWTAB_FOREGROUND ||
aOpenLocation == nsIBrowserDOMWindow::OPEN_NEWWINDOW ||
aOpenLocation == nsIBrowserDOMWindow::OPEN_PRINT_BROWSER);
@ -5603,7 +5602,6 @@ mozilla::ipc::IPCResult ContentParent::CommonCreateWindow(
if (aOpenLocation == nsIBrowserDOMWindow::OPEN_NEWTAB ||
aOpenLocation == nsIBrowserDOMWindow::OPEN_NEWTAB_BACKGROUND ||
aOpenLocation == nsIBrowserDOMWindow::OPEN_NEWTAB_FOREGROUND ||
aOpenLocation == nsIBrowserDOMWindow::OPEN_PRINT_BROWSER) {
RefPtr<Element> openerElement = do_QueryObject(frame);
@ -5832,8 +5830,7 @@ mozilla::ipc::IPCResult ContentParent::RecvCreateWindow(
// do this work.
MOZ_ALWAYS_SUCCEEDS(newBC->SetHasSiblings(
openLocation == nsIBrowserDOMWindow::OPEN_NEWTAB ||
openLocation == nsIBrowserDOMWindow::OPEN_NEWTAB_BACKGROUND ||
openLocation == nsIBrowserDOMWindow::OPEN_NEWTAB_FOREGROUND));
openLocation == nsIBrowserDOMWindow::OPEN_NEWTAB_BACKGROUND));
newTab->SwapFrameScriptsFrom(cwi.frameScripts());
newTab->MaybeShowFrame();

View File

@ -652,7 +652,7 @@ public class GeckoSession {
case 0: // OPEN_DEFAULTWINDOW
case 1: // OPEN_CURRENTWINDOW
return NavigationDelegate.TARGET_WINDOW_CURRENT;
default: // OPEN_NEWWINDOW, OPEN_NEWTAB, OPEN_NEWTAB_BACKGROUND, OPEN_NEWTAB_FOREGROUND
default: // OPEN_NEWWINDOW, OPEN_NEWTAB, OPEN_NEWTAB_BACKGROUND
return NavigationDelegate.TARGET_WINDOW_NEW;
}
}
@ -5030,7 +5030,7 @@ public class GeckoSession {
case 0: // OPEN_DEFAULTWINDOW
case 1: // OPEN_CURRENTWINDOW
return TARGET_WINDOW_CURRENT;
default: // OPEN_NEWWINDOW, OPEN_NEWTAB, OPEN_NEWTAB_BACKGROUND, OPEN_NEWTAB_FOREGROUND
default: // OPEN_NEWWINDOW, OPEN_NEWTAB, OPEN_NEWTAB_BACKGROUND
return TARGET_WINDOW_NEW;
}
}

View File

@ -490,8 +490,7 @@ export class GeckoViewNavigation extends GeckoViewModule {
if (
where === Ci.nsIBrowserDOMWindow.OPEN_NEWWINDOW ||
where === Ci.nsIBrowserDOMWindow.OPEN_NEWTAB ||
where === Ci.nsIBrowserDOMWindow.OPEN_NEWTAB_BACKGROUND ||
where === Ci.nsIBrowserDOMWindow.OPEN_NEWTAB_FOREGROUND
where === Ci.nsIBrowserDOMWindow.OPEN_NEWTAB_BACKGROUND
) {
browser = this.handleNewSession(uri, openWindowInfo, where, flags, name);
}

View File

@ -1636,18 +1636,6 @@
value: false
mirror: always
# If set, when a link is opened to a new tab, do not switch to the new tab.
#
# This pref is used when the link is opened with "Open Link in New Tab",
# middle-click, etc.
#
# See also browser.tabs.loadDivertedInBackground, which is used when the website
# diverts the link into a new tab.
- name: browser.tabs.loadInBackground
type: bool
value: true
mirror: always
# Whether we should draw the tabs on top of the titlebar.
#
# no (0), yes (1), or default (2), which is true everywhere except Linux.
@ -1663,12 +1651,6 @@
value: false
mirror: always
# If set, middle clicking on a link opens the link in a new tab.
- name: browser.tabs.opentabfor.middleclick
type: bool
value: true
mirror: always
# Testing-only pref which makes data: URIs be loaded in a "web" content process
# instead of within a process based on the URI's loader.
- name: browser.tabs.remote.dataUriInDefaultWebProcess
@ -11135,21 +11117,6 @@
value: 262144
mirror: always
#---------------------------------------------------------------------------
# Prefs starting with "middlemouse."
#---------------------------------------------------------------------------
# If set and browser.tabs.opentabfor.middleclick is not set, middle clicking on
# a link opens the link in a new window.
- name: middlemouse.openNewWindow
type: bool
#if defined(ANDROID) || !defined(XP_MACOSX) && defined(XP_UNIX)
value: true
#else
value: false
#endif
mirror: always
#---------------------------------------------------------------------------
# Prefs starting with "midi."
#---------------------------------------------------------------------------

View File

@ -2655,6 +2655,7 @@ pref("font.size.monospace.x-math", 13);
// Middle-mouse handling
pref("middlemouse.paste", true);
pref("middlemouse.openNewWindow", true);
pref("middlemouse.scrollbarPosition", true);
// Tab focus model bit field:
@ -2685,6 +2686,7 @@ pref("font.size.monospace.x-math", 13);
// Middle-mouse handling
pref("middlemouse.paste", true);
pref("middlemouse.openNewWindow", true);
pref("middlemouse.scrollbarPosition", true);
// Tab focus model bit field:

View File

@ -62,7 +62,6 @@ pref_groups = [
"mathml",
"media",
"memory",
"middlemouse",
"midi",
"mousewheel",
"mozilla",

View File

@ -1657,9 +1657,8 @@ static int32_t GetWhereToOpen(nsIChannel* aChannel, bool aIsDocumentLoad) {
where == nsIBrowserDOMWindow::OPEN_NEWTAB) {
return where;
}
// NOTE: nsIBrowserDOMWindow::OPEN_NEWTAB_BACKGROUND and
// nsIBrowserDOMWindow::OPEN_NEWTAB_FOREGROUND are not allowed as pref
// values.
// NOTE: nsIBrowserDOMWindow::OPEN_NEWTAB_BACKGROUND is not allowed as a pref
// value.
return nsIBrowserDOMWindow::OPEN_NEWTAB;
}
@ -1752,7 +1751,6 @@ static RefPtr<dom::BrowsingContextCallbackReceivedPromise> SwitchToNewTab(
CanonicalBrowsingContext* aLoadingBrowsingContext, int32_t aWhere) {
MOZ_ASSERT(aWhere == nsIBrowserDOMWindow::OPEN_NEWTAB ||
aWhere == nsIBrowserDOMWindow::OPEN_NEWTAB_BACKGROUND ||
aWhere == nsIBrowserDOMWindow::OPEN_NEWTAB_FOREGROUND ||
aWhere == nsIBrowserDOMWindow::OPEN_NEWWINDOW,
"Unsupported open location");

View File

@ -64,7 +64,6 @@
#include "mozilla/Preferences.h"
#include "mozilla/ResultExtensions.h"
#include "mozilla/StaticPrefs_browser.h"
#include "mozilla/StaticPrefs_middlemouse.h"
#include "mozilla/StaticPrefs_full_screen_api.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/Storage.h"
@ -2443,44 +2442,26 @@ bool nsWindowWatcher::IsWindowOpenLocationModified(
const mozilla::dom::UserActivation::Modifiers& aModifiers,
int32_t* aLocation) {
// Perform the subset of BrowserUtils.whereToOpenLink in
// toolkit/modules/BrowserUtils.sys.mjs for modifier key handling, and
// URILoadingHelper.openLinkIn in browser/modules/URILoadingHelper.sys.mjs
// for loadInBackground pref handling.
// toolkit/modules/BrowserUtils.sys.mjs
#ifdef XP_MACOSX
bool metaKey = aModifiers.IsMeta();
#else
bool metaKey = aModifiers.IsControl();
#endif
bool shiftKey = aModifiers.IsShift();
bool middleMouse = aModifiers.IsMiddleMouse();
bool middleUsesTabs = StaticPrefs::browser_tabs_opentabfor_middleclick();
bool middleUsesNewWindow = StaticPrefs::middlemouse_openNewWindow();
if (metaKey || (middleMouse && middleUsesTabs)) {
bool loadInBackground = StaticPrefs::browser_tabs_loadInBackground();
if (metaKey) {
if (shiftKey) {
loadInBackground = !loadInBackground;
}
if (loadInBackground) {
*aLocation = nsIBrowserDOMWindow::OPEN_NEWTAB_BACKGROUND;
} else {
*aLocation = nsIBrowserDOMWindow::OPEN_NEWTAB_FOREGROUND;
*aLocation = nsIBrowserDOMWindow::OPEN_NEWTAB;
return true;
}
*aLocation = nsIBrowserDOMWindow::OPEN_NEWTAB_BACKGROUND;
return true;
}
if (shiftKey || (middleMouse && !middleUsesTabs && middleUsesNewWindow)) {
if (shiftKey) {
*aLocation = nsIBrowserDOMWindow::OPEN_NEWWINDOW;
return true;
}
// If both middleUsesTabs and middleUsesNewWindow are false, it means the
// middle-click is used for different purpose, such as paste or scroll.
// Webpage still can trigger `window.open` for the user activation, and in
// that case use the `window.open`'s `features` parameter and other prefs to
// decide where to open.
return false;
}

View File

@ -544,7 +544,6 @@ nsContentTreeOwner::ProvideWindow(
if (openLocation != nsIBrowserDOMWindow::OPEN_NEWTAB &&
openLocation != nsIBrowserDOMWindow::OPEN_NEWTAB_BACKGROUND &&
openLocation != nsIBrowserDOMWindow::OPEN_NEWTAB_FOREGROUND &&
openLocation != nsIBrowserDOMWindow::OPEN_CURRENTWINDOW &&
openLocation != nsIBrowserDOMWindow::OPEN_PRINT_BROWSER) {
// Just open a window normally