Skip to content

Commit

Permalink
Merge mozilla-central to mozilla-inbound
Browse files Browse the repository at this point in the history
  • Loading branch information
BavarianTomcat committed Jun 23, 2017
2 parents 2924991 + 5f51e55 commit 7af37a5
Show file tree
Hide file tree
Showing 367 changed files with 8,932 additions and 9,057 deletions.
5 changes: 5 additions & 0 deletions browser/app/profile/firefox.js
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,11 @@ pref("browser.tabs.drawInTitlebar", false);
pref("browser.tabs.drawInTitlebar", true);
#endif

// false - disable the tabbar session restore button
// true - enable the tabbar session restore button
// To be enabled with shield
pref("browser.tabs.restorebutton", false);

// When tabs opened by links in other tabs via a combination of
// browser.link.open_newwindow being set to 3 and target="_blank" etc are
// closed:
Expand Down
31 changes: 31 additions & 0 deletions browser/base/content/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -8168,16 +8168,47 @@ var RestoreLastSessionObserver = {
init() {
if (SessionStore.canRestoreLastSession &&
!PrivateBrowsingUtils.isWindowPrivate(window)) {
if (Services.prefs.getBoolPref("browser.tabs.restorebutton")) {
let {restoreTabsButton} = gBrowser.tabContainer;
let restoreTabsButtonWrapper = restoreTabsButton.parentNode;
restoreTabsButtonWrapper.setAttribute("session-exists", "true");
gBrowser.tabContainer.updateSessionRestoreVisibility();
gBrowser.tabContainer.addEventListener("TabOpen", this);
}
Services.obs.addObserver(this, "sessionstore-last-session-cleared", true);
goSetCommandEnabled("Browser:RestoreLastSession", true);
}
},

handleEvent(event) {
switch (event.type) {
case "TabOpen":
this.removeRestoreButton();
break;
}
},

removeRestoreButton() {
let {restoreTabsButton, restoreTabsButtonWrapperWidth} = gBrowser.tabContainer;
let restoreTabsButtonWrapper = restoreTabsButton.parentNode;
restoreTabsButtonWrapper.removeAttribute("session-exists");
gBrowser.tabContainer.addEventListener("transitionend", function maxWidthTransitionHandler(e) {
if (e.propertyName == "max-width") {
gBrowser.tabContainer.updateSessionRestoreVisibility();
gBrowser.tabContainer.removeEventListener("transitionend", maxWidthTransitionHandler);
}
});
restoreTabsButton.style.maxWidth = `${restoreTabsButtonWrapperWidth}px`;
requestAnimationFrame(() => restoreTabsButton.style.maxWidth = 0);
gBrowser.tabContainer.removeEventListener("TabOpen", this);
},

observe() {
// The last session can only be restored once so there's
// no way we need to re-enable our menu item.
Services.obs.removeObserver(this, "sessionstore-last-session-cleared");
goSetCommandEnabled("Browser:RestoreLastSession", false);
this.removeRestoreButton();
},

QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver,
Expand Down
61 changes: 61 additions & 0 deletions browser/base/content/tabbrowser.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5886,6 +5886,13 @@
onmouseover="document.getBindingParent(this)._enterNewTab();"
onmouseout="document.getBindingParent(this)._leaveNewTab();"
tooltip="dynamic-shortcut-tooltip"/>
<xul:hbox class="restore-tabs-button-wrapper"
anonid="restore-tabs-button-wrapper">
<xul:toolbarbutton anonid="restore-tabs-button"
class="restore-tabs-button"
onclick="SessionStore.restoreLastSession();"/>
</xul:hbox>

<xul:spacer class="closing-tabs-spacer" anonid="closing-tabs-spacer"
style="width: 0;"/>
</xul:arrowscrollbox>
Expand All @@ -5896,6 +5903,9 @@
<![CDATA[
this.mTabClipWidth = Services.prefs.getIntPref("browser.tabs.tabClipWidth");
let { restoreTabsButton } = this;
restoreTabsButton.setAttribute("label", this.tabbrowser.mStringBundle.getString("tabs.restoreLastTabs"));
var tab = this.firstChild;
tab.label = this.tabbrowser.mStringBundle.getString("tabs.emptyTabTitle");
tab.setAttribute("onerror", "this.removeAttribute('image');");
Expand Down Expand Up @@ -5938,6 +5948,56 @@
<field name="_beforeHoveredTab">null</field>
<field name="_afterHoveredTab">null</field>
<field name="_hoveredTab">null</field>
<field name="restoreTabsButton">
document.getAnonymousElementByAttribute(this, "anonid", "restore-tabs-button");
</field>
<field name="_restoreTabsButtonWrapperWidth">0</field>
<field name="windowUtils">
window.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
</field>

<property name="restoreTabsButtonWrapperWidth" readonly="true">
<getter>
if (!this._restoreTabsButtonWrapperWidth) {
this._restoreTabsButtonWrapperWidth = this.windowUtils
.getBoundsWithoutFlushing(this.restoreTabsButton.parentNode)
.width;
}
return this._restoreTabsButtonWrapperWidth;
</getter>
</property>

<method name="updateSessionRestoreVisibility">
<body><![CDATA[
let {restoreTabsButton, restoreTabsButtonWrapperWidth, windowUtils, mTabstripWidth} = this;
let restoreTabsButtonWrapper = restoreTabsButton.parentNode;
if (!restoreTabsButtonWrapper.getAttribute("session-exists")) {
restoreTabsButtonWrapper.removeAttribute("shown");
return;
}
let newTabButton = document.getAnonymousElementByAttribute(
this, "anonid", "tabs-newtab-button");
// If there are no pinned tabs it will multiply by 0 and result in 0
let pinnedTabsWidth = windowUtils.getBoundsWithoutFlushing(this.firstChild).width * this._lastNumPinned;
let numUnpinnedTabs = this.childNodes.length - this._lastNumPinned;
let unpinnedTabsWidth = windowUtils.getBoundsWithoutFlushing(this.lastChild).width * numUnpinnedTabs;
let tabbarUsedSpace = pinnedTabsWidth + unpinnedTabsWidth
+ windowUtils.getBoundsWithoutFlushing(newTabButton).width;
// Subtract the elements' widths from the available space to ensure
// that showing the restoreTabsButton won't cause any overflow.
if ((mTabstripWidth - tabbarUsedSpace) > restoreTabsButtonWrapperWidth) {
restoreTabsButtonWrapper.setAttribute("shown", "true");
} else {
restoreTabsButtonWrapper.removeAttribute("shown");
}
]]></body>
</method>

<method name="observe">
<parameter name="aSubject"/>
Expand Down Expand Up @@ -6468,6 +6528,7 @@
this.adjustTabstrip();
this._handleTabSelect(false);
this.mTabstripWidth = width;
this.updateSessionRestoreVisibility();
}
break;
case "mouseout":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ add_task(async function() {

// Now check that opening a link that does create a new tab works,
// and also that it nulls out the opener.
let pageLoadPromise = BrowserTestUtils.browserLoaded(appTab.linkedBrowser, "http://example.com/");
let pageLoadPromise = BrowserTestUtils.browserLoaded(appTab.linkedBrowser, false, "http://example.com/");
await BrowserTestUtils.loadURI(appTab.linkedBrowser, "http://example.com/");
info("Started loading example.com");
await pageLoadPromise;
Expand Down
6 changes: 3 additions & 3 deletions browser/base/content/test/urlbar/browser_bug304198.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ add_task(async function() {
partialURLTab = BrowserTestUtils.addTab(gBrowser);
testURL = "http://example.org/browser/browser/base/content/test/urlbar/dummy_page.html";

let loaded1 = BrowserTestUtils.browserLoaded(deletedURLTab.linkedBrowser, testURL);
let loaded2 = BrowserTestUtils.browserLoaded(fullURLTab.linkedBrowser, testURL);
let loaded3 = BrowserTestUtils.browserLoaded(partialURLTab.linkedBrowser, testURL);
let loaded1 = BrowserTestUtils.browserLoaded(deletedURLTab.linkedBrowser, false, testURL);
let loaded2 = BrowserTestUtils.browserLoaded(fullURLTab.linkedBrowser, false, testURL);
let loaded3 = BrowserTestUtils.browserLoaded(partialURLTab.linkedBrowser, false, testURL);
deletedURLTab.linkedBrowser.loadURI(testURL);
fullURLTab.linkedBrowser.loadURI(testURL);
partialURLTab.linkedBrowser.loadURI(testURL);
Expand Down
2 changes: 1 addition & 1 deletion browser/base/content/test/urlbar/browser_pasteAndGo.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ add_task(async function() {
await cxmenuPromise;
let menuitem = document.getAnonymousElementByAttribute(textBox,
"anonid", "paste-and-go");
let browserLoadedPromise = BrowserTestUtils.browserLoaded(browser, url.replace(/\n/g, ""));
let browserLoadedPromise = BrowserTestUtils.browserLoaded(browser, false, url.replace(/\n/g, ""));
EventUtils.synthesizeMouseAtCenter(menuitem, {});
// Using toSource in order to get the newlines escaped:
info("Paste and go, loading " + url.toSource());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ add_task(async function openKeywordBookmarkWithWindowOpen() {
let browser = tab.linkedBrowser;
if (!browser.currentURI || browser.currentURI.spec != TEST_URL) {
info("Waiting for browser load");
await BrowserTestUtils.browserLoaded(browser);
await BrowserTestUtils.browserLoaded(browser, false, TEST_URL);
}
is(browser.currentURI && browser.currentURI.spec, TEST_URL, "Tab with expected URL loaded.");
info("Waiting to remove tab");
Expand Down
77 changes: 37 additions & 40 deletions browser/components/preferences/in-content-new/privacy.xul
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,41 @@
<label class="header-name" flex="1">&panePrivacySecurity.title;</label>
</hbox>

<!-- Permissions -->
<groupbox id="permissionsGroup" data-category="panePrivacy" hidden="true">
<caption><label>&permissions.label;</label></caption>
<separator class="thin"/>
<hbox align="start">
<checkbox id="popupPolicy" preference="dom.disable_open_during_load"
label="&blockPopups.label;" accesskey="&blockPopups.accesskey;"
onsyncfrompreference="return gPrivacyPane.updateButtons('popupPolicyButton',
'dom.disable_open_during_load');"
flex="1" />
<button id="popupPolicyButton"
class="accessory-button"
label="&popupExceptions.label;"
accesskey="&popupExceptions.accesskey;"
searchkeywords="&address.label; &button.cancel.label; &button.ok.label;"/>
</hbox>
<hbox id="addonInstallBox">
<checkbox id="warnAddonInstall"
label="&warnOnAddonInstall.label;"
accesskey="&warnOnAddonInstall.accesskey;"
preference="xpinstall.whitelist.required"
onsyncfrompreference="return gPrivacyPane.readWarnAddonInstall();"
flex="1" />
<button id="addonExceptions"
class="accessory-button"
label="&addonExceptions.label;"
accesskey="&addonExceptions.accesskey;"
searchkeywords="&address.label;
&allow.label;
&removepermission.label;
&removeallpermissions.label;
&button.cancel.label;
&button.ok.label;"/>
</hbox>
</groupbox>

<!-- History -->
<groupbox id="historyGroup" data-category="panePrivacy" hidden="true">
Expand Down Expand Up @@ -431,23 +466,6 @@
</vbox>
</groupbox>

<!-- Pop-ups -->
<groupbox id="miscGroup" data-category="panePrivacy" hidden="true">
<caption><label>&popups.label;</label></caption>
<hbox align="start">
<checkbox id="popupPolicy" preference="dom.disable_open_during_load"
label="&blockPopups.label;" accesskey="&blockPopups.accesskey;"
onsyncfrompreference="return gPrivacyPane.updateButtons('popupPolicyButton',
'dom.disable_open_during_load');"
flex="1" />
<button id="popupPolicyButton"
class="accessory-button"
label="&popupExceptions.label;"
accesskey="&popupExceptions.accesskey;"
searchkeywords="&address.label; &button.cancel.label; &button.ok.label;"/>
</hbox>
</groupbox>

<!-- Notifications -->
<groupbox id="notificationsGroup" data-category="panePrivacy" hidden="true">
<caption><label>&notificationsPolicy.label;</label></caption>
Expand Down Expand Up @@ -504,30 +522,9 @@
</label>
</groupbox>

<!-- addons, forgery (phishing) UI Security -->
<groupbox id="addonsPhishingGroup" data-category="panePrivacy" hidden="true">
<!-- Forgery (phishing) UI Security -->
<groupbox id="phishingGroup" data-category="panePrivacy" hidden="true">
<caption><label>&security.label;</label></caption>

<hbox id="addonInstallBox">
<checkbox id="warnAddonInstall"
label="&warnOnAddonInstall.label;"
accesskey="&warnOnAddonInstall.accesskey;"
preference="xpinstall.whitelist.required"
onsyncfrompreference="return gPrivacyPane.readWarnAddonInstall();"
flex="1" />
<button id="addonExceptions"
class="accessory-button"
label="&addonExceptions.label;"
accesskey="&addonExceptions.accesskey;"
searchkeywords="&address.label;
&allow.label;
&removepermission.label;
&removeallpermissions.label;
&button.cancel.label;
&button.ok.label;"/>
</hbox>

<separator class="thin"/>
<checkbox id="enableSafeBrowsing"
label="&enableSafeBrowsing.label;"
accesskey="&enableSafeBrowsing.accesskey;" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ add_task(async function() {
*/
add_task(async function() {
await openPreferencesViaOpenPreferencesAPI("paneGeneral", {leaveOpen: true});
evaluateSearchResults("open pop-up windows", "miscGroup");
evaluateSearchResults("open pop-up windows", "permissionsGroup");
await BrowserTestUtils.removeTab(gBrowser.selectedTab);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ add_task(async function() {
*/
add_task(async function() {
await openPreferencesViaOpenPreferencesAPI("paneGeneral", {leaveOpen: true});
evaluateSearchResults("allowed to install add-ons", "addonsPhishingGroup");
evaluateSearchResults("allowed to install add-ons", "permissionsGroup");
await BrowserTestUtils.removeTab(gBrowser.selectedTab);
});

Expand Down
1 change: 0 additions & 1 deletion browser/components/uitour/jar.mn
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@

browser.jar:
content/browser/content-UITour.js
content/browser/UITour-lib.js
2 changes: 2 additions & 0 deletions browser/extensions/formautofill/FormAutofillContent.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ AutofillProfileAutoCompleteSearch.prototype = {
if (this.forceStop) {
return;
}
// Sort addresses by timeLastUsed for showing the lastest used address at top.
addresses.sort((a, b) => b.timeLastUsed - a.timeLastUsed);

let allFieldNames = FormAutofillContent.getAllFieldNames(focusedInput);
let result = new ProfileAutoCompleteResult(searchString,
Expand Down
45 changes: 28 additions & 17 deletions browser/extensions/formautofill/FormAutofillHandler.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -128,20 +128,19 @@ FormAutofillHandler.prototype = {
}
this.changeFieldState(fieldDetail, "AUTO_FILLED");
} else if (element instanceof Ci.nsIDOMHTMLSelectElement) {
for (let option of element.options) {
if (value === option.textContent || value === option.value) {
// Do not change value if the option is already selected.
// Use case for multiple select is not considered here.
if (option.selected) {
break;
}
option.selected = true;
element.dispatchEvent(new element.ownerGlobal.UIEvent("input", {bubbles: true}));
element.dispatchEvent(new element.ownerGlobal.Event("change", {bubbles: true}));
this.changeFieldState(fieldDetail, "AUTO_FILLED");
break;
}
let option = FormAutofillUtils.findSelectOption(element, profile, fieldDetail.fieldName);
if (!option) {
continue;
}
// Do not change value or dispatch events if the option is already selected.
// Use case for multiple select is not considered here.
if (!option.selected) {
option.selected = true;
element.dispatchEvent(new element.ownerGlobal.UIEvent("input", {bubbles: true}));
element.dispatchEvent(new element.ownerGlobal.Event("change", {bubbles: true}));
}
// Autofill highlight appears regardless if value is changed or not
this.changeFieldState(fieldDetail, "AUTO_FILLED");
}

// Unlike using setUserInput directly, FormFillController dispatches an
Expand Down Expand Up @@ -210,13 +209,25 @@ FormAutofillHandler.prototype = {
let element = fieldDetail.elementWeakRef.get();
let value = profile[fieldDetail.fieldName] || "";

// Skip the field that is null or already has text entered
if (!element || element.value) {
// Skip the field that is null
if (!element) {
continue;
}

element.previewValue = value;
this.changeFieldState(fieldDetail, value ? "PREVIEW" : "NORMAL");
if (element instanceof Ci.nsIDOMHTMLSelectElement) {
// Unlike text input, select element is always previewed even if
// the option is already selected.
let option = FormAutofillUtils.findSelectOption(element, profile, fieldDetail.fieldName);
element.previewValue = option ? option.text : "";
this.changeFieldState(fieldDetail, option ? "PREVIEW" : "NORMAL");
} else {
// Skip the field if it already has text entered
if (element.value) {
continue;
}
element.previewValue = value;
this.changeFieldState(fieldDetail, value ? "PREVIEW" : "NORMAL");
}
}
},

Expand Down
Loading

0 comments on commit 7af37a5

Please sign in to comment.