Files
tubestation/toolkit/components/aboutthirdparty/AboutThirdParty_TestMethods.cpp
Ray Kraesig aec3a47a80 Bug 1776048 - [1/1] Remove custom filepicker from test code r=gstoll
The existing code for the `browser_aboutthirdparty.js` test attempts to
load a DLL indirectly by means of a Rube Goldberg process involving a
directly-instantiated file-picker. This appears to be the source of the
severe flakiness of this test.

This approach was reasonable when the file-picker was the primary source
of deleterious third-party DLLs; but now that we generally open file-
pickers out-of-process, there isn't as much of a reason to test that
particular injection mechanism. Let's just load the test DLL directly,
instead.

This patch has two caveats:

* The test fails _consistently_, rather than flakily, on ASAN builds.
  The reason for that remains to be investigated, but probably belongs
  in a separate bug; for now, we simply leave it disabled.

* The test expects the DLL to be a shell extension, and fails with
  complaints if it's not. There's no other reason to have any of the
  shell-extension-registration machinery in there, though, so it can
  (and probably should) be removed, and the test rewritten accordingly.
  In the interests of swiftly deflaking it, though, this is also being
  left for a separate bug.

Outside of test-only code, no functional changes.

Differential Revision: https://phabricator.services.mozilla.com/D231462
2024-12-09 14:58:26 +00:00

30 lines
844 B
C++

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */
#include "AboutThirdParty.h"
#include <windows.h>
#include <shlobj.h>
#include <shobjidl.h>
namespace mozilla {
NS_IMETHODIMP AboutThirdParty::LoadModuleForTesting(
const nsAString& aModuleName) {
HMODULE module = ::LoadLibraryW(aModuleName.Data());
// We don't need to keep the module around; just loading it is sufficient.
if (module) {
::FreeLibrary(module);
return NS_OK;
}
// auto const err [[maybe_unused]] = ::GetLastError();
return NS_ERROR_UNEXPECTED;
}
} // namespace mozilla