diff options
Diffstat (limited to 'toolkit/xre')
-rw-r--r-- | toolkit/xre/moz.build | 58 | ||||
-rw-r--r-- | toolkit/xre/nsAndroidStartup.cpp | 45 | ||||
-rw-r--r-- | toolkit/xre/nsAppRunner.cpp | 25 | ||||
-rw-r--r-- | toolkit/xre/nsEmbedFunctions.cpp | 8 | ||||
-rw-r--r-- | toolkit/xre/nsSigHandlers.cpp | 6 | ||||
-rw-r--r-- | toolkit/xre/nsUpdateDriver.cpp | 2 | ||||
-rw-r--r-- | toolkit/xre/nsXREDirProvider.cpp | 13 | ||||
-rw-r--r-- | toolkit/xre/test/.eslintrc.js | 7 | ||||
-rw-r--r-- | toolkit/xre/test/browser.ini | 4 | ||||
-rw-r--r-- | toolkit/xre/test/browser_checkdllblockliststate.js | 16 | ||||
-rw-r--r-- | toolkit/xre/test/mochitest.ini | 3 | ||||
-rw-r--r-- | toolkit/xre/test/test_fpuhandler.html | 38 | ||||
-rw-r--r-- | toolkit/xre/test/win/Makefile.in | 14 | ||||
-rw-r--r-- | toolkit/xre/test/win/TestDllInterceptor.cpp | 232 | ||||
-rw-r--r-- | toolkit/xre/test/win/TestXREMakeCommandLineWin.cpp | 265 | ||||
-rw-r--r-- | toolkit/xre/test/win/TestXREMakeCommandLineWin.ini | 94 | ||||
-rw-r--r-- | toolkit/xre/test/win/moz.build | 30 |
17 files changed, 21 insertions, 839 deletions
diff --git a/toolkit/xre/moz.build b/toolkit/xre/moz.build index 072bd9ff9..4ad9926a8 100644 --- a/toolkit/xre/moz.build +++ b/toolkit/xre/moz.build @@ -4,15 +4,7 @@ # 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/. -if CONFIG['OS_ARCH'] == 'WINNT': - TEST_DIRS += ['test/win'] - -MOCHITEST_MANIFESTS += ['test/mochitest.ini'] -BROWSER_CHROME_MANIFESTS += ['test/browser.ini'] - -XPIDL_SOURCES += [ - 'nsINativeAppSupport.idl', -] +XPIDL_SOURCES += ['nsINativeAppSupport.idl'] if CONFIG['OS_ARCH'] == 'WINNT': XPIDL_SOURCES += [ @@ -27,9 +19,7 @@ if CONFIG['MOZ_INSTRUMENT_EVENT_LOOP']: EXPORTS += ['EventTracer.h'] if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows': - UNIFIED_SOURCES += [ - 'nsNativeAppSupportWin.cpp', - ] + UNIFIED_SOURCES += ['nsNativeAppSupportWin.cpp'] elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa': UNIFIED_SOURCES += [ 'MacApplicationDelegate.mm', @@ -45,29 +35,16 @@ elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'uikit': 'UIKitDirProvider.mm', ] elif 'gtk' in CONFIG['MOZ_WIDGET_TOOLKIT']: - UNIFIED_SOURCES += [ - 'nsNativeAppSupportUnix.cpp', - ] + UNIFIED_SOURCES += ['nsNativeAppSupportUnix.cpp'] else: - UNIFIED_SOURCES += [ - 'nsNativeAppSupportDefault.cpp', - ] + UNIFIED_SOURCES += ['nsNativeAppSupportDefault.cpp'] if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gtk3': - UNIFIED_SOURCES += [ - 'nsGDKErrorHandler.cpp', - ] + UNIFIED_SOURCES += ['nsGDKErrorHandler.cpp'] if CONFIG['MOZ_X11']: EXPORTS += ['nsX11ErrorHandler.h'] - UNIFIED_SOURCES += [ - 'nsX11ErrorHandler.cpp', - ] - -if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android': - UNIFIED_SOURCES += [ - 'nsAndroidStartup.cpp', - ] + UNIFIED_SOURCES += ['nsX11ErrorHandler.cpp'] UNIFIED_SOURCES += [ 'CreateAppData.cpp', @@ -97,10 +74,10 @@ if CONFIG['MOZ_INSTRUMENT_EVENT_LOOP']: ] if CONFIG['MOZ_UPDATER']: - if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'android': - UNIFIED_SOURCES += [ - 'nsUpdateDriver.cpp', - ] + DEFINES['MOZ_UPDATER'] = True + UNIFIED_SOURCES += [ + 'nsUpdateDriver.cpp', + ] include('/ipc/chromium/chromium-config.mozbuild') @@ -109,21 +86,18 @@ FINAL_LIBRARY = 'xul' if CONFIG['MOZ_GL_DEFAULT_PROVIDER'] == 'GLX': DEFINES['USE_GLX_TEST'] = True -for var in ('MOZ_APP_NAME', 'MOZ_APP_BASENAME', 'MOZ_APP_VERSION', 'OS_TARGET', +for var in ('MOZ_APP_NAME', + 'MOZ_APP_BASENAME', + 'MOZ_APP_VERSION', + 'OS_TARGET', 'MOZ_WIDGET_TOOLKIT'): DEFINES[var] = '"%s"' % CONFIG[var] -if CONFIG['MOZ_UPDATER'] and CONFIG['MOZ_WIDGET_TOOLKIT'] != 'android': - DEFINES['MOZ_UPDATER'] = True - if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows': DEFINES['WIN32_LEAN_AND_MEAN'] = True DEFINES['UNICODE'] = True DEFINES['_UNICODE'] = True -if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android': - DEFINES['ANDROID_PACKAGE_NAME'] = '"%s"' % CONFIG['ANDROID_PACKAGE_NAME'] - if CONFIG['TARGET_XPCOM_ABI']: DEFINES['TARGET_OS_ABI'] = '"%s_%s"' % (CONFIG['OS_TARGET'], CONFIG['TARGET_XPCOM_ABI']) @@ -167,9 +141,7 @@ if 'gtk' in CONFIG['MOZ_WIDGET_TOOLKIT']: CXXFLAGS += CONFIG['MOZ_PANGO_CFLAGS'] DEFINES['TOPOBJDIR'] = TOPOBJDIR -FINAL_TARGET_PP_FILES += [ - 'platform.ini' -] +FINAL_TARGET_PP_FILES += ['platform.ini'] if CONFIG['GNU_CXX']: CXXFLAGS += ['-Wno-error=shadow'] diff --git a/toolkit/xre/nsAndroidStartup.cpp b/toolkit/xre/nsAndroidStartup.cpp deleted file mode 100644 index 68ad75c01..000000000 --- a/toolkit/xre/nsAndroidStartup.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * 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 <android/log.h> - -#include <jni.h> - -#include <stdlib.h> -#include <string.h> -#include <pthread.h> - -#include "mozilla/jni/Utils.h" -#include "nsTArray.h" -#include "nsString.h" -#include "nsIFile.h" -#include "nsAppRunner.h" -#include "APKOpen.h" - -#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, MOZ_APP_NAME, args) - -extern "C" NS_EXPORT void -GeckoStart(JNIEnv* env, char* data, const nsXREAppData* appData) -{ - mozilla::jni::SetGeckoThreadEnv(env); - - if (!data) { - LOG("Failed to get arguments for GeckoStart\n"); - return; - } - - nsTArray<char *> targs; - char *arg = strtok(data, " "); - while (arg) { - targs.AppendElement(arg); - arg = strtok(nullptr, " "); - } - targs.AppendElement(static_cast<char *>(nullptr)); - - int result = XRE_main(targs.Length() - 1, targs.Elements(), appData, 0); - - if (result) - LOG("XRE_main returned %d", result); -} diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp index d8f95c2a8..e3705a5c2 100644 --- a/toolkit/xre/nsAppRunner.cpp +++ b/toolkit/xre/nsAppRunner.cpp @@ -23,7 +23,7 @@ #include "nsAppRunner.h" #include "mozilla/AppData.h" -#if defined(MOZ_UPDATER) && !defined(MOZ_WIDGET_ANDROID) +#ifdef MOZ_UPDATER #include "nsUpdateDriver.h" #endif #include "ProfileReset.h" @@ -186,10 +186,6 @@ #include "base/command_line.h" #include "GTestRunner.h" -#ifdef MOZ_WIDGET_ANDROID -#include "GeneratedJNIWrappers.h" -#endif - extern uint32_t gRestartMode; extern void InstallSignalHandlers(const char *ProgramName); @@ -1517,9 +1513,6 @@ static nsresult LaunchChild(nsINativeAppSupport* aNative, SaveToEnv("MOZ_LAUNCHED_CHILD=1"); -#if defined(MOZ_WIDGET_ANDROID) - java::GeckoAppShell::ScheduleRestart(); -#else #if defined(XP_MACOSX) CommandLineServiceMac::SetupMacCommandLine(gRestartArgc, gRestartArgv, true); LaunchChildMac(gRestartArgc, gRestartArgv); @@ -1559,7 +1552,6 @@ static nsresult LaunchChild(nsINativeAppSupport* aNative, #endif // XP_UNIX #endif // WP_WIN #endif // WP_MACOSX -#endif // MOZ_WIDGET_ANDROID return NS_ERROR_LAUNCHED_CHILD_PROCESS; } @@ -1653,10 +1645,7 @@ ProfileLockedDialog(nsIFile* aProfileDir, nsIFile* aProfileLocalDir, if (aUnlocker) { int32_t button; -#ifdef MOZ_WIDGET_ANDROID - java::GeckoAppShell::KillAnyZombies(); - button = 0; -#else + const uint32_t flags = (nsIPromptService::BUTTON_TITLE_IS_STRING * nsIPromptService::BUTTON_POS_0) + @@ -1668,7 +1657,6 @@ ProfileLockedDialog(nsIFile* aProfileDir, nsIFile* aProfileLocalDir, killTitle, nullptr, nullptr, nullptr, &checkState, &button); NS_ENSURE_SUCCESS_LOG(rv, rv); -#endif if (button == 0) { rv = aUnlocker->Unlock(nsIProfileUnlocker::FORCE_QUIT); @@ -1682,15 +1670,8 @@ ProfileLockedDialog(nsIFile* aProfileDir, nsIFile* aProfileLocalDir, return LaunchChild(aNative); } } else { -#ifdef MOZ_WIDGET_ANDROID - if (java::GeckoAppShell::UnlockProfile()) { - return NS_LockProfilePath(aProfileDir, aProfileLocalDir, - nullptr, aResult); - } -#else rv = ps->Alert(nullptr, killTitle, killMessage); NS_ENSURE_SUCCESS_LOG(rv, rv); -#endif } return NS_ERROR_ABORT; @@ -3409,7 +3390,7 @@ XREMain::XRE_mainStartup(bool* aExitFlag) } #endif -#if defined(MOZ_UPDATER) && !defined(MOZ_WIDGET_ANDROID) +#ifdef MOZ_UPDATER // Check for and process any available updates nsCOMPtr<nsIFile> updRoot; bool persistent; diff --git a/toolkit/xre/nsEmbedFunctions.cpp b/toolkit/xre/nsEmbedFunctions.cpp index 52b443770..f0a8d9cab 100644 --- a/toolkit/xre/nsEmbedFunctions.cpp +++ b/toolkit/xre/nsEmbedFunctions.cpp @@ -246,17 +246,9 @@ XRE_InitChildProcess(int aArgc, NS_ENSURE_ARG_POINTER(aArgv[0]); MOZ_ASSERT(aChildData); -#if !defined(MOZ_WIDGET_ANDROID) // On non-Fennec Gecko, the GMPLoader code resides in plugin-container, // and we must forward it through to the GMP code here. GMPProcessChild::SetGMPLoader(aChildData->gmpLoader.get()); -#else - // On Fennec, the GMPLoader's code resides inside XUL (because for the time - // being GMPLoader relies upon NSPR, which we can't use in plugin-container - // on Android), so we create it here inside XUL and pass it to the GMP code. - UniquePtr<GMPLoader> loader = CreateGMPLoader(nullptr); - GMPProcessChild::SetGMPLoader(loader.get()); -#endif #if defined(XP_WIN) // From the --attach-console support in nsNativeAppSupportWin.cpp, but diff --git a/toolkit/xre/nsSigHandlers.cpp b/toolkit/xre/nsSigHandlers.cpp index 660af4522..11648e45a 100644 --- a/toolkit/xre/nsSigHandlers.cpp +++ b/toolkit/xre/nsSigHandlers.cpp @@ -27,9 +27,7 @@ #include <unistd.h> #include <stdlib.h> // atoi #include <sys/prctl.h> -#ifndef ANDROID // no Android impl -# include <ucontext.h> -#endif +#include <ucontext.h> #endif #ifdef XP_SOLARIS @@ -172,7 +170,7 @@ static void fpehandler(int signum, siginfo_t *si, void *context) *mxcsr &= ~SSE_STATUS_FLAGS; /* clear all pending SSE exceptions */ #endif #endif -#if defined(LINUX) && !defined(ANDROID) +#if defined(LINUX) ucontext_t *uc = (ucontext_t *)context; #if defined(__i386__) diff --git a/toolkit/xre/nsUpdateDriver.cpp b/toolkit/xre/nsUpdateDriver.cpp index be11fb158..499445885 100644 --- a/toolkit/xre/nsUpdateDriver.cpp +++ b/toolkit/xre/nsUpdateDriver.cpp @@ -333,7 +333,7 @@ CopyUpdaterIntoUpdateDir(nsIFile *greDir, nsIFile *appDir, nsIFile *updateDir, return false; CopyFileIntoUpdateDir(appDir, NS_LITERAL_CSTRING(UPDATER_INI), updateDir); #endif -#if defined(XP_UNIX) && !defined(XP_MACOSX) && !defined(ANDROID) +#if defined(XP_UNIX) && !defined(XP_MACOSX) nsCOMPtr<nsIFile> iconDir; appDir->Clone(getter_AddRefs(iconDir)); iconDir->AppendNative(NS_LITERAL_CSTRING("icons")); diff --git a/toolkit/xre/nsXREDirProvider.cpp b/toolkit/xre/nsXREDirProvider.cpp index 265652477..151eb34e5 100644 --- a/toolkit/xre/nsXREDirProvider.cpp +++ b/toolkit/xre/nsXREDirProvider.cpp @@ -1340,10 +1340,6 @@ nsXREDirProvider::GetUserDataDirectoryHome(nsIFile** aFile, bool aLocal) if (!homeDir || !*homeDir) return NS_ERROR_FAILURE; -#ifdef ANDROID /* We want (ProfD == ProfLD) on Android. */ - aLocal = false; -#endif - if (aLocal) { // If $XDG_CACHE_HOME is defined use it, otherwise use $HOME/.cache. const char* cacheHome = getenv("XDG_CACHE_HOME"); @@ -1550,15 +1546,6 @@ nsXREDirProvider::AppendProfilePath(nsIFile* aFile, } NS_ENSURE_SUCCESS(rv, rv); -#elif defined(ANDROID) - // The directory used for storing profiles - // The parent of this directory is set in GetUserDataDirectoryHome - // XXX: handle gAppData->profile properly - // XXXsmaug ...and the rest of the profile creation! - MOZ_ASSERT(!aAppName, - "Profile creation for external applications is not implemented!"); - rv = aFile->AppendNative(nsDependentCString("mozilla")); - NS_ENSURE_SUCCESS(rv, rv); #elif defined(XP_UNIX) nsAutoCString folder; // Make it hidden (by starting with "."), except when local (the diff --git a/toolkit/xre/test/.eslintrc.js b/toolkit/xre/test/.eslintrc.js deleted file mode 100644 index e3134a291..000000000 --- a/toolkit/xre/test/.eslintrc.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict"; - -module.exports = { - "extends": [ - "../../../testing/mochitest/mochitest.eslintrc.js" - ] -}; diff --git a/toolkit/xre/test/browser.ini b/toolkit/xre/test/browser.ini deleted file mode 100644 index deadebc46..000000000 --- a/toolkit/xre/test/browser.ini +++ /dev/null @@ -1,4 +0,0 @@ -[DEFAULT] - -[browser_checkdllblockliststate.js] -skip-if = os != "win" diff --git a/toolkit/xre/test/browser_checkdllblockliststate.js b/toolkit/xre/test/browser_checkdllblockliststate.js deleted file mode 100644 index 6b989c370..000000000 --- a/toolkit/xre/test/browser_checkdllblockliststate.js +++ /dev/null @@ -1,16 +0,0 @@ -// Any copyright is dedicated to the Public Domain. -// http://creativecommons.org/publicdomain/zero/1.0/ - -// Tests that the dll blocklist initializes correctly during test runs. -add_task(function* test() { - yield BrowserTestUtils.withNewTab({gBrowser, url: "about:blank" }, function* (browser) { - ok(Components.classes["@mozilla.org/xre/app-info;1"] - .getService(Ci.nsIXULRuntime) - .windowsDLLBlocklistStatus, - "Windows dll blocklist status should be true, indicating it is " + - "running properly. A failure in this test is considered a " + - "release blocker."); - }); -}); - - diff --git a/toolkit/xre/test/mochitest.ini b/toolkit/xre/test/mochitest.ini deleted file mode 100644 index ccbb08ed9..000000000 --- a/toolkit/xre/test/mochitest.ini +++ /dev/null @@ -1,3 +0,0 @@ -[DEFAULT] - -[test_fpuhandler.html] diff --git a/toolkit/xre/test/test_fpuhandler.html b/toolkit/xre/test/test_fpuhandler.html deleted file mode 100644 index afe70ee64..000000000 --- a/toolkit/xre/test/test_fpuhandler.html +++ /dev/null @@ -1,38 +0,0 @@ -<head> - <title>Floating-point exception handler test</title> - <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> - -<body onload="runTest()"> - <embed id="plugin1" type="application/x-test" width="400" height="400"></embed> - - <script class="testbody" type="application/javascript"> - SimpleTest.waitForExplicitFinish(); - - function doDiv(x, y) { - var z; - z = x / y; - - for (i = 0 + x; i < 1000; ++i) - z = y / x; - - z = x / y; - return z; - } - - function runTest() - { - ok(isNaN(doDiv(0.0, 0.0)), "Undefined division-by-zero doesn't crash"); - - try { - document.getElementById('plugin1').enableFPExceptions(); - } - catch (e) { - ok(true, "No special code to set the FPU bit in the testplugin."); - SimpleTest.finish(); - return; - } - - ok(isNaN(doDiv(0.0, 0.0)), "Undefined division-by-zero doesn't crash again."); - SimpleTest.finish(); - } - </script> diff --git a/toolkit/xre/test/win/Makefile.in b/toolkit/xre/test/win/Makefile.in deleted file mode 100644 index 331a8a4fd..000000000 --- a/toolkit/xre/test/win/Makefile.in +++ /dev/null @@ -1,14 +0,0 @@ -# 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/. - -MOZ_WINCONSOLE = 1 - -include $(topsrcdir)/config/rules.mk - -libs:: TestXREMakeCommandLineWin.ini - $(INSTALL) $^ $(FINAL_TARGET)/ - -check:: - @echo 'Running TestXREMakeCommandLineWin tests' - @$(RUN_TEST_PROGRAM) $(FINAL_TARGET)/TestXREMakeCommandLineWin.exe diff --git a/toolkit/xre/test/win/TestDllInterceptor.cpp b/toolkit/xre/test/win/TestDllInterceptor.cpp deleted file mode 100644 index 57d68ea77..000000000 --- a/toolkit/xre/test/win/TestDllInterceptor.cpp +++ /dev/null @@ -1,232 +0,0 @@ -/* 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 <shlobj.h> -#include <stdio.h> - -#include "mozilla/WindowsVersion.h" -#include "nsWindowsDllInterceptor.h" -#include "nsWindowsHelpers.h" - -using namespace mozilla; - -struct payload { - UINT64 a; - UINT64 b; - UINT64 c; - - bool operator==(const payload &other) const { - return (a == other.a && - b == other.b && - c == other.c); - } -}; - -extern "C" __declspec(dllexport) __declspec(noinline) payload rotatePayload(payload p) { - UINT64 tmp = p.a; - p.a = p.b; - p.b = p.c; - p.c = tmp; - return p; -} - -static bool patched_func_called = false; - -static payload (*orig_rotatePayload)(payload); - -static payload -patched_rotatePayload(payload p) -{ - patched_func_called = true; - return orig_rotatePayload(p); -} - -bool TestHook(const char *dll, const char *func) -{ - void *orig_func; - bool successful = false; - { - WindowsDllInterceptor TestIntercept; - TestIntercept.Init(dll); - successful = TestIntercept.AddHook(func, 0, &orig_func); - } - - if (successful) { - printf("TEST-PASS | WindowsDllInterceptor | Could hook %s from %s\n", func, dll); - return true; - } else { - printf("TEST-UNEXPECTED-FAIL | WindowsDllInterceptor | Failed to hook %s from %s\n", func, dll); - return false; - } -} - -bool TestDetour(const char *dll, const char *func) -{ - void *orig_func; - bool successful = false; - { - WindowsDllInterceptor TestIntercept; - TestIntercept.Init(dll); - successful = TestIntercept.AddDetour(func, 0, &orig_func); - } - - if (successful) { - printf("TEST-PASS | WindowsDllInterceptor | Could detour %s from %s\n", func, dll); - return true; - } else { - printf("TEST-UNEXPECTED-FAIL | WindowsDllInterceptor | Failed to detour %s from %s\n", func, dll); - return false; - } -} - -bool MaybeTestHook(const bool cond, const char* dll, const char* func) -{ - if (!cond) { - return true; - } - - return TestHook(dll, func); -} - -bool ShouldTestTipTsf() -{ -#if defined(_M_X64) - return false; -#else - if (!IsWin8OrLater()) { - return false; - } - - nsModuleHandle shell32(LoadLibraryW(L"shell32.dll")); - if (!shell32) { - return true; - } - - auto pSHGetKnownFolderPath = reinterpret_cast<decltype(&SHGetKnownFolderPath)>(GetProcAddress(shell32, "SHGetKnownFolderPath")); - if (!pSHGetKnownFolderPath) { - return true; - } - - PWSTR commonFilesPath = nullptr; - if (FAILED(pSHGetKnownFolderPath(FOLDERID_ProgramFilesCommon, 0, nullptr, - &commonFilesPath))) { - return true; - } - - wchar_t fullPath[MAX_PATH + 1] = {}; - wcscpy(fullPath, commonFilesPath); - wcscat(fullPath, L"\\Microsoft Shared\\Ink\\tiptsf.dll"); - CoTaskMemFree(commonFilesPath); - - if (!LoadLibraryW(fullPath)) { - return false; - } - - // Leak the module so that it's loaded for the interceptor test - return true; -#endif -} - -int main() -{ - payload initial = { 0x12345678, 0xfc4e9d31, 0x87654321 }; - payload p0, p1; - ZeroMemory(&p0, sizeof(p0)); - ZeroMemory(&p1, sizeof(p1)); - - p0 = rotatePayload(initial); - - { - WindowsDllInterceptor ExeIntercept; - ExeIntercept.Init("TestDllInterceptor.exe"); - if (ExeIntercept.AddHook("rotatePayload", reinterpret_cast<intptr_t>(patched_rotatePayload), (void**) &orig_rotatePayload)) { - printf("TEST-PASS | WindowsDllInterceptor | Hook added\n"); - } else { - printf("TEST-UNEXPECTED-FAIL | WindowsDllInterceptor | Failed to add hook\n"); - return 1; - } - - p1 = rotatePayload(initial); - - if (patched_func_called) { - printf("TEST-PASS | WindowsDllInterceptor | Hook called\n"); - } else { - printf("TEST-UNEXPECTED-FAIL | WindowsDllInterceptor | Hook was not called\n"); - return 1; - } - - if (p0 == p1) { - printf("TEST-PASS | WindowsDllInterceptor | Hook works properly\n"); - } else { - printf("TEST-UNEXPECTED-FAIL | WindowsDllInterceptor | Hook didn't return the right information\n"); - return 1; - } - } - - patched_func_called = false; - ZeroMemory(&p1, sizeof(p1)); - - p1 = rotatePayload(initial); - - if (!patched_func_called) { - printf("TEST-PASS | WindowsDllInterceptor | Hook was not called after unregistration\n"); - } else { - printf("TEST-UNEXPECTED-FAIL | WindowsDllInterceptor | Hook was still called after unregistration\n"); - return 1; - } - - if (p0 == p1) { - printf("TEST-PASS | WindowsDllInterceptor | Original function worked properly\n"); - } else { - printf("TEST-UNEXPECTED-FAIL | WindowsDllInterceptor | Original function didn't return the right information\n"); - return 1; - } - - if (TestHook("user32.dll", "GetWindowInfo") && -#ifdef _WIN64 - TestHook("user32.dll", "SetWindowLongPtrA") && - TestHook("user32.dll", "SetWindowLongPtrW") && -#else - TestHook("user32.dll", "SetWindowLongA") && - TestHook("user32.dll", "SetWindowLongW") && -#endif - TestHook("user32.dll", "TrackPopupMenu") && -#ifdef _M_IX86 - // We keep this test to hook complex code on x86. (Bug 850957) - TestHook("ntdll.dll", "NtFlushBuffersFile") && -#endif - TestHook("ntdll.dll", "NtCreateFile") && - TestHook("ntdll.dll", "NtReadFile") && - TestHook("ntdll.dll", "NtReadFileScatter") && - TestHook("ntdll.dll", "NtWriteFile") && - TestHook("ntdll.dll", "NtWriteFileGather") && - TestHook("ntdll.dll", "NtQueryFullAttributesFile") && - // Bug 733892: toolkit/crashreporter/nsExceptionHandler.cpp - TestHook("kernel32.dll", "SetUnhandledExceptionFilter") && -#ifdef _M_IX86 - // Bug 670967: xpcom/base/AvailableMemoryTracker.cpp - TestHook("kernel32.dll", "VirtualAlloc") && - TestHook("kernel32.dll", "MapViewOfFile") && - TestHook("gdi32.dll", "CreateDIBSection") && - TestHook("kernel32.dll", "CreateFileW") && -#endif - TestDetour("user32.dll", "CreateWindowExW") && - TestHook("user32.dll", "InSendMessageEx") && - TestHook("imm32.dll", "ImmGetContext") && - TestHook("imm32.dll", "ImmGetCompositionStringW") && - TestHook("imm32.dll", "ImmSetCandidateWindow") && -#ifdef _M_X64 - TestHook("user32.dll", "GetKeyState") && -#endif - MaybeTestHook(ShouldTestTipTsf(), "tiptsf.dll", "ProcessCaretEvents") && -#ifdef _M_IX86 - TestHook("user32.dll", "SendMessageTimeoutW") && -#endif - TestDetour("ntdll.dll", "LdrLoadDll")) { - printf("TEST-PASS | WindowsDllInterceptor | all checks passed\n"); - return 0; - } - - return 1; -} diff --git a/toolkit/xre/test/win/TestXREMakeCommandLineWin.cpp b/toolkit/xre/test/win/TestXREMakeCommandLineWin.cpp deleted file mode 100644 index 00d786aa2..000000000 --- a/toolkit/xre/test/win/TestXREMakeCommandLineWin.cpp +++ /dev/null @@ -1,265 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* 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 <stdio.h> -#include <stdlib.h> -#include <windows.h> -// Support for _setmode -#include <fcntl.h> -#include <io.h> - -#include "nsWindowsRestart.cpp" - -// CommandLineToArgvW may return different values for argv[0] since it contains -// the path to the binary that was executed so we prepend an argument that is -// quoted with a space to prevent argv[1] being appended to argv[0]. -#define DUMMY_ARG1 L"\"arg 1\" " - -#ifndef MAXPATHLEN -# ifdef PATH_MAX -# define MAXPATHLEN PATH_MAX -# elif defined(MAX_PATH) -# define MAXPATHLEN MAX_PATH -# elif defined(_MAX_PATH) -# define MAXPATHLEN _MAX_PATH -# elif defined(CCHMAXPATH) -# define MAXPATHLEN CCHMAXPATH -# else -# define MAXPATHLEN 1024 -# endif -#endif - -#define TEST_NAME L"XRE MakeCommandLine" -#define MAX_TESTS 100 - -// Verbose output can be enabled by defining VERBOSE 1 -#define VERBOSE 0 - -// Compares compareCmdLine with the output of MakeCommandLine. This is -// accomplished by converting inCmdLine to an argument list with -// CommandLineToArgvW and converting it back to a command line with -// MakeCommandLine. -static int -verifyCmdLineCreation(wchar_t *inCmdLine, - wchar_t *compareCmdLine, - bool passes, int testNum) -{ - int rv = 0; - int i; - int inArgc; - int outArgc; - bool isEqual; - - // When debugging with command lines containing Unicode characters greater - // than 255 you can set the mode for stdout to Unicode so the console will - // receive the correct characters though it won't display them properly unless - // the console's font has been set to one that can display the characters. You - // can also redirect the console output to a file that has been saved as Unicode - // to view the characters. -// _setmode(_fileno(stdout), _O_WTEXT); - - // Prepend an additional argument to the command line. CommandLineToArgvW - // handles argv[0] differently than other arguments since argv[0] is the path - // to the binary being executed and MakeCommandLine only handles argv[1] and - // larger. - wchar_t *inCmdLineNew = (wchar_t *) malloc((wcslen(DUMMY_ARG1) + wcslen(inCmdLine) + 1) * sizeof(wchar_t)); - wcscpy(inCmdLineNew, DUMMY_ARG1); - wcscat(inCmdLineNew, inCmdLine); - LPWSTR *inArgv = CommandLineToArgvW(inCmdLineNew, &inArgc); - - wchar_t *outCmdLine = MakeCommandLine(inArgc - 1, inArgv + 1); - wchar_t *outCmdLineNew = (wchar_t *) malloc((wcslen(DUMMY_ARG1) + wcslen(outCmdLine) + 1) * sizeof(wchar_t)); - wcscpy(outCmdLineNew, DUMMY_ARG1); - wcscat(outCmdLineNew, outCmdLine); - LPWSTR *outArgv = CommandLineToArgvW(outCmdLineNew, &outArgc); - - if (VERBOSE) { - wprintf(L"\n"); - wprintf(L"Verbose Output\n"); - wprintf(L"--------------\n"); - wprintf(L"Input command line : >%s<\n", inCmdLine); - wprintf(L"MakeComandLine output: >%s<\n", outCmdLine); - wprintf(L"Expected command line: >%s<\n", compareCmdLine); - - wprintf(L"input argc : %d\n", inArgc - 1); - wprintf(L"output argc: %d\n", outArgc - 1); - - for (i = 1; i < inArgc; ++i) { - wprintf(L"input argv[%d] : >%s<\n", i - 1, inArgv[i]); - } - - for (i = 1; i < outArgc; ++i) { - wprintf(L"output argv[%d]: >%s<\n", i - 1, outArgv[i]); - } - wprintf(L"\n"); - } - - isEqual = (inArgc == outArgc); - if (!isEqual) { - wprintf(L"TEST-%s-FAIL | %s | ARGC Comparison (check %2d)\n", - passes ? L"UNEXPECTED" : L"KNOWN", TEST_NAME, testNum); - if (passes) { - rv = 1; - } - LocalFree(inArgv); - LocalFree(outArgv); - free(inCmdLineNew); - free(outCmdLineNew); - free(outCmdLine); - return rv; - } - - for (i = 1; i < inArgc; ++i) { - isEqual = (wcscmp(inArgv[i], outArgv[i]) == 0); - if (!isEqual) { - wprintf(L"TEST-%s-FAIL | %s | ARGV Comparison (check %2d)\n", - passes ? L"UNEXPECTED" : L"KNOWN", TEST_NAME, testNum); - if (passes) { - rv = 1; - } - LocalFree(inArgv); - LocalFree(outArgv); - free(inCmdLineNew); - free(outCmdLineNew); - free(outCmdLine); - return rv; - } - } - - isEqual = (wcscmp(outCmdLine, compareCmdLine) == 0); - if (!isEqual) { - wprintf(L"TEST-%s-FAIL | %s | Command Line Comparison (check %2d)\n", - passes ? L"UNEXPECTED" : L"KNOWN", TEST_NAME, testNum); - if (passes) { - rv = 1; - } - LocalFree(inArgv); - LocalFree(outArgv); - free(inCmdLineNew); - free(outCmdLineNew); - free(outCmdLine); - return rv; - } - - if (rv == 0) { - if (passes) { - wprintf(L"TEST-PASS | %s | check %2d\n", TEST_NAME, testNum); - } else { - wprintf(L"TEST-UNEXPECTED-PASS | %s | check %2d\n", TEST_NAME, testNum); - rv = 1; - } - } - - LocalFree(inArgv); - LocalFree(outArgv); - free(inCmdLineNew); - free(outCmdLineNew); - free(outCmdLine); - return rv; -} - -int wmain(int argc, wchar_t *argv[]) -{ - int i; - int rv = 0; - - if (argc > 1 && (_wcsicmp(argv[1], L"-check-one") != 0 || argc != 3)) { - fwprintf(stderr, L"Displays and validates output from MakeCommandLine.\n\n"); - fwprintf(stderr, L"Usage: %s -check-one <test number>\n\n", argv[0]); - fwprintf(stderr, L" <test number>\tSpecifies the test number to run from the\n"); - fwprintf(stderr, L"\t\tTestXREMakeCommandLineWin.ini file.\n"); - return 255; - } - - wchar_t inifile[MAXPATHLEN]; - if (!::GetModuleFileNameW(0, inifile, MAXPATHLEN)) { - wprintf(L"TEST-UNEXPECTED-FAIL | %s | GetModuleFileNameW\n", TEST_NAME); - return 2; - } - - WCHAR *slash = wcsrchr(inifile, '\\'); - if (!slash) { - wprintf(L"TEST-UNEXPECTED-FAIL | %s | wcsrchr\n", TEST_NAME); - return 3; - } - - wcscpy(slash + 1, L"TestXREMakeCommandLineWin.ini\0"); - - for (i = 0; i < MAX_TESTS; ++i) { - wchar_t sInputVal[MAXPATHLEN]; - wchar_t sOutputVal[MAXPATHLEN]; - wchar_t sPassesVal[MAXPATHLEN]; - wchar_t sInputKey[MAXPATHLEN]; - wchar_t sOutputKey[MAXPATHLEN]; - wchar_t sPassesKey[MAXPATHLEN]; - - if (argc > 2 && _wcsicmp(argv[1], L"-check-one") == 0 && argc == 3) { - i = _wtoi(argv[2]); - } - - _snwprintf(sInputKey, MAXPATHLEN, L"input_%d", i); - _snwprintf(sOutputKey, MAXPATHLEN, L"output_%d", i); - _snwprintf(sPassesKey, MAXPATHLEN, L"passes_%d", i); - - if (!GetPrivateProfileStringW(L"MakeCommandLineTests", sInputKey, nullptr, - sInputVal, MAXPATHLEN, inifile)) { - if (i == 0 || (argc > 2 && _wcsicmp(argv[1], L"-check-one") == 0)) { - wprintf(L"TEST-UNEXPECTED-FAIL | %s | see following explanation:\n", TEST_NAME); - wprintf(L"ERROR: Either the TestXREMakeCommandLineWin.ini file doesn't exist\n"); - if (argc > 1 && _wcsicmp(argv[1], L"-check-one") == 0 && argc == 3) { - wprintf(L"ERROR: or the test is not defined in the MakeCommandLineTests section.\n"); - } else { - wprintf(L"ERROR: or it has no tests defined in the MakeCommandLineTests section.\n"); - } - wprintf(L"ERROR: File: %s\n", inifile); - return 4; - } - break; - } - - GetPrivateProfileStringW(L"MakeCommandLineTests", sOutputKey, nullptr, - sOutputVal, MAXPATHLEN, inifile); - GetPrivateProfileStringW(L"MakeCommandLineTests", sPassesKey, nullptr, - sPassesVal, MAXPATHLEN, inifile); - - rv |= verifyCmdLineCreation(sInputVal, sOutputVal, - (_wcsicmp(sPassesVal, L"false") == 0) ? FALSE : TRUE, - i); - - if (argc > 2 && _wcsicmp(argv[1], L"-check-one") == 0) { - break; - } - } - - if (rv == 0) { - wprintf(L"TEST-PASS | %s | all checks passed\n", TEST_NAME); - } else { - wprintf(L"TEST-UNEXPECTED-FAIL | %s | some checks failed\n", TEST_NAME); - } - - return rv; -} - -#ifdef __MINGW32__ - -/* MingW currently does not implement a wide version of the - startup routines. Workaround is to implement something like - it ourselves. See bug 411826 */ - -#include <shellapi.h> - -int main(int argc, char **argv) -{ - LPWSTR commandLine = GetCommandLineW(); - int argcw = 0; - LPWSTR *argvw = CommandLineToArgvW(commandLine, &argcw); - if (!argvw) - return 127; - - int result = wmain(argcw, argvw); - LocalFree(argvw); - return result; -} -#endif /* __MINGW32__ */ diff --git a/toolkit/xre/test/win/TestXREMakeCommandLineWin.ini b/toolkit/xre/test/win/TestXREMakeCommandLineWin.ini deleted file mode 100644 index dbb529d1b..000000000 --- a/toolkit/xre/test/win/TestXREMakeCommandLineWin.ini +++ /dev/null @@ -1,94 +0,0 @@ -; A typical MakeCommandLine test will contain an input and an output name value -; pair. The value for input_xx is the input command line and the value for -; output_xx is the expected output command line. -; -; A test that is known to fail can be added as follows. If the passes_xx name -; value pair doesn't exist it defaults to true. -; input_99=yabadaba -; output_99=doo -; passes_99=false -; -; If a value starts and ends with single or double quotation marks then it must -; be enclosed in single or double quotation marks due to GetPrivateProfileString -; discarding the outmost quotation marks. See GetPrivateProfileString on MSDN -; for more information. -; http://msdn.microsoft.com/en-us/library/ms724353.aspx - -[MakeCommandLineTests] -input_0=a:\ -output_0=a:\ - -input_1=""a:\"" -output_1=a:\" - -input_2=""a:\b c"" -output_2=""a:\b c"" - -input_3=""a:\b c\"" -output_3=""a:\b c\""" - -input_4=""a:\b c\d e"" -output_4=""a:\b c\d e"" - -input_5=""a:\b c\d e\"" -output_5=""a:\b c\d e\""" - -input_6=""a:\\"" -output_6=a:\ - -input_7="a:\" "b:\c d" -output_7=a:\" "b:\c d" - -input_8="a "b:\" "c:\d e"" -output_8="a "b:\" c:\d" e" - -input_9="abc" d e -output_9=abc d e - -input_10="a b c" d e -output_10="a b c" d e - -input_11=a\\\b d"e f"g h -output_11=a\\\b "de fg" h - -input_12=a b -output_12=a b - -input_13=""a b"" -output_13=""a b"" - -input_14=a\\\"b c d -output_14=a\\\"b c d - -input_15=a\\\"b c" -output_15=a\\\"b c - -input_16=""a\\\b c" -output_16=""a\\\b c"" - -input_17=\"a -output_17=\"a - -input_18=\\"a -output_18=\a - -input_19=\\"\\\\"a -output_19=\\\a - -input_20=\\"\\\\\"a -output_20=\\\\\\\"a - -input_21="a\\\"b c\" d e -output_21=""a\\\"b c\" d e"" - -input_22=a\\\\\"b c" d e" -output_22=a\\\\\"b "c d e" - -input_23=a:\b c\アルファ オメガ\d -output_23=a:\b c\アルファ オメガ\d - -input_24=a:\b "c\アルファ オメガ\d" -output_24=a:\b "c\アルファ オメガ\d" - -input_25=アルファ オメガ -output_25=アルファ オメガ diff --git a/toolkit/xre/test/win/moz.build b/toolkit/xre/test/win/moz.build deleted file mode 100644 index 51ad0bcb3..000000000 --- a/toolkit/xre/test/win/moz.build +++ /dev/null @@ -1,30 +0,0 @@ -# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- -# vim: set filetype=python: -# 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/. - -SimplePrograms([ - 'TestXREMakeCommandLineWin', -]) - -CppUnitTests([ - 'TestDllInterceptor', -]) - -DEFINES['NS_NO_XPCOM'] = True - -LOCAL_INCLUDES += [ - '/config', - '/toolkit/xre', -] - -DISABLE_STL_WRAPPING = True -USE_STATIC_LIBS = True - -OS_LIBS += [ - 'comctl32', - 'ole32', - 'shell32', - 'ws2_32', -] |