Skip to content

Commit

Permalink
Merge autoland to mozilla-central. a=merge on a CLOSED TREE
Browse files Browse the repository at this point in the history
  • Loading branch information
nbeleuzu committed Oct 30, 2020
2 parents 72f0e99 + 3fc97c1 commit fa754ef
Show file tree
Hide file tree
Showing 159 changed files with 1,912 additions and 1,162 deletions.
4 changes: 2 additions & 2 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,12 @@ endif
# enable --host-bins only for automation builds, which only require Linux and
# Windows host binaries.
recurse_artifact:
$(topsrcdir)/mach --log-no-times artifact install$(if $(MOZ_ARTIFACT_BUILD_SYMBOLS), --symbols$(addprefix =,$(filter full,$(MOZ_ARTIFACT_BUILD_SYMBOLS))))$(if $(MOZ_AUTOMATION), --host-bins) $(verbose_flag)
$(PYTHON3) $(topsrcdir)/mach --log-no-times artifact install$(if $(MOZ_ARTIFACT_BUILD_SYMBOLS), --symbols$(addprefix =,$(filter full,$(MOZ_ARTIFACT_BUILD_SYMBOLS))))$(if $(MOZ_AUTOMATION), --host-bins) $(verbose_flag)

ifdef MOZ_EME_WIN32_ARTIFACT
recurse_win32-artifact:
rm -rf $(DIST)/i686
$(topsrcdir)/mach --log-no-times artifact install --job $(if $(MOZ_PGO),win32-pgo,win32-opt) --no-tests --distdir $(DIST)/i686 $(verbose_flag)
$(PYTHON3) $(topsrcdir)/mach --log-no-times artifact install --job $(if $(MOZ_PGO),win32-pgo,win32-opt) --no-tests --distdir $(DIST)/i686 $(verbose_flag)
mv $(DIST)/i686/bin/* $(DIST)/i686
endif

Expand Down
51 changes: 50 additions & 1 deletion browser/base/content/browser-places.js
Original file line number Diff line number Diff line change
Expand Up @@ -2170,6 +2170,10 @@ var BookmarkingUI = {
}
break;
}

if (ev.parentGuid === PlacesUtils.bookmarks.unfiledGuid) {
this.maybeShowOtherBookmarksFolder();
}
}
},

Expand Down Expand Up @@ -2207,7 +2211,25 @@ var BookmarkingUI = {
onEndUpdateBatch() {},
onBeforeItemRemoved() {},
onItemVisited() {},
onItemMoved() {},
onItemMoved(
aItemId,
aProperty,
aIsAnnotationProperty,
aNewValue,
aLastModified,
aItemType,
aGuid,
oldParentGuid,
newParentGuid
) {
let hasMovedToOrOutOfOtherBookmarks =
newParentGuid === PlacesUtils.bookmarks.unfiledGuid ||
oldParentGuid === PlacesUtils.bookmarks.unfiledGuid;

if (hasMovedToOrOutOfOtherBookmarks) {
this.maybeShowOtherBookmarksFolder();
}
},

onWidgetUnderflow(aNode, aContainer) {
let win = aNode.ownerGlobal;
Expand All @@ -2220,5 +2242,32 @@ var BookmarkingUI = {
this._uninitView();
},

async maybeShowOtherBookmarksFolder() {
// Only show the "Other Bookmarks" folder in the toolbar if pref is enabled.
let featureEnabled = Services.prefs.getBoolPref(
"browser.toolbars.bookmarks.2h2020",
false
);

if (!featureEnabled) {
return;
}

let unfiledGuid = PlacesUtils.bookmarks.unfiledGuid;
let numberOfBookmarks = PlacesUtils.getChildCountForFolder(unfiledGuid);
let otherBookmarks = document.getElementById("OtherBookmarks");

if (numberOfBookmarks > 0) {
let otherBookmarksPopup = document.getElementById("OtherBookmarksPopup");
let result = PlacesUtils.getFolderContents(unfiledGuid);
let node = result.root;
otherBookmarksPopup._placesNode = PlacesUtils.asContainer(node);

otherBookmarks.hidden = false;
} else {
otherBookmarks.hidden = true;
}
},

QueryInterface: ChromeUtils.generateQI(["nsINavBookmarkObserver"]),
};
13 changes: 13 additions & 0 deletions browser/base/content/browser.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -2086,6 +2086,19 @@
tooltip="bhTooltip" popupsinherittooltip="true"
context="placesContext"/>
</toolbarbutton>
<toolbarbutton type="menu"
id="OtherBookmarks"
class="bookmark-item"
hidden="true"
label="&bookmarksMenuButton.other.label;"
container="true"
onpopupshowing="document.getElementById('PlacesToolbar')
._placesView._onOtherBookmarksPopupShowing(event);">
<menupopup id="OtherBookmarksPopup"
is="places-popup"
placespopup="true"
context="placesContext" />
</toolbarbutton>
</hbox>
</hbox>
</toolbaritem>
Expand Down
4 changes: 4 additions & 0 deletions browser/base/content/test/favicons/browser_mixed_content.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
add_task(async () => {
await SpecialPowers.pushPrefEnv({
set: [["security.mixed_content.upgrade_display_content", false]],
});

const testPath =
"https://example.com/browser/browser/base/content/test/favicons/file_insecure_favicon.html";
const expectedIcon =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ add_task(async function test() {
set: [
// By default, proxies don't apply to 127.0.0.1. We need them to for this test, though:
["network.proxy.allow_hijacking_localhost", true],
["security.mixed_content.upgrade_display_content", false],
],
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ add_task(async function() {
});

async function run_testcase(testcase) {
await SpecialPowers.pushPrefEnv({
set: [["security.mixed_content.upgrade_display_content", false]],
});
// Test the forward and back case.
// Start by loading an unrelated URI so that this generalizes well when the
// testcase would otherwise first navigate to an error page, which doesn't
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,15 @@ add_task(async function test() {
);
let startBookmarksLength = currentBookmarks.length;

let lastBookmark = currentBookmarks[currentBookmarks.length - 1];
// The destination element should be a non-folder bookmark
let destBookmarkItem = () =>
bookmarksToolbar.querySelector(
"#PlacesToolbarItems .bookmark-item:not([container])"
);

await EventUtils.synthesizePlainDragAndDrop({
srcElement: tab1,
destElement: lastBookmark,
destElement: destBookmarkItem(),
});
await TestUtils.waitForCondition(
() => currentBookmarks.length == startBookmarksLength + 2,
Expand All @@ -50,7 +55,7 @@ add_task(async function test() {
startBookmarksLength = currentBookmarks.length;
await EventUtils.synthesizePlainDragAndDrop({
srcElement: tab3,
destElement: lastBookmark,
destElement: destBookmarkItem(),
});
await TestUtils.waitForCondition(
() => currentBookmarks.length == startBookmarksLength + 1,
Expand Down
13 changes: 13 additions & 0 deletions browser/components/places/content/browserPlacesViews.js
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,8 @@ function PlacesToolbar(aPlace) {
["_dropIndicator", "PlacesToolbarDropIndicator"],
["_chevron", "PlacesChevron"],
["_chevronPopup", "PlacesChevronPopup"],
["_otherBookmarks", "OtherBookmarks"],
["_otherBookmarksPopup", "OtherBookmarksPopup"],
].forEach(function(elementGlobal) {
let [name, id] = elementGlobal;
thisView.__defineGetter__(name, function() {
Expand Down Expand Up @@ -1030,6 +1032,8 @@ PlacesToolbar.prototype = {
// Otherwise, it will be initialized when the toolbar overflows.
this._chevronPopup.place = this.place;
}

BookmarkingUI.maybeShowOtherBookmarksFolder();
},

_insertNewItem: function PT__insertNewItem(
Expand Down Expand Up @@ -1119,6 +1123,15 @@ PlacesToolbar.prototype = {
this._updateChevronPopupNodesVisibility();
},

_onOtherBookmarksPopupShowing: function PT__onOtherBookmarksPopupShowing(
aEvent
) {
if (aEvent.target != this._otherBookmarksPopup) {
return;
}
this._rebuildPopup(this._otherBookmarksPopup);
},

handleEvent: function PT_handleEvent(aEvent) {
switch (aEvent.type) {
case "unload":
Expand Down
1 change: 1 addition & 0 deletions browser/components/places/tests/browser/browser.ini
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ skip-if = (os == "mac" && debug) # Bug 1467049
[browser_toolbar_drop_text.js]
[browser_toolbar_library_downloads.js]
[browser_toolbar_library_open_recent.js]
[browser_toolbar_other_bookmarks.js]
[browser_toolbar_overflow.js]
skip-if = os == "linux" && bits == 32 && debug # bug 1463443
[browser_toolbarbutton_menu_context.js]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
/* 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/. */
/* eslint-disable mozilla/no-arbitrary-setTimeout */

"use strict";

const BOOKMARKS_H2_2020_PREF = "browser.toolbars.bookmarks.2h2020";
const bookmarksInfo = [
{
title: "firefox",
url: "http://example.com",
},
{
title: "rules",
url: "http://example.com/2",
},
{
title: "yo",
url: "http://example.com/2",
},
];

/**
* Test showing the "Other Bookmarks" folder in the bookmarks toolbar.
*/

// Setup.
add_task(async function setup() {
let toolbar = document.getElementById("PersonalToolbar");
let wasCollapsed = toolbar.collapsed;

// Uncollapse the personal toolbar if needed.
if (wasCollapsed) {
await promiseSetToolbarVisibility(toolbar, true);
}

// Cleanup.
registerCleanupFunction(async () => {
// Collapse the personal toolbar if needed.
if (wasCollapsed) {
await promiseSetToolbarVisibility(toolbar, false);
}
await PlacesUtils.bookmarks.eraseEverything();
});
});

// Test the "Other Bookmarks" folder is shown in the toolbar when
// bookmarks are stored under that folder.
add_task(async function testShowingOtherBookmarksInToolbar() {
await SpecialPowers.pushPrefEnv({
set: [[BOOKMARKS_H2_2020_PREF, true]],
});

info("Check visibility of an empty Other Bookmarks folder.");
testIsOtherBookmarksHidden(true);

info("Ensure folder appears in toolbar when a new bookmark is added.");
let bookmarks = await PlacesUtils.bookmarks.insertTree({
guid: PlacesUtils.bookmarks.unfiledGuid,
children: bookmarksInfo,
});
testIsOtherBookmarksHidden(false);

info("Ensure folder disappears from toolbar when no bookmarks are present.");
await PlacesUtils.bookmarks.remove(bookmarks);

info("Add bookmarks to the Bookmarks Toolbar folder.");
testIsOtherBookmarksHidden(true);
});

// Test that folder visibility is correct when moving bookmarks to an empty
// "Other Bookmarks" folder and vice versa.
add_task(async function testOtherBookmarksVisibilityWhenMovingBookmarks() {
await SpecialPowers.pushPrefEnv({
set: [[BOOKMARKS_H2_2020_PREF, true]],
});

info("Add bookmarks to Bookmarks Toolbar.");
let bookmarks = await PlacesUtils.bookmarks.insertTree({
guid: PlacesUtils.bookmarks.toolbarGuid,
children: bookmarksInfo,
});
testIsOtherBookmarksHidden(true);

info("Move toolbar bookmarks to Other Bookmarks folder.");
await PlacesUtils.bookmarks.moveToFolder(
bookmarks.map(b => b.guid),
PlacesUtils.bookmarks.unfiledGuid,
PlacesUtils.bookmarks.DEFAULT_INDEX
);
testIsOtherBookmarksHidden(false);

info("Move bookmarks from Other Bookmarks back to the toolbar.");
await PlacesUtils.bookmarks.moveToFolder(
bookmarks.map(b => b.guid),
PlacesUtils.bookmarks.toolbarGuid,
PlacesUtils.bookmarks.DEFAULT_INDEX
);
testIsOtherBookmarksHidden(true);
});

// Test OtherBookmarksPopup in toolbar.
add_task(async function testOtherBookmarksMenuPopup() {
await SpecialPowers.pushPrefEnv({
set: [[BOOKMARKS_H2_2020_PREF, true]],
});

info("Add bookmarks to Other Bookmarks folder.");
let bookmarks = await PlacesUtils.bookmarks.insertTree({
guid: PlacesUtils.bookmarks.unfiledGuid,
children: bookmarksInfo,
});

testIsOtherBookmarksHidden(false);

info("Check the popup menu has correct number of children.");
await openMenuPopup();
testNumberOfMenuPopupChildren(3);
await closeMenuPopup();

info("Remove a bookmark.");
await PlacesUtils.bookmarks.remove(bookmarks[0]);

await openMenuPopup();
testNumberOfMenuPopupChildren(2);
await closeMenuPopup();
});

/**
* Tests whether or not the "Other Bookmarks" folder is visible.
*/
async function testIsOtherBookmarksHidden(expected) {
info("Test whether or not the 'Other Bookmarks' folder is visible.");
let otherBookmarks = document.getElementById("OtherBookmarks");

await BrowserTestUtils.waitForAttribute("hidden", otherBookmarks, expected);

ok(true, `Other Bookmarks folder "hidden" state should be ${expected}.`);
}

/**
* Tests number of menu items in Other Bookmarks popup.
*/
function testNumberOfMenuPopupChildren(expected) {
let popup = document.getElementById("OtherBookmarksPopup");
let items = popup.querySelectorAll("menuitem");

is(items.length, expected, `Number of menu items should be ${expected}.`);
}

/**
* Helper for opening the menupopup
*/
async function openMenuPopup() {
let popup = document.getElementById("OtherBookmarksPopup");
let target = document.getElementById("OtherBookmarks");

EventUtils.synthesizeMouseAtCenter(target, {});

await BrowserTestUtils.waitForPopupEvent(popup, "shown");
}

/**
* Helper for closing the context menu.
*/
async function closeMenuPopup() {
let popup = document.getElementById("OtherBookmarksPopup");

info("Closing menu popup.");
popup.hidePopup();
await BrowserTestUtils.waitForPopupEvent(popup, "hidden");
}
11 changes: 10 additions & 1 deletion browser/components/sessionstore/SessionStore.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -1219,12 +1219,21 @@ var SessionStoreInternal = {
let userContextId = aBrowser.contentPrincipal
? aBrowser.contentPrincipal.originAttributes.userContextId
: listener._lastKnownUserContextId;
// If aData.sHistoryNeeded we need to collect all session
// history entries, because with SHIP this indicates that we
// either saw 'DOMTitleChanged' in
// mozilla::dom::TabListener::HandleEvent or
// 'OnDocumentStart/OnDocumentEnd' was called on
// mozilla::dom::ContentSessionStore, and both needs a full
// collect.
aData.data.historychange = SessionHistory.collectFromParent(
uri,
body,
aBrowsingContext.sessionHistory,
userContextId,
listener._sHistoryChanges ? listener._fromIdx : -1
listener._sHistoryChanges && !aData.sHistoryNeeded
? listener._fromIdx
: -1
);
listener._sHistoryChanges = false;
listener._fromIdx = kNoIndex;
Expand Down
Loading

0 comments on commit fa754ef

Please sign in to comment.