Skip to content

Commit

Permalink
Merge mozilla-central to autoland. a=merge CLOSED TREE
Browse files Browse the repository at this point in the history
  • Loading branch information
raulgurzau committed Feb 6, 2018
2 parents 0206b90 + 476c3b3 commit ba6075e
Show file tree
Hide file tree
Showing 321 changed files with 6,609 additions and 3,969 deletions.
4 changes: 4 additions & 0 deletions browser/app/blocklist.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1862,6 +1862,10 @@
<prefs/>
<versionRange minVersion="0" maxVersion="*" severity="3"/>
</emItem>
<emItem blockID="646e2384-f894-41bf-b7fc-8879e0095109" id="/^(https|youtube)@vietbacsecurity\.com$/">
<prefs/>
<versionRange minVersion="0" maxVersion="*" severity="3"/>
</emItem>
<emItem blockID="i521" id="/^({66b103a7-d772-4fcd-ace4-16f79a9056e0}|{6926c7f7-6006-42d1-b046-eba1b3010315}|{72cabc40-64b2-46ed-8648-26d831761150}|{73ee2cf2-7b76-4c49-b659-c3d8cf30825d}|{ca6446a5-73d5-4c35-8aa1-c71dc1024a18}|{5373a31d-9410-45e2-b299-4f61428f0be4})$/">
<prefs/>
<versionRange minVersion="0" maxVersion="*" severity="1"/>
Expand Down
4 changes: 4 additions & 0 deletions browser/app/profile/firefox.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,10 @@ pref("browser.urlbar.decodeURLsOnCopy", false);
// Tab" feature of the awesomebar.
pref("browser.urlbar.switchTabs.adoptIntoActiveWindow", false);

// Whether addresses and search results typed into the address bar
// should be opened in new tabs by default.
pref("browser.urlbar.openintab", false);

pref("browser.altClickSave", false);

// Enable logging downloads operations to the Console.
Expand Down
5 changes: 4 additions & 1 deletion browser/base/content/browser.xul
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,10 @@
nomaxresults="true" />

<!-- for search with one-off buttons -->
<panel type="autocomplete" id="PopupSearchAutoComplete" noautofocus="true" hidden="true"/>
<panel type="autocomplete-richlistbox"
id="PopupSearchAutoComplete"
noautofocus="true"
hidden="true" />

