Merge mozilla-central to inbound. a=merge CLOSED TREE

This commit is contained in:
Margareta Eliza Balazs 2018-08-27 12:45:16 +03:00
Родитель bd06f8da9f 4623c0701b
Коммит 097bf8b179
5 изменённых файлов: 32 добавлений и 76 удалений

Просмотреть файл

@ -341,7 +341,7 @@
<menuseparator id="sanitizeSeparator"/> <menuseparator id="sanitizeSeparator"/>
<menuitem id="sync-tabs-menuitem" <menuitem id="sync-tabs-menuitem"
label="&syncTabsMenu3.label;" label="&syncTabsMenu3.label;"
oncommand="BrowserOpenSyncTabs();" oncommand="gSync.openSyncedTabsPanel();"
hidden="true"/> hidden="true"/>
<menuitem id="historyRestoreLastSession" <menuitem id="historyRestoreLastSession"
label="&historyRestoreLastSession.label;" label="&historyRestoreLastSession.label;"

Просмотреть файл

@ -7299,10 +7299,6 @@ function checkEmptyPageOrigin(browser = gBrowser.selectedBrowser,
return ssm.isSystemPrincipal(contentPrincipal); return ssm.isSystemPrincipal(contentPrincipal);
} }
function BrowserOpenSyncTabs() {
gSync.openSyncedTabsPanel();
}
function ReportFalseDeceptiveSite() { function ReportFalseDeceptiveSite() {
let docURI = gBrowser.selectedBrowser.documentURI; let docURI = gBrowser.selectedBrowser.documentURI;
let isPhishingPage = let isPhishingPage =

Просмотреть файл

@ -5,7 +5,7 @@
"use strict"; "use strict";
/** /**
* Test the HTMLTooltip autofocus configuration option. * This is the sanity test for the HTMLTooltip focus
*/ */
const HTML_NS = "http://www.w3.org/1999/xhtml"; const HTML_NS = "http://www.w3.org/1999/xhtml";
@ -30,17 +30,11 @@ add_task(async function() {
}); });
async function runTests(doc) { async function runTests(doc) {
await testNoAutoFocus(doc);
await testAutoFocus(doc);
await testAutoFocusPreservesFocusChange(doc);
}
async function testNoAutoFocus(doc) {
await focusNode(doc, "#box4-input"); await focusNode(doc, "#box4-input");
ok(doc.activeElement.closest("#box4-input"), "Focus is in the #box4-input"); ok(doc.activeElement.closest("#box4-input"), "Focus is in the #box4-input");
info("Test a tooltip without autofocus will not take focus"); info("Test a tooltip will not take focus");
const tooltip = await createTooltip(doc, false); const tooltip = await createTooltip(doc);
await showTooltip(tooltip, doc.getElementById("box1")); await showTooltip(tooltip, doc.getElementById("box1"));
ok(doc.activeElement.closest("#box4-input"), "Focus is still in the #box4-input"); ok(doc.activeElement.closest("#box4-input"), "Focus is still in the #box4-input");
@ -51,50 +45,6 @@ async function testNoAutoFocus(doc) {
tooltip.destroy(); tooltip.destroy();
} }
async function testAutoFocus(doc) {
await focusNode(doc, "#box4-input");
ok(doc.activeElement.closest("#box4-input"), "Focus is in the #box4-input");
info("Test autofocus tooltip takes focus when displayed, " +
"and restores the focus when hidden");
const tooltip = await createTooltip(doc, true);
await showTooltip(tooltip, doc.getElementById("box1"));
ok(doc.activeElement.closest(".tooltip-content"), "Focus is in the tooltip");
await hideTooltip(tooltip);
ok(doc.activeElement.closest("#box4-input"), "Focus is in the #box4-input");
info("Blur the textbox before moving to the next test to reset the state.");
await blurNode(doc, "#box4-input");
tooltip.destroy();
}
async function testAutoFocusPreservesFocusChange(doc) {
await focusNode(doc, "#box4-input");
ok(doc.activeElement.closest("#box4-input"), "Focus is still in the #box3-input");
info("Test autofocus tooltip takes focus when displayed, " +
"but does not try to restore the active element if it is not focused when hidden");
const tooltip = await createTooltip(doc, true);
await showTooltip(tooltip, doc.getElementById("box1"));
ok(doc.activeElement.closest(".tooltip-content"), "Focus is in the tooltip");
info("Move the focus to #box3-input while the tooltip is displayed");
await focusNode(doc, "#box3-input");
ok(doc.activeElement.closest("#box3-input"), "Focus moved to the #box3-input");
await hideTooltip(tooltip);
ok(doc.activeElement.closest("#box3-input"), "Focus is still in the #box3-input");
info("Blur the textbox before moving to the next test to reset the state.");
await blurNode(doc, "#box3-input");
tooltip.destroy();
}
/** /**
* Fpcus the node corresponding to the provided selector in the provided document. Returns * Fpcus the node corresponding to the provided selector in the provided document. Returns
* a promise that will resolve when receiving the focus event on the node. * a promise that will resolve when receiving the focus event on the node.
@ -118,16 +68,15 @@ function blurNode(doc, selector) {
} }
/** /**
* Create an HTMLTooltip instance with the provided autofocus setting. * Create an HTMLTooltip instance.
* *
* @param {Document} doc * @param {Document} doc
* Document in which the tooltip should be created * Document in which the tooltip should be created
* @param {Boolean} autofocus
* @return {Promise} promise that will resolve the HTMLTooltip instance created when the * @return {Promise} promise that will resolve the HTMLTooltip instance created when the
* tooltip content will be ready. * tooltip content will be ready.
*/ */
function createTooltip(doc, autofocus) { function createTooltip(doc) {
const tooltip = new HTMLTooltip(doc, {autofocus, useXulWrapper}); const tooltip = new HTMLTooltip(doc, {useXulWrapper});
const div = doc.createElementNS(HTML_NS, "div"); const div = doc.createElementNS(HTML_NS, "div");
div.classList.add("tooltip-content"); div.classList.add("tooltip-content");
div.style.height = "50px"; div.style.height = "50px";

Просмотреть файл

@ -294,8 +294,6 @@ const getRelativeRect = function(node, relativeTo) {
* - {String} type * - {String} type
* Display type of the tooltip. Possible values: "normal", "arrow", and * Display type of the tooltip. Possible values: "normal", "arrow", and
* "doorhanger". * "doorhanger".
* - {Boolean} autofocus
* Defaults to false. Should the tooltip be focused when opening it.
* - {Boolean} consumeOutsideClicks * - {Boolean} consumeOutsideClicks
* Defaults to true. The tooltip is closed when clicking outside. * Defaults to true. The tooltip is closed when clicking outside.
* Should this event be stopped and consumed or not. * Should this event be stopped and consumed or not.
@ -307,7 +305,6 @@ function HTMLTooltip(toolboxDoc, {
id = "", id = "",
className = "", className = "",
type = "normal", type = "normal",
autofocus = false,
consumeOutsideClicks = true, consumeOutsideClicks = true,
useXulWrapper = false, useXulWrapper = false,
} = {}) { } = {}) {
@ -317,7 +314,6 @@ function HTMLTooltip(toolboxDoc, {
this.id = id; this.id = id;
this.className = className; this.className = className;
this.type = type; this.type = type;
this.autofocus = autofocus;
this.consumeOutsideClicks = consumeOutsideClicks; this.consumeOutsideClicks = consumeOutsideClicks;
this.useXulWrapper = this._isXUL() && useXulWrapper; this.useXulWrapper = this._isXUL() && useXulWrapper;
this.preferredWidth = "auto"; this.preferredWidth = "auto";
@ -451,9 +447,6 @@ HTMLTooltip.prototype = {
this.doc.defaultView.clearTimeout(this.attachEventsTimer); this.doc.defaultView.clearTimeout(this.attachEventsTimer);
this.attachEventsTimer = this.doc.defaultView.setTimeout(() => { this.attachEventsTimer = this.doc.defaultView.setTimeout(() => {
if (this.autofocus) {
this.focus();
}
// Update the top window reference each time in case the host changes. // Update the top window reference each time in case the host changes.
this.topWindow = this._getTopWindow(); this.topWindow = this._getTopWindow();
this.topWindow.addEventListener("click", this._onClick, true); this.topWindow.addEventListener("click", this._onClick, true);

Просмотреть файл

@ -92,18 +92,24 @@ nsTSubstring<T>::StartBulkWrite(size_type aCapacity,
} }
// Note! Capacity() returns 0 when the string is immutable. // Note! Capacity() returns 0 when the string is immutable.
size_type curCapacity = Capacity(); const size_type curCapacity = Capacity();
bool shrinking = false;
// We've established that aCapacity > 0. // We've established that aCapacity > 0.
// |curCapacity == 0| means that the buffer is immutable or 0-sized, so we // |curCapacity == 0| means that the buffer is immutable or 0-sized, so we
// need to allocate a new buffer. We cannot use the existing buffer even // need to allocate a new buffer. We cannot use the existing buffer even
// though it might be large enough. // though it might be large enough.
if (!aAllowShrinking && aCapacity <= curCapacity) { if (aCapacity <= curCapacity) {
char_traits::move(this->mData + aNewSuffixStart, if (aAllowShrinking) {
this->mData + aOldSuffixStart, shrinking = true;
aSuffixLength); } else {
return curCapacity; char_traits::move(this->mData + aNewSuffixStart,
this->mData + aOldSuffixStart,
aSuffixLength);
return curCapacity;
}
} }
char_type* oldData = this->mData; char_type* oldData = this->mData;
@ -167,6 +173,7 @@ nsTSubstring<T>::StartBulkWrite(size_type aCapacity,
MOZ_ASSERT(aAllowShrinking, "How come we didn't return earlier?"); MOZ_ASSERT(aAllowShrinking, "How come we didn't return earlier?");
// We're already close enough to the right size. // We're already close enough to the right size.
newData = oldData; newData = oldData;
newCapacity = curCapacity;
} else { } else {
size_type storageSize = (newCapacity + 1) * sizeof(char_type); size_type storageSize = (newCapacity + 1) * sizeof(char_type);
// Since we allocate only by powers of 2 we always fit into a full mozjemalloc // Since we allocate only by powers of 2 we always fit into a full mozjemalloc
@ -174,7 +181,18 @@ nsTSubstring<T>::StartBulkWrite(size_type aCapacity,
// copying too much. // copying too much.
nsStringBuffer* newHdr = nsStringBuffer::Alloc(storageSize).take(); nsStringBuffer* newHdr = nsStringBuffer::Alloc(storageSize).take();
if (!newHdr) { if (!newHdr) {
return mozilla::Err(NS_ERROR_OUT_OF_MEMORY); // we are still in a consistent state // we are still in a consistent state
if (shrinking) {
// Since shrinking is just a memory footprint optimization, we
// don't propagate OOM if we tried to shrink in order to avoid
// OOM crashes from infallible callers. If we're lucky, soon enough
// a fallible caller reaches OOM and is able to deal or we end up
// disposing of this string before reaching OOM again.
newData = oldData;
newCapacity = curCapacity;
} else {
return mozilla::Err(NS_ERROR_OUT_OF_MEMORY);
}
} }
newData = (char_type*)newHdr->Data(); newData = (char_type*)newHdr->Data();