From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- .../tests/TestShellEx/TestShellEx.cpp | 68 ++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 toolkit/components/aboutthirdparty/tests/TestShellEx/TestShellEx.cpp (limited to 'toolkit/components/aboutthirdparty/tests/TestShellEx/TestShellEx.cpp') diff --git a/toolkit/components/aboutthirdparty/tests/TestShellEx/TestShellEx.cpp b/toolkit/components/aboutthirdparty/tests/TestShellEx/TestShellEx.cpp new file mode 100644 index 0000000000..dc0588483f --- /dev/null +++ b/toolkit/components/aboutthirdparty/tests/TestShellEx/TestShellEx.cpp @@ -0,0 +1,68 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * vim: sw=2 ts=2 et lcs=trail\:.,tab\:>~ : + * 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 "mozilla/RefPtr.h" +#include "RegUtils.h" + +#include +#include + +already_AddRefed CreateFactory(); + +// {10A9521E-0205-4CC7-93A1-62F30A9A54B3} +GUID CLSID_TestShellEx = { + 0x10a9521e, 0x205, 0x4cc7, {0x93, 0xa1, 0x62, 0xf3, 0xa, 0x9a, 0x54, 0xb3}}; +wchar_t kFriendlyName[] = L"Minimum Shell Extension for Firefox testing"; + +std::wstring gDllPath; + +BOOL APIENTRY DllMain(HMODULE aModule, DWORD aReason, LPVOID) { + wchar_t buf[MAX_PATH]; + switch (aReason) { + case DLL_PROCESS_ATTACH: + if (!::GetModuleFileNameW(aModule, buf, ARRAYSIZE(buf))) { + return FALSE; + } + gDllPath = buf; + break; + case DLL_THREAD_ATTACH: + case DLL_THREAD_DETACH: + case DLL_PROCESS_DETACH: + break; + } + return TRUE; +} + +STDAPI DllGetClassObject(REFCLSID aClsid, REFIID aIid, void** aResult) { + if (!IsEqualCLSID(aClsid, CLSID_TestShellEx) || + !IsEqualCLSID(aIid, IID_IClassFactory)) { + return CLASS_E_CLASSNOTAVAILABLE; + } + + RefPtr factory = CreateFactory(); + return factory ? factory->QueryInterface(aIid, aResult) : E_OUTOFMEMORY; +} + +STDAPI DllCanUnloadNow() { return S_OK; } + +// These functions enable us to run "regsvr32 [/u] TestShellEx.dll" manually. +// (No admin privilege is needed because all access is under HKCU.) +// We don't use these functions in the mochitest, but having these makes easier +// to test the module manually. +STDAPI DllRegisterServer() { + ComRegisterer reg(CLSID_TestShellEx, kFriendlyName); + if (!reg.RegisterObject(L"Apartment") || !reg.RegisterExtensions()) { + return E_ACCESSDENIED; + } + return S_OK; +} +STDAPI DllUnregisterServer() { + ComRegisterer reg(CLSID_TestShellEx, kFriendlyName); + if (!reg.UnregisterAll()) { + return E_ACCESSDENIED; + } + return S_OK; +} -- cgit v1.2.3