<!-- for url bar autocomplete -->
<panel type="autocomplete-richlistbox"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ add_task(async function() {
return URLBar.controller.searchStatus >=
Ci.nsIAutoCompleteController.STATUS_COMPLETE_NO_MATCH;
});
let matchCount = URLBar.popup._matchCount;
let matchCount = URLBar.popup.matchCount;
await BrowserTestUtils.waitForCondition(() => {
return URLBar.popup.richlistbox.childNodes.length == matchCount;
});
Expand Down
2 changes: 1 addition & 1 deletion browser/base/content/test/urlbar/Panel.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ this.Panel.prototype = {
let controller = this.p.mInput.controller;
for (let i = 0; i < this.p.maxResults; i++) {
let idx = this._currentIndex;
if (idx >= this.p._matchCount) {
if (idx >= this.p.matchCount) {
break;
}
let url = controller.getValueAt(idx);
Expand Down
1 change: 1 addition & 0 deletions browser/base/content/test/urlbar/browser.ini
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ support-files =
[browser_urlbarDecode.js]
[browser_urlbarDelete.js]
[browser_urlbarEnter.js]
[browser_urlbar_whereToOpen.js]
[browser_urlbarEnterAfterMouseOver.js]
skip-if = os == "linux" # Bug 1073339 - Investigate autocomplete test unreliability on Linux/e10s
[browser_urlbarFocusedCmdK.js]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ add_task(async function focus() {
Assert.ok(gURLBar.popup.popupOpen, "popup should be open");
assertVisible(true);
assertFooterVisible(false);
Assert.equal(gURLBar.popup._matchCount, 0, "popup should have no results");
Assert.equal(gURLBar.popup.matchCount, 0, "popup should have no results");

// Start searching.
EventUtils.synthesizeKey("r", {});
Expand Down Expand Up @@ -83,7 +83,7 @@ add_task(async function click_on_focused() {
Assert.ok(gURLBar.popup.popupOpen, "popup should be open");
assertVisible(true);
assertFooterVisible(false);
Assert.equal(gURLBar.popup._matchCount, 0, "popup should have no results");
Assert.equal(gURLBar.popup.matchCount, 0, "popup should have no results");
gURLBar.blur();
Assert.ok(!gURLBar.popup.popupOpen, "popup should be closed");
});
Expand Down
112 changes: 112 additions & 0 deletions browser/base/content/test/urlbar/browser_urlbar_whereToOpen.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

const NON_EMPTY_TAB = "example.com/non-empty";
const EMPTY_TAB = "about:blank";
const META_KEY = AppConstants.platform == "macosx" ? "metaKey" : "ctrlKey";
const ENTER = new KeyboardEvent("keydown", {});
const ALT_ENTER = new KeyboardEvent("keydown", {altKey: true});
const CLICK = new MouseEvent("click", {button: 0});
const META_CLICK = new MouseEvent("click", {button: 0, [META_KEY]: true});
const MIDDLE_CLICK = new MouseEvent("click", {button: 1});


let old_openintab = Preferences.get("browser.urlbar.openintab");
registerCleanupFunction(async function() {
Preferences.set("browser.urlbar.openintab", old_openintab);
});

add_task(async function openInTab() {
// Open a non-empty tab.
let tab = gBrowser.selectedTab = await BrowserTestUtils.openNewForegroundTab(gBrowser, NON_EMPTY_TAB);

for (let test of [{pref: false, event: ALT_ENTER,
desc: "Alt+Enter, non-empty tab, default prefs"},
{pref: false, event: META_CLICK,
desc: "Meta+click, non-empty tab, default prefs"},
{pref: false, event: MIDDLE_CLICK,
desc: "Middle click, non-empty tab, default prefs"},
{pref: true, event: ENTER,
desc: "Enter, non-empty tab, openInTab"},
{pref: true, event: CLICK,
desc: "Normal click, non-empty tab, openInTab"}]) {
info(test.desc);

Preferences.set("browser.urlbar.openintab", test.pref);
let where = gURLBar._whereToOpen(test.event);
is(where, "tab", "URL would be loaded in a new tab");
}

// Clean up.
await BrowserTestUtils.removeTab(tab);
});

add_task(async function keepEmptyTab() {
// Open an empty tab.
let tab = gBrowser.selectedTab = await BrowserTestUtils.openNewForegroundTab(gBrowser, EMPTY_TAB);

for (let test of [{pref: false, event: META_CLICK,
desc: "Meta+click, empty tab, default prefs"},
{pref: false, event: MIDDLE_CLICK,
desc: "Middle click, empty tab, default prefs"}]) {
info(test.desc);

Preferences.set("browser.urlbar.openintab", test.pref);
let where = gURLBar._whereToOpen(test.event);
is(where, "tab", "URL would be loaded in a new tab");
}

// Clean up.
await BrowserTestUtils.removeTab(tab);
});

add_task(async function reuseEmptyTab() {
// Open an empty tab.
let tab = gBrowser.selectedTab = await BrowserTestUtils.openNewForegroundTab(gBrowser, EMPTY_TAB);

for (let test of [{pref: false, event: ALT_ENTER,
desc: "Alt+Enter, empty tab, default prefs"},
{pref: true, event: ENTER,
desc: "Enter, empty tab, openInTab"},
{pref: true, event: CLICK,
desc: "Normal click, empty tab, openInTab"}]) {
info(test.desc);
Preferences.set("browser.urlbar.openintab", test.pref);
let where = gURLBar._whereToOpen(test.event);
is(where, "current", "New URL would reuse the current empty tab");
}

// Clean up.
await BrowserTestUtils.removeTab(tab);
});

add_task(async function openInCurrentTab() {
for (let test of [{pref: false, url: NON_EMPTY_TAB, event: ENTER,
desc: "Enter, non-empty tab, default prefs"},
{pref: false, url: NON_EMPTY_TAB, event: CLICK,
desc: "Normal click, non-empty tab, default prefs"},
{pref: false, url: EMPTY_TAB, event: ENTER,
desc: "Enter, empty tab, default prefs"},
{pref: false, url: EMPTY_TAB, event: CLICK,
desc: "Normal click, empty tab, default prefs"},
{pref: true, url: NON_EMPTY_TAB, event: ALT_ENTER,
desc: "Alt+Enter, non-empty tab, openInTab"},
{pref: true, url: NON_EMPTY_TAB, event: META_CLICK,
desc: "Meta+click, non-empty tab, openInTab"},
{pref: true, url: NON_EMPTY_TAB, event: MIDDLE_CLICK,
desc: "Middle click, non-empty tab, openInTab"}]) {
info(test.desc);

// Open a new tab.
let tab = gBrowser.selectedTab = await BrowserTestUtils.openNewForegroundTab(gBrowser, test.url);

Preferences.set("browser.urlbar.openintab", test.pref);
let where = gURLBar._whereToOpen(test.event);
is(where, "current", "URL would open in the current tab");

// Clean up.
await BrowserTestUtils.removeTab(tab);
}
});
57 changes: 38 additions & 19 deletions browser/base/content/urlbarBindings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
Services.prefs.addObserver("browser.search.suggest.enabled", this);
this.browserSearchSuggestEnabled = Services.prefs.getBoolPref("browser.search.suggest.enabled");

this.openInTab = this._prefs.getBoolPref("openintab");
this.clickSelectsAll = this._prefs.getBoolPref("clickSelectsAll");
this.doubleClickSelectsAll = this._prefs.getBoolPref("doubleClickSelectsAll");
this.completeDefaultIndex = this._prefs.getBoolPref("autoFill");
Expand Down Expand Up @@ -315,9 +316,9 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
return true;
}
let maxResultsRemaining =
this.popup.maxResults - this.popup._matchCount;
this.popup.maxResults - this.popup.matchCount;
let lastResultSelected =
this.popup.selectedIndex + 1 == this.popup._matchCount;
this.popup.selectedIndex + 1 == this.popup.matchCount;
return maxResultsRemaining > 0 && lastResultSelected;
]]></body>
</method>
Expand Down Expand Up @@ -518,6 +519,33 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
]]></body>
</method>

<method name="_whereToOpen">
<parameter name="event"/>
<body><![CDATA[
let isMouseEvent = event instanceof MouseEvent;
let reuseEmpty = !isMouseEvent;
let where = undefined;
if (isMouseEvent) {
where = whereToOpenLink(event, false, false);
} else {
let altEnter = event && event.altKey;
where = altEnter ? "tab" : "current";
}
if (this.openInTab) {
if (where == "current") {
where = "tab";
} else if (where == "tab") {
where = "current";
}
reuseEmpty = true;
}
if (where == "tab" && reuseEmpty && isTabEmpty(gBrowser.selectedTab)) {
where = "current";
}
return where;
]]></body>
</method>

<!--
This is ultimately called by the autocomplete controller as the result
of handleEnter when the Return key is pressed in the textbox. Since
Expand Down Expand Up @@ -566,19 +594,7 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
return;
}

let where = openUILinkWhere;
if (!where) {
if (isMouseEvent) {
where = whereToOpenLink(event, false, false);
} else {
// If the current tab is empty, ignore Alt+Enter (reuse this tab)
let altEnter = !isMouseEvent &&
event &&
event.altKey &&
!isTabEmpty(gBrowser.selectedTab);
where = altEnter ? "tab" : "current";
}
}
let where = openUILinkWhere || this._whereToOpen(event);

let url = this.value;
if (!url) {
Expand Down Expand Up @@ -1119,6 +1135,9 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
case "speculativeConnect.enabled":
this.speculativeConnectEnabled = this._prefs.getBoolPref(aData);
break;
case "openintab":
this.openInTab = this._prefs.getBoolPref(aData);
break;
case "browser.search.suggest.enabled":
this.browserSearchSuggestEnabled = Services.prefs.getBoolPref(aData);
break;
Expand Down Expand Up @@ -2017,8 +2036,8 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
this.classList.add("showSearchSuggestionsNotification");
// Don't show the one-off buttons if we are showing onboarding and
// there's no result, since it would be ugly and pointless.
this.footer.collapsed = this._matchCount == 0;
this.input.tabScrolling = this._matchCount != 0;
this.footer.collapsed = this.matchCount == 0;
this.input.tabScrolling = this.matchCount != 0;

// This event allows accessibility APIs to see the notification.
if (!this.popupOpen) {
Expand All @@ -2037,7 +2056,7 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
this.richlistbox.flex = 1;
this.removeAttribute("dontanimate");
this.searchSuggestionsNotification.removeAttribute("animate");
if (this._matchCount) {
if (this.matchCount) {
// Update popup height.
this._invalidate();
} else {
Expand Down Expand Up @@ -2072,7 +2091,7 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
<method name="handleKeyPress">
<parameter name="aEvent"/>
<body><![CDATA[
this.oneOffSearchButtons.handleKeyPress(aEvent, this._matchCount,
this.oneOffSearchButtons.handleKeyPress(aEvent, this.matchCount,
!this._isFirstResultHeuristic,
gBrowser.userTypedValue);
return aEvent.defaultPrevented && !aEvent.urlbarDeferred;
Expand Down
Loading

0 comments on commit ba6075e

Please sign in to comment.