зеркало из https://github.com/mozilla/gecko-dev.git
New files for Killer app on Win32
This commit is contained in:
Родитель
9c545008e5
Коммит
171e857827
|
@ -0,0 +1,97 @@
|
||||||
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||||
|
* The contents of this file are subject to the Mozilla Public
|
||||||
|
* License Version 1.1 (the "License"); you may not use this file
|
||||||
|
* except in compliance with the License. You may obtain a copy of
|
||||||
|
* the License at http://www.mozilla.org/MPL/
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS
|
||||||
|
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||||
|
* implied. See the License for the specific language governing
|
||||||
|
* rights and limitations under the License.
|
||||||
|
*
|
||||||
|
* The Original Code is mozilla.org code.
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||||
|
* Inc. Portions created by Sun are
|
||||||
|
* Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||||
|
* Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
*/
|
||||||
|
//cl killer.cpp /link user32.lib
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
|
//Define keywords to determine Assertion window
|
||||||
|
#define ASSERTION_DIALOG_KW_1 "nsDebug"
|
||||||
|
#define ASSERTION_DIALOG_KW_2 "Assertion"
|
||||||
|
|
||||||
|
//Define keywords to determine ERROR window
|
||||||
|
#define ERROR_DIALOG_KW_1 "mozilla"
|
||||||
|
#define ERROR_DIALOG_KW_2 "Error"
|
||||||
|
|
||||||
|
|
||||||
|
#define IGNORE_BUTTON_TITLE "&Ignore"
|
||||||
|
#define IGNORE_BUTTON_ID 5
|
||||||
|
|
||||||
|
#define OK_BUTTON_TITLE "OK"
|
||||||
|
#define OK_BUTTON_ID 1
|
||||||
|
|
||||||
|
BOOL CALLBACK EnumChildProc(HWND hwnd, LPARAM out) {
|
||||||
|
char title[1024];
|
||||||
|
GetWindowText(hwnd, title, 1024);
|
||||||
|
//printf("--Child Window: %x -> %s\n", hwnd, title);
|
||||||
|
if ((!strcmp(title, OK_BUTTON_TITLE))||(!strcmp(title, IGNORE_BUTTON_TITLE))) {
|
||||||
|
//printf("Found window: %x -> %s\n", hwnd, title);
|
||||||
|
*((HWND*)out) = hwnd;
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL CALLBACK EnumWindowsProc( HWND hwnd, LPARAM lParam) {
|
||||||
|
char title[1024];
|
||||||
|
GetWindowText(hwnd, title, 1024);
|
||||||
|
//printf("++Window: %x -> %s\n", hwnd, title);
|
||||||
|
if (strstr(title, ERROR_DIALOG_KW_1) && strstr(title, ERROR_DIALOG_KW_2)) {
|
||||||
|
printf("Found Error window:\\\\%s// /n",title);
|
||||||
|
DWORD lp = 0, wp = 0;
|
||||||
|
HWND ok;
|
||||||
|
//really we can ommit this step but ...
|
||||||
|
EnumChildWindows(hwnd, EnumChildProc, (LPARAM)(&ok));
|
||||||
|
if (!ok) {
|
||||||
|
printf("OK button not found !\n");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
lp = (unsigned long)ok;
|
||||||
|
wp = OK_BUTTON_ID;
|
||||||
|
wp = wp | (BN_CLICKED << 16);
|
||||||
|
//printf("COMMAND: %d (hwnd), %d (code), %d(id)\n", lp, HIWORD(wp), LOWORD(wp));
|
||||||
|
SendMessage(hwnd, WM_COMMAND, wp, lp);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
if (strstr(title, ASSERTION_DIALOG_KW_1) && strstr(title, ASSERTION_DIALOG_KW_2)) {
|
||||||
|
printf("Found Assertion window:\\\\%s// /n",title);
|
||||||
|
DWORD lp = 0, wp = 0;
|
||||||
|
HWND ok;
|
||||||
|
//really we can ommit this step but ...
|
||||||
|
EnumChildWindows(hwnd, EnumChildProc, (LPARAM)(&ok));
|
||||||
|
if (!ok) {
|
||||||
|
printf("OK button not found !\n");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
lp = (unsigned long)ok;
|
||||||
|
wp = IGNORE_BUTTON_ID;
|
||||||
|
wp = wp | (BN_CLICKED << 16);
|
||||||
|
//printf("COMMAND: %d (hwnd), %d (code), %d(id)\n", lp, HIWORD(wp), LOWORD(wp));
|
||||||
|
SendMessage(hwnd, WM_COMMAND, wp, lp);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
EnumWindows(EnumWindowsProc, 0);
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
Killer README.
|
||||||
|
|
||||||
|
This tool is derived from OJI API tests Killer.
|
||||||
|
|
||||||
|
Usually used to help Mozilla to die in abnormal situations.
|
||||||
|
|
||||||
|
Two types of dialog windows processed:
|
||||||
|
|
||||||
|
1. Assertion dialogs(with 3 buttons: "Abort","Retry","Ignore"):
|
||||||
|
- A "Ignore" button automatically pressed to continue working
|
||||||
|
2. Error dialogs(with 2 buttons: "OK","Cancel")
|
||||||
|
- A "OK" button automatically pressed to forse Mozilla's termination
|
|
@ -0,0 +1,32 @@
|
||||||
|
#!nmake
|
||||||
|
#
|
||||||
|
# The contents of this file are subject to the Mozilla Public
|
||||||
|
# License Version 1.1 (the "License"); you may not use this file
|
||||||
|
# except in compliance with the License. You may obtain a copy of
|
||||||
|
# the License at http://www.mozilla.org/MPL/
|
||||||
|
#
|
||||||
|
# Software distributed under the License is distributed on an "AS
|
||||||
|
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||||
|
# implied. See the License for the specific language governing
|
||||||
|
# rights and limitations under the License.
|
||||||
|
#
|
||||||
|
# The Original Code is mozilla.org code.
|
||||||
|
#
|
||||||
|
# The Initial Developer of the Original Code is Sun Microsystems,
|
||||||
|
# Inc. Portions created by Sun are
|
||||||
|
# Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||||
|
# Rights Reserved.
|
||||||
|
#
|
||||||
|
# Contributor(s):
|
||||||
|
|
||||||
|
SRC=Killer.cpp
|
||||||
|
FLAGS=/link user32.lib
|
||||||
|
DEPTH=../..
|
||||||
|
EXE=Killer.exe
|
||||||
|
|
||||||
|
build:
|
||||||
|
@cl $(SRC) $(FLAGS)
|
||||||
|
install: build
|
||||||
|
@copy $(EXE) $(DEPTH)\utils
|
||||||
|
clean:
|
||||||
|
@-del Killer.exe Killer.obj
|
Загрузка…
Ссылка в новой задаче