Skip to content

Commit

Permalink
Merge autoland to mozilla-central. a=merge
Browse files Browse the repository at this point in the history
  • Loading branch information
nbeleuzu committed Jan 22, 2024
2 parents f09efbd + 6964a15 commit 734887c
Show file tree
Hide file tree
Showing 220 changed files with 5,128 additions and 1,207 deletions.
12 changes: 10 additions & 2 deletions browser/actors/LinkHandlerParent.sys.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,15 @@ export class LinkHandlerParent extends JSWindowActorParent {
setIconFromLink(
gBrowser,
browser,
{ pageURL, originalURL, canUseForTab, expiration, iconURL, canStoreIcon }
{
pageURL,
originalURL,
canUseForTab,
expiration,
iconURL,
canStoreIcon,
beforePageShow,
}
) {
let tab = gBrowser.getTabForBrowser(browser);
if (!tab) {
Expand Down Expand Up @@ -150,7 +158,7 @@ export class LinkHandlerParent extends JSWindowActorParent {
}

if (canUseForTab) {
gBrowser.setIcon(tab, iconURL, originalURL);
gBrowser.setIcon(tab, iconURL, originalURL, null, beforePageShow);
}
}
}
3 changes: 0 additions & 3 deletions browser/app/profile/firefox.js
Original file line number Diff line number Diff line change
Expand Up @@ -2184,9 +2184,6 @@ pref("privacy.fingerprintingProtection.pbmode", true);
pref("privacy.exposeContentTitleInWindow", true);
pref("privacy.exposeContentTitleInWindow.pbm", true);

// Start the browser in e10s mode
pref("browser.tabs.remote.autostart", true);

// Run media transport in a separate process?
pref("media.peerconnection.mtransport_process", true);

Expand Down
8 changes: 6 additions & 2 deletions browser/base/content/tabbrowser.js
Original file line number Diff line number Diff line change
Expand Up @@ -977,7 +977,8 @@
aTab,
aIconURL = "",
aOriginalURL = aIconURL,
aLoadingPrincipal = null
aLoadingPrincipal = null,
aClearImageFirst = false
) {
let makeString = url => (url instanceof Ci.nsIURI ? url.spec : url);

Expand All @@ -1001,7 +1002,9 @@
browser.mIconURL = aIconURL;

if (aIconURL != aTab.getAttribute("image")) {
aTab.removeAttribute("image");
if (aClearImageFirst) {
aTab.removeAttribute("image");
}
if (aIconURL) {
if (aLoadingPrincipal) {
aTab.setAttribute("iconloadingprincipal", aLoadingPrincipal);
Expand All @@ -1010,6 +1013,7 @@
}
aTab.setAttribute("image", aIconURL);
} else {
aTab.removeAttribute("image");
aTab.removeAttribute("iconloadingprincipal");
}
this._tabAttrModified(aTab, ["image"]);
Expand Down
5 changes: 4 additions & 1 deletion browser/base/content/test/favicons/browser.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ support-files = [
]

["browser_favicon_empty_data.js"]
support-files = ["blank.html"]
support-files = [
"blank.html",
"file_favicon_empty.html",
]

["browser_favicon_load.js"]
https_first_disabled = true
Expand Down
32 changes: 24 additions & 8 deletions browser/base/content/test/favicons/browser_favicon_empty_data.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@

const TEST_ROOT =
"http://mochi.test:8888/browser/browser/base/content/test/favicons/";
const ICON_URL = TEST_ROOT + "file_bug970276_favicon1.ico";
const EMPTY_URL = "data:image/x-icon";

const PAGE_URL = TEST_ROOT + "blank.html";
const ICON_URL = TEST_ROOT + "file_bug970276_favicon1.ico";
const ICON_DATAURI_START = "data:image/x-icon;base64,AAABAAEAEBAAAAAAAABoBQAA";

const EMPTY_PAGE_URL = TEST_ROOT + "file_favicon_empty.html";
const EMPTY_ICON_URL = "data:image/x-icon";

add_task(async function () {
await BrowserTestUtils.withNewTab(
Expand All @@ -16,18 +20,30 @@ add_task(async function () {
let iconBox = gBrowser
.getTabForBrowser(browser)
.querySelector(".tab-icon-image");

await addContentLinkForIconUrl(ICON_URL, browser);
Assert.ok(
browser.mIconURL.startsWith(
"data:image/x-icon;base64,AAABAAEAEBAAAAAAAABoBQAA"
),
browser.mIconURL.startsWith(ICON_DATAURI_START),
"Favicon is correctly set."
);

// Give some time to ensure the icon is rendered.
/* eslint-disable mozilla/no-arbitrary-setTimeout */
await new Promise(resolve => setTimeout(resolve, 200));
let firstIconShotDataURL = TestUtils.screenshotArea(iconBox, window);

await addContentLinkForIconUrl(EMPTY_URL, browser);
Assert.equal(browser.mIconURL, EMPTY_URL, "Favicon is correctly set.");
let browserLoaded = BrowserTestUtils.browserLoaded(
browser,
false,
EMPTY_PAGE_URL
);
BrowserTestUtils.startLoadingURIString(browser, EMPTY_PAGE_URL);
let iconChanged = waitForFavicon(browser, EMPTY_ICON_URL);
await Promise.all([browserLoaded, iconChanged]);
Assert.equal(browser.mIconURL, EMPTY_ICON_URL, "Favicon was changed.");

// Give some time to ensure the icon is rendered.
/* eslint-disable mozilla/no-arbitrary-setTimeout */
await new Promise(resolve => setTimeout(resolve, 200));
let secondIconShotDataURL = TestUtils.screenshotArea(iconBox, window);

Assert.notEqual(
Expand Down
12 changes: 12 additions & 0 deletions browser/base/content/test/favicons/file_favicon_empty.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>

<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<link rel="icon" href="data:image/x-icon" type="image/ico" id="i">
</head>

<body>
</body>

</html>
36 changes: 0 additions & 36 deletions browser/components/shell/nsIWindowsShellService.idl
Original file line number Diff line number Diff line change
Expand Up @@ -189,42 +189,6 @@ interface nsIWindowsShellService : nsISupports
*/
void unpinShortcutFromTaskbar(in AString aShortcutPath);


/**
* Gets the full path of a taskbar tab shortcut.
*
* @param aShortcutName
* The name of the taskbar tab shortcut, excluding the file extension.
* @throws NS_ERROR_FAILURE
* If the user token cannot be found.
* @throws NS_ERROR_ABORT
* If converting the sid to a string fails.
*
* @return The full path of the taskbar tab shortcut
*/
AString getTaskbarTabShortcutPath(in AString aShortcutName);

/*
* Searches the %USERPROFILE%\AppData\Roaming\Microsoft\Windows\Start
* Menu\Programs folder and returns an array with the path of all
* shortcuts with a target matching the current Firefox install location
* and the -taskbar-tab argument.
*
* It is possible to return an empty array if no shortcuts are found.
*
* @return An array of paths for all taskbar tab shortcuts.
*
* @throws NS_ERROR_ABORT
* if instance cannot be created.
* @throws NS_ERROR_FILE_NOT_FOUND
* if %USERPROFILE%\AppData\Roaming\ cannot be opened.
* @throws NS_ERROR_FAILURE
* if the executable file cannot be found.
* @throws NS_ERROR_FILE_UNRECOGNIZED_PATH
* if the executable file cannot be converted into a string.
*/
Array<AString> getTaskbarTabPins();

/*
* Determine where a given shortcut likely appears in the shell.
*
Expand Down
150 changes: 10 additions & 140 deletions browser/components/shell/nsWindowsShellService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1418,15 +1418,23 @@ static nsresult ManageShortcutTaskbarPins(bool aCheckOnly, bool aPinType,
}
};

HRESULT hr = CoInitialize(nullptr);
if (FAILED(hr)) {
return NS_ERROR_FAILURE;
}
const struct ComUninitializer {
~ComUninitializer() { CoUninitialize(); }
} kCUi;

mozilla::UniquePtr<__unaligned ITEMIDLIST, ILFreeDeleter> path(
ILCreateFromPathW(nsString(aShortcutPath).get()));
if (NS_WARN_IF(!path)) {
return NS_ERROR_FILE_NOT_FOUND;
}

IPinnedList3* pinnedList = nullptr;
HRESULT hr = CoCreateInstance(CLSID_TaskbandPin, NULL, CLSCTX_INPROC_SERVER,
IID_IPinnedList3, (void**)&pinnedList);
hr = CoCreateInstance(CLSID_TaskbandPin, NULL, CLSCTX_INPROC_SERVER,
IID_IPinnedList3, (void**)&pinnedList);
if (FAILED(hr) || !pinnedList) {
return NS_ERROR_NOT_AVAILABLE;
}
Expand Down Expand Up @@ -1459,144 +1467,6 @@ nsWindowsShellService::UnpinShortcutFromTaskbar(
return ManageShortcutTaskbarPins(runInTestMode, pinType, aShortcutPath);
}

NS_IMETHODIMP
nsWindowsShellService::GetTaskbarTabShortcutPath(const nsAString& aShortcutName,
nsAString& aRetPath) {
// The taskbar tab shortcut will always be in
// %APPDATA%\Microsoft\Windows\Start Menu\Programs
RefPtr<IKnownFolderManager> fManager;
RefPtr<IKnownFolder> progFolder;
LPWSTR progFolderW;
nsString progFolderNS;
HRESULT hr =
CoCreateInstance(CLSID_KnownFolderManager, nullptr, CLSCTX_INPROC_SERVER,
IID_IKnownFolderManager, getter_AddRefs(fManager));
if (NS_WARN_IF(FAILED(hr))) {
return NS_ERROR_ABORT;
}
fManager->GetFolder(FOLDERID_Programs, progFolder.StartAssignment());
hr = progFolder->GetPath(0, &progFolderW);
if (FAILED(hr)) {
return NS_ERROR_FILE_NOT_FOUND;
}
progFolderNS.Assign(progFolderW);
aRetPath = progFolderNS + u"\\"_ns + aShortcutName + u".lnk"_ns;
return NS_OK;
}

NS_IMETHODIMP
nsWindowsShellService::GetTaskbarTabPins(nsTArray<nsString>& aShortcutPaths) {
aShortcutPaths.Clear();

// Get AppData\\Roaming folder using a known folder ID
RefPtr<IKnownFolderManager> fManager;
RefPtr<IKnownFolder> roamingAppData;
LPWSTR roamingAppDataW;
nsString roamingAppDataNS;
HRESULT hr =
CoCreateInstance(CLSID_KnownFolderManager, nullptr, CLSCTX_INPROC_SERVER,
IID_IKnownFolderManager, getter_AddRefs(fManager));
if (NS_WARN_IF(FAILED(hr))) {
return NS_ERROR_ABORT;
}
fManager->GetFolder(FOLDERID_RoamingAppData,
roamingAppData.StartAssignment());
hr = roamingAppData->GetPath(0, &roamingAppDataW);
if (FAILED(hr)) {
return NS_ERROR_FILE_NOT_FOUND;
}

// Append taskbar pins folder to AppData\\Roaming
roamingAppDataNS.Assign(roamingAppDataW);
CoTaskMemFree(roamingAppDataW);
nsString taskbarFolder =
roamingAppDataNS + u"\\Microsoft\\Windows\\Start Menu\\Programs"_ns;
nsString taskbarFolderWildcard = taskbarFolder + u"\\*.lnk"_ns;

// Get known path for binary file for later comparison with shortcuts.
// Returns lowercase file path which should be fine for Windows as all
// directories and files are case-insensitive by default.
RefPtr<nsIFile> binFile;
nsString binPath;
nsresult rv = XRE_GetBinaryPath(binFile.StartAssignment());
if (NS_WARN_IF(FAILED(rv))) {
return NS_ERROR_FAILURE;
}
rv = binFile->GetPath(binPath);
if (NS_WARN_IF(FAILED(rv))) {
return NS_ERROR_FILE_UNRECOGNIZED_PATH;
}

// Check for if first file exists with a shortcut extension (.lnk)
WIN32_FIND_DATAW ffd;
HANDLE fileHandle = INVALID_HANDLE_VALUE;
fileHandle = FindFirstFileW(taskbarFolderWildcard.get(), &ffd);
if (fileHandle == INVALID_HANDLE_VALUE) {
// This means that no files were found in the folder which
// doesn't imply an error.
return NS_OK;
}

do {
// Extract shortcut target path from every
// shortcut in the taskbar pins folder.
nsString fileName(ffd.cFileName);
RefPtr<IShellLinkW> link;
RefPtr<IPersistFile> ppf;
RefPtr<IPropertyStore> pps;
nsString target;
target.SetLength(MAX_PATH);
hr = CoCreateInstance(CLSID_ShellLink, nullptr, CLSCTX_INPROC_SERVER,
IID_IShellLinkW, getter_AddRefs(link));
if (NS_WARN_IF(FAILED(hr))) {
continue;
}
nsString filePath = taskbarFolder + u"\\"_ns + fileName;
if (NS_WARN_IF(FAILED(hr))) {
continue;
}

// After loading shortcut, search through arguments to find if
// it is a taskbar tab shortcut.
hr = SHGetPropertyStoreFromParsingName(filePath.get(), nullptr,
GPS_READWRITE, IID_IPropertyStore,
getter_AddRefs(pps));
if (NS_WARN_IF(FAILED(hr)) || pps == nullptr) {
continue;
}
PROPVARIANT propVar;
PropVariantInit(&propVar);
auto cleanupPropVariant =
MakeScopeExit([&] { PropVariantClear(&propVar); });
// Get the PKEY_Link_Arguments property
hr = pps->GetValue(PKEY_Link_Arguments, &propVar);
if (NS_WARN_IF(FAILED(hr))) {
continue;
}
// Check if the argument matches
if (!(propVar.vt == VT_LPWSTR && propVar.pwszVal != nullptr &&
wcsstr(propVar.pwszVal, L"-taskbar-tab") != nullptr)) {
continue;
}

hr = link->GetPath(target.get(), MAX_PATH, nullptr, 0);
if (NS_WARN_IF(FAILED(hr))) {
continue;
}

// If shortcut target matches known binary file value
// then add the path to the shortcut as a valid
// shortcut. This has to be a substring search as
// the user could have added unknown command line arguments
// to the shortcut.
if (_wcsnicmp(target.get(), binPath.get(), binPath.Length()) == 0) {
aShortcutPaths.AppendElement(filePath);
}
} while (FindNextFile(fileHandle, &ffd) != 0);
FindClose(fileHandle);
return NS_OK;
}

static nsresult PinCurrentAppToTaskbarWin10(bool aCheckOnly,
const nsAString& aAppUserModelId,
nsAutoString aShortcutPath) {
Expand Down
2 changes: 2 additions & 0 deletions browser/modules/FaviconLoader.sys.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,7 @@ class IconLoader {
expiration: undefined,
iconURL: iconInfo.iconUri.spec,
canStoreIcon: iconInfo.beforePageShow,
beforePageShow: iconInfo.beforePageShow,
});
return;
}
Expand All @@ -568,6 +569,7 @@ class IconLoader {
expiration,
iconURL: dataURL,
canStoreIcon,
beforePageShow: iconInfo.beforePageShow,
});
} catch (e) {
if (e.result != Cr.NS_BINDING_ABORTED) {
Expand Down
6 changes: 0 additions & 6 deletions build/pgo/profileserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,6 @@ def get_crashreports(directory, name=None):
v = v.format(**interpolation)
prefs[k] = Preferences.cast(v)

# Enforce e10s. This isn't in one of the user.js files because those
# are shared with android, which doesn't want this on. We can't
# interpolate because the formatting code only works for strings,
# and this is a bool pref.
prefs["browser.tabs.remote.autostart"] = True

profile = FirefoxProfile(
profile=profilePath,
preferences=prefs,
Expand Down
1 change: 1 addition & 0 deletions build/valgrind/mach_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ def valgrind_test(command_context, suppressions):

env = os.environ.copy()
env["G_SLICE"] = "always-malloc"
env["MOZ_FORCE_DISABLE_E10S"] = "1"
env["MOZ_CC_RUN_DURING_SHUTDOWN"] = "1"
env["MOZ_CRASHREPORTER_NO_REPORT"] = "1"
env["MOZ_DISABLE_NONLOCAL_CONNECTIONS"] = "1"
Expand Down
Loading

0 comments on commit 734887c

Please sign in to comment.