Retire ATK nodes without accessing freed children or retaining dangling parent and ID pointers. Treat failed and malformed MSAA state queries as protected, and initialize worker logging before argument validation. Add publisher lifetime and worker privacy regressions, correct the publisher build target dependency, and remove both browser artifacts during uninstall. Validation: build, all 12 CTests, updated startup-error regression, AddressSanitizer lifetime check, shellcheck, and temporary-prefix removal check passed. Live speech and Braille acceptance remains separate.
76 lines
2.9 KiB
C++
76 lines
2.9 KiB
C++
// SPDX-License-Identifier: LGPL-2.1-or-later
|
|
#define wmain browser_worker_main
|
|
#include "../../browser_worker.cpp"
|
|
#undef wmain
|
|
#include <cassert>
|
|
|
|
class StateProvider : public IAccessible {
|
|
public:
|
|
HRESULT result = S_OK;
|
|
VARTYPE type = VT_I4;
|
|
LONG state = 0;
|
|
int valueCalls = 0;
|
|
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID, void **out) override { *out = nullptr; return E_NOINTERFACE; }
|
|
ULONG STDMETHODCALLTYPE AddRef() override { return 1; }
|
|
ULONG STDMETHODCALLTYPE Release() override { return 1; }
|
|
HRESULT STDMETHODCALLTYPE get_accState(VARIANT, VARIANT *out) override {
|
|
out->vt = type;
|
|
out->lVal = state;
|
|
return result;
|
|
}
|
|
HRESULT STDMETHODCALLTYPE get_accValue(VARIANT, BSTR *out) override {
|
|
++valueCalls;
|
|
*out = SysAllocString(L"private sentinel");
|
|
return S_OK;
|
|
}
|
|
#define STUB(name, args) HRESULT STDMETHODCALLTYPE name args override { return E_NOTIMPL; }
|
|
STUB(GetTypeInfoCount, (UINT *))
|
|
STUB(GetTypeInfo, (UINT, LCID, ITypeInfo **))
|
|
STUB(GetIDsOfNames, (REFIID, LPOLESTR *, UINT, LCID, DISPID *))
|
|
STUB(Invoke, (DISPID, REFIID, LCID, WORD, DISPPARAMS *, VARIANT *, EXCEPINFO *, UINT *))
|
|
STUB(get_accParent, (IDispatch **))
|
|
STUB(get_accChildCount, (long *))
|
|
STUB(get_accChild, (VARIANT, IDispatch **))
|
|
STUB(get_accName, (VARIANT, BSTR *))
|
|
STUB(get_accDescription, (VARIANT, BSTR *))
|
|
STUB(get_accRole, (VARIANT, VARIANT *))
|
|
STUB(get_accHelp, (VARIANT, BSTR *))
|
|
STUB(get_accHelpTopic, (BSTR *, VARIANT, long *))
|
|
STUB(get_accKeyboardShortcut, (VARIANT, BSTR *))
|
|
STUB(get_accFocus, (VARIANT *))
|
|
STUB(get_accSelection, (VARIANT *))
|
|
STUB(get_accDefaultAction, (VARIANT, BSTR *))
|
|
STUB(accSelect, (long, VARIANT))
|
|
STUB(accLocation, (long *, long *, long *, long *, VARIANT))
|
|
STUB(accNavigate, (long, VARIANT, VARIANT *))
|
|
STUB(accHitTest, (long, long, VARIANT *))
|
|
STUB(accDoDefaultAction, (VARIANT))
|
|
STUB(put_accName, (VARIANT, BSTR))
|
|
STUB(put_accValue, (VARIANT, BSTR))
|
|
#undef STUB
|
|
};
|
|
|
|
int main() {
|
|
StateProvider provider;
|
|
for (int scenario = 0; scenario < 5; ++scenario) {
|
|
provider.result = scenario == 0 ? E_FAIL : scenario == 1 ? S_FALSE : S_OK;
|
|
provider.type = scenario == 2 ? VT_EMPTY : VT_I4;
|
|
provider.state = scenario == 3 ? STATE_SYSTEM_PROTECTED : 0;
|
|
provider.valueCalls = 0;
|
|
const bool protectedValue = scenario != 4;
|
|
assert(is_protected(&provider) == protectedValue);
|
|
std::string record;
|
|
node_record(&provider, 0, false, 0, record);
|
|
assert(provider.valueCalls == (protectedValue ? 0 : 1));
|
|
assert((record.find("private sentinel") == std::string::npos) == protectedValue);
|
|
}
|
|
wchar_t program[] = L"worker";
|
|
wchar_t invalid[] = L"--invalid-option";
|
|
wchar_t *arguments[] = {program, invalid};
|
|
assert(browser_worker_main(1, arguments) == 2);
|
|
DeleteCriticalSection(&outputLock);
|
|
assert(browser_worker_main(2, arguments) == 2);
|
|
DeleteCriticalSection(&outputLock);
|
|
return 0;
|
|
}
|