зеркало из https://github.com/mozilla/pjs.git
A webclient/classes_spec/org/mozilla/mcp/package.html
- package description for MCP M dist/build.xml - copy ancilliary files for javadoc A dist/javadoc.css - Stylesheet for code samples within Javadocs M dist/netbeans/build.xml - Use releasenotes for test browesr start page M dom/jni/Makefile.in M dom/src/Makefile.in M webclient/src_moz/Makefile.in M webclient/src_share/Makefile.in - FORCE_PR_LOG M dom/jni/javaDOMEventsGlobals.cpp M dom/jni/nativeDOMProxyListener.cpp M dom/jni/org_mozilla_dom_events_MouseEventImpl.cpp - use nsCOMPtr and correct QI-ing. M webclient/classes_spec/org/mozilla/mcp/MCP.java - Javadocs - Make private things private A webclient/classes_spec/org/mozilla/mcp/mcp.jpg - Master Control Program M webclient/classes_spec/org/mozilla/webclient/WebclientFactory.java - javadocs
This commit is contained in:
Родитель
22d14fdbd8
Коммит
ee3d686eea
|
@ -259,9 +259,18 @@
|
|||
<target name="build.javadocs" depends="prepare,uptodate"
|
||||
unless="javadocs.uptodate"
|
||||
description="Create the JavaDoc API documentation">
|
||||
<copy todir="${dist.javadocs}">
|
||||
<fileset dir="${source.home}/webclient/classes_spec">
|
||||
<include name="**/*.jpg" />
|
||||
<include name="**/*.jpeg" />
|
||||
<include name="**/*.gif" />
|
||||
<include name="**/*.html" />
|
||||
</fileset>
|
||||
</copy>
|
||||
<javadoc packagenames="org.mozilla.*"
|
||||
destdir="${dist.javadocs}"
|
||||
Overview="${source.home}/webclient/classes_spec/org/mozilla/webclient/overview.html"
|
||||
stylesheetfile="javadoc.css"
|
||||
private="${javadoc.private}"
|
||||
protected="${javadoc.protected}"
|
||||
windowtitle="${Name} (${version})"
|
||||
|
@ -270,6 +279,8 @@
|
|||
<fileset dir="${source.home}">
|
||||
<include name="**/*.java"/>
|
||||
<exclude name="**/impl/**/*.java" />
|
||||
<exclude name="**/*ICE*.java" />
|
||||
<exclude name="**/cardemo/**/*.java" />
|
||||
<exclude name="**/wrapper_nonnative/**/*.java" />
|
||||
<exclude name="**/*Impl.java" />
|
||||
<exclude name="**/test*/**/*.java" />
|
||||
|
@ -279,7 +290,14 @@
|
|||
<exclude name="pluggable-jvm/**/*.*" />
|
||||
<exclude name="**/*Bookmark*.java" />
|
||||
<exclude name="**/*Preferences*.java" />
|
||||
<exclude name="**/PrefChangedCallback.java" />
|
||||
<exclude name="**/*Profile*.java" />
|
||||
<exclude name="**/WebclientFactory.java" />
|
||||
<exclude name="**/ImplObject.java" />
|
||||
<exclude name="**/WCKeyEvent.java" />
|
||||
<exclude name="**/WCMouseEvent.java" />
|
||||
<exclude name="util/**/*.java" />
|
||||
<exclude name="dom/**/*.java" />
|
||||
</fileset>
|
||||
<classpath location="${dist.jar}"/>
|
||||
</javadoc>
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
/* GeSHi (c) Nigel McNie 2004 (http://qbnz.com/highlighter) */
|
||||
.java .de1, .java .de2 {font-family: 'Courier New', Courier, monospace; font-weight: normal;}
|
||||
.java {font-family: monospace;}
|
||||
.java .imp {font-weight: bold; color: red;}
|
||||
.java li {background: #ffffff;}
|
||||
.java li.li2 {background: #f4f4f4;}
|
||||
.java .kw1 {color: #b1b100;}
|
||||
.java .kw2 {color: #000000; font-weight: bold;}
|
||||
.java .kw3 {color: #aaaadd; font-weight: bold;}
|
||||
.java .kw4 {color: #993333;}
|
||||
.java .co1 {color: #808080; font-style: italic;}
|
||||
.java .co2 {color: #a1a100;}
|
||||
.java .coMULTI {color: #808080; font-style: italic;}
|
||||
.java .es0 {color: #000099; font-weight: bold;}
|
||||
.java .br0 {color: #66cc66;}
|
||||
.java .st0 {color: #ff0000;}
|
||||
.java .nu0 {color: #cc66cc;}
|
||||
.java .me1 {color: #006600;}
|
||||
.java .me2 {color: #006600;}
|
|
@ -209,6 +209,8 @@ ${so.prefix}xul.${so.extension}.
|
|||
<target name="run" depends="-init-check">
|
||||
|
||||
<property name="debug.jvm.args" value="" />
|
||||
<property name="test.browser.url"
|
||||
value="${basedir}/../2_0_alpha_6.html" />
|
||||
|
||||
<java classname="org.mozilla.webclient.test.TestBrowser" fork="true">
|
||||
<jvmarg value="-DNSPR_LOG_MODULES=webclient:4,webclientstub:4,pluglets:4"/>
|
||||
|
@ -218,6 +220,7 @@ ${so.prefix}xul.${so.extension}.
|
|||
<jvmarg line="${debug.jvm.args}"/>
|
||||
<jvmarg line="-Djava.util.logging.config.file=${basedir}${FILE_PATH_SEP}logging.properties"/>
|
||||
<jvmarg line="-Djava.library.path=${browser.bin.dir}" />
|
||||
<arg value="${test.browser.url}" />
|
||||
|
||||
|
||||
<classpath>
|
||||
|
|
|
@ -77,7 +77,7 @@ EXTRA_LIBS += \
|
|||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
DEFINES += -DMOZILLA_INTERNAL_API
|
||||
DEFINES += -DMOZILLA_INTERNAL_API -DFORCE_PR_LOG
|
||||
|
||||
ifeq ($(OS_ARCH),Darwin)
|
||||
INCLUDES += -I$(MOZ_JDKHOME)/include
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
#include "nsIDOMEvent.h"
|
||||
#include "nsIDOMUIEvent.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
jclass JavaDOMEventsGlobals::eventClass = NULL;
|
||||
jclass JavaDOMEventsGlobals::uiEventClass = NULL;
|
||||
jclass JavaDOMEventsGlobals::eventListenerClass = NULL;
|
||||
|
@ -47,6 +49,9 @@ static NS_DEFINE_IID(kIDOMUIEventIID, NS_IDOMUIEVENT_IID);
|
|||
|
||||
void JavaDOMEventsGlobals::Initialize(JNIEnv *env)
|
||||
{
|
||||
PR_LOG(JavaDOMGlobals::log, PR_LOG_DEBUG,
|
||||
("JavaDOMEventsGlobals::Initialize: Beginning initialization"));
|
||||
|
||||
eventClass = env->FindClass("org/mozilla/dom/events/EventImpl");
|
||||
if (!eventClass) {
|
||||
JavaDOMGlobals::ThrowException(env, "Class org.mozilla.dom.events.EventImpl not found");
|
||||
|
@ -116,6 +121,10 @@ void JavaDOMEventsGlobals::Initialize(JNIEnv *env)
|
|||
mouseEventClass = (jclass) env->NewGlobalRef(mouseEventClass);
|
||||
if (!mouseEventClass)
|
||||
return;
|
||||
|
||||
PR_LOG(JavaDOMGlobals::log, PR_LOG_DEBUG,
|
||||
("JavaDOMEventsGlobals::Initialize: Completed Successfully"));
|
||||
|
||||
}
|
||||
|
||||
void JavaDOMEventsGlobals::Destroy(JNIEnv *env)
|
||||
|
@ -175,19 +184,18 @@ static jboolean isEventOfType(const char* const* types, nsString &type)
|
|||
}
|
||||
|
||||
jobject JavaDOMEventsGlobals::CreateEventSubtype(JNIEnv *env,
|
||||
nsIDOMEvent *event)
|
||||
nsIDOMEvent *eventIn)
|
||||
{
|
||||
jobject jevent;
|
||||
jclass clazz = eventClass;
|
||||
nsISupports *isupports;
|
||||
void *target;
|
||||
nsCOMPtr<nsIDOMEvent> event = eventIn;
|
||||
nsCOMPtr<nsIDOMUIEvent> uiEvent;
|
||||
nsresult rv;
|
||||
|
||||
isupports = (nsISupports *) event;
|
||||
|
||||
uiEvent = do_QueryInterface(event, &rv);
|
||||
|
||||
//check whenever our Event is UIEvent
|
||||
rv = isupports->QueryInterface(kIDOMUIEventIID, (void **) &target);
|
||||
if (!NS_FAILED(rv) && target) {
|
||||
if (NS_SUCCEEDED(rv) && uiEvent) {
|
||||
// At the moment DOM2 draft specifies set of UIEvent subclasses
|
||||
// However Mozilla still presents these events as nsUIEvent
|
||||
// So we need a cludge to determine proper java class to be created
|
||||
|
@ -232,8 +240,6 @@ jobject JavaDOMEventsGlobals::CreateEventSubtype(JNIEnv *env,
|
|||
clazz = uiEventClass;
|
||||
}
|
||||
|
||||
event->Release();
|
||||
event = (nsIDOMEvent *) target;
|
||||
}
|
||||
|
||||
PR_LOG(JavaDOMGlobals::log, PR_LOG_WARNING,
|
||||
|
@ -247,14 +253,13 @@ jobject JavaDOMEventsGlobals::CreateEventSubtype(JNIEnv *env,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
env->SetLongField(jevent, eventPtrFID, (jlong) event);
|
||||
env->SetLongField(jevent, eventPtrFID, (jlong) event.get());
|
||||
if (env->ExceptionOccurred()) {
|
||||
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
|
||||
("JavaDOMEventGlobals::CreateEventSubtype: failed to set native ptr %x\n",
|
||||
(jlong) event));
|
||||
(jlong) event.get()));
|
||||
return NULL;
|
||||
}
|
||||
event->AddRef();
|
||||
|
||||
return jevent;
|
||||
}
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
#include"nsIDOMEventListener.h"
|
||||
#include"javaDOMEventsGlobals.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kIDOMEventListener, NS_IDOMEVENTLISTENER_IID);
|
||||
|
||||
|
@ -59,10 +61,11 @@ NativeDOMProxyListener::~NativeDOMProxyListener()
|
|||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP NativeDOMProxyListener::HandleEvent(nsIDOMEvent* aEvent)
|
||||
NS_IMETHODIMP NativeDOMProxyListener::HandleEvent(nsIDOMEvent* aEventIn)
|
||||
{
|
||||
jobject jevent;
|
||||
JNIEnv *env;
|
||||
nsCOMPtr<nsIDOMEvent> aEvent = aEventIn;
|
||||
|
||||
if (vm->AttachCurrentThread(&env, NULL) != 0) {
|
||||
PR_LOG(JavaDOMGlobals::log, PR_LOG_WARNING,
|
||||
|
@ -78,10 +81,17 @@ NS_IMETHODIMP NativeDOMProxyListener::HandleEvent(nsIDOMEvent* aEvent)
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
PR_LOG(JavaDOMGlobals::log, PR_LOG_WARNING,
|
||||
("NativeDOMProxyListener::HandleEvent About to call into java.\n listener: %p\n eventListenerHandleEventMID: %p\n jevent: %p\n", listener, JavaDOMEventsGlobals::eventListenerHandleEventMID, jevent));
|
||||
|
||||
env->CallVoidMethod(listener,
|
||||
JavaDOMEventsGlobals::eventListenerHandleEventMID,
|
||||
jevent);
|
||||
|
||||
PR_LOG(JavaDOMGlobals::log, PR_LOG_WARNING,
|
||||
("NativeDOMProxyListener::HandleEvent returned from java"));
|
||||
|
||||
|
||||
if (env->ExceptionOccurred()) {
|
||||
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
|
||||
("NativeDOMProxyListener::HandleEvent: failed to call EventListener %x\n",
|
||||
|
|
|
@ -21,11 +21,15 @@
|
|||
|
||||
#include "prlog.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOMEvent.h"
|
||||
#include "nsIDOMMouseEvent.h"
|
||||
#include "nsIDOMEventTarget.h"
|
||||
#include "javaDOMEventsGlobals.h"
|
||||
#include "org_mozilla_dom_events_MouseEventImpl.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_dom_events_MouseEventImpl
|
||||
* Method: getAltKey
|
||||
|
@ -34,21 +38,28 @@
|
|||
JNIEXPORT jboolean JNICALL Java_org_mozilla_dom_events_MouseEventImpl_nativeGetAltKey
|
||||
(JNIEnv *env, jobject jthis)
|
||||
{
|
||||
nsIDOMMouseEvent* event = (nsIDOMMouseEvent*)
|
||||
env->GetLongField(jthis, JavaDOMEventsGlobals::eventPtrFID);
|
||||
if (!event) {
|
||||
nsresult rv = NS_OK;
|
||||
nsIDOMEvent *eventPtr = (nsIDOMEvent*)
|
||||
env->GetLongField(jthis, JavaDOMEventsGlobals::eventPtrFID);
|
||||
nsCOMPtr<nsIDOMMouseEvent> event = do_QueryInterface(eventPtr, &rv);
|
||||
|
||||
if (!event || NS_FAILED(rv)) {
|
||||
PR_LOG(JavaDOMGlobals::log, PR_LOG_DEBUG,
|
||||
("MouseEventImpl::nativeGetAltKey: cannot QI to nsIDOMMouseEvent from nsIDOMEvent"));
|
||||
JavaDOMGlobals::ThrowException(env,
|
||||
"MouseEvent.getAltKey: NULL pointer");
|
||||
"MouseEvent.getAltKey: NULL pointer");
|
||||
return JNI_FALSE;
|
||||
}
|
||||
|
||||
PRBool altKey = PR_FALSE;
|
||||
nsresult rv = event->GetAltKey(&altKey);
|
||||
rv = event->GetAltKey(&altKey);
|
||||
if (NS_FAILED(rv)) {
|
||||
JavaDOMGlobals::ThrowException(env,
|
||||
"MouseEvent.getAltKey: failed", rv);
|
||||
return JNI_FALSE;
|
||||
}
|
||||
PR_LOG(JavaDOMGlobals::log, PR_LOG_DEBUG,
|
||||
("MouseEventImpl::nativeGetAltKey: result: %d", altKey));
|
||||
|
||||
return (altKey == PR_TRUE) ? JNI_TRUE : JNI_FALSE;
|
||||
|
||||
|
@ -63,21 +74,28 @@ JNIEXPORT jboolean JNICALL Java_org_mozilla_dom_events_MouseEventImpl_nativeGetA
|
|||
JNIEXPORT jshort JNICALL Java_org_mozilla_dom_events_MouseEventImpl_nativeGetButton
|
||||
(JNIEnv *env, jobject jthis)
|
||||
{
|
||||
nsIDOMMouseEvent* event = (nsIDOMMouseEvent*)
|
||||
env->GetLongField(jthis, JavaDOMEventsGlobals::eventPtrFID);
|
||||
if (!event) {
|
||||
nsresult rv = NS_OK;
|
||||
nsIDOMEvent *eventPtr = (nsIDOMEvent*)
|
||||
env->GetLongField(jthis, JavaDOMEventsGlobals::eventPtrFID);
|
||||
nsCOMPtr<nsIDOMMouseEvent> event = do_QueryInterface(eventPtr, &rv);
|
||||
|
||||
if (!event || NS_FAILED(rv)) {
|
||||
PR_LOG(JavaDOMGlobals::log, PR_LOG_DEBUG,
|
||||
("MouseEventImpl::nativeGetButton: cannot QI to nsIDOMMouseEvent from nsIDOMEvent"));
|
||||
JavaDOMGlobals::ThrowException(env,
|
||||
"MouseEvent.getButton: NULL pointer");
|
||||
return 0;
|
||||
}
|
||||
|
||||
PRUint16 code = 0;
|
||||
nsresult rv = event->GetButton(&code);
|
||||
rv = event->GetButton(&code);
|
||||
if (NS_FAILED(rv)) {
|
||||
JavaDOMGlobals::ThrowException(env,
|
||||
"MouseEvent.getButton: failed", rv);
|
||||
return 0;
|
||||
}
|
||||
PR_LOG(JavaDOMGlobals::log, PR_LOG_DEBUG,
|
||||
("MouseEventImpl::nativeGetButton: result: %d", code));
|
||||
|
||||
return (jshort) code;
|
||||
}
|
||||
|
@ -90,21 +108,28 @@ JNIEXPORT jshort JNICALL Java_org_mozilla_dom_events_MouseEventImpl_nativeGetBut
|
|||
JNIEXPORT jint JNICALL Java_org_mozilla_dom_events_MouseEventImpl_nativeGetClientX
|
||||
(JNIEnv *env, jobject jthis)
|
||||
{
|
||||
nsIDOMMouseEvent* event = (nsIDOMMouseEvent*)
|
||||
env->GetLongField(jthis, JavaDOMEventsGlobals::eventPtrFID);
|
||||
if (!event) {
|
||||
nsresult rv = NS_OK;
|
||||
nsIDOMEvent *eventPtr = (nsIDOMEvent*)
|
||||
env->GetLongField(jthis, JavaDOMEventsGlobals::eventPtrFID);
|
||||
nsCOMPtr<nsIDOMMouseEvent> event = do_QueryInterface(eventPtr, &rv);
|
||||
|
||||
if (!event || NS_FAILED(rv)) {
|
||||
PR_LOG(JavaDOMGlobals::log, PR_LOG_DEBUG,
|
||||
("MouseEventImpl::nativeGetClientX: cannot QI to nsIDOMMouseEvent from nsIDOMEvent"));
|
||||
JavaDOMGlobals::ThrowException(env,
|
||||
"MouseEvent.getClientX: NULL pointer");
|
||||
return 0;
|
||||
return JNI_FALSE;
|
||||
}
|
||||
|
||||
PRInt32 clientX = 0;
|
||||
nsresult rv = event->GetClientX(&clientX);
|
||||
rv = event->GetClientX(&clientX);
|
||||
if (NS_FAILED(rv)) {
|
||||
JavaDOMGlobals::ThrowException(env,
|
||||
"MouseEvent.getClientX: failed", rv);
|
||||
return 0;
|
||||
}
|
||||
PR_LOG(JavaDOMGlobals::log, PR_LOG_DEBUG,
|
||||
("MouseEventImpl::nativeGetClientX: result: %d", clientX));
|
||||
|
||||
return (jint) clientX;
|
||||
}
|
||||
|
@ -117,21 +142,28 @@ JNIEXPORT jint JNICALL Java_org_mozilla_dom_events_MouseEventImpl_nativeGetClien
|
|||
JNIEXPORT jint JNICALL Java_org_mozilla_dom_events_MouseEventImpl_nativeGetClientY
|
||||
(JNIEnv *env, jobject jthis)
|
||||
{
|
||||
nsIDOMMouseEvent* event = (nsIDOMMouseEvent*)
|
||||
env->GetLongField(jthis, JavaDOMEventsGlobals::eventPtrFID);
|
||||
if (!event) {
|
||||
nsresult rv = NS_OK;
|
||||
nsIDOMEvent *eventPtr = (nsIDOMEvent*)
|
||||
env->GetLongField(jthis, JavaDOMEventsGlobals::eventPtrFID);
|
||||
nsCOMPtr<nsIDOMMouseEvent> event = do_QueryInterface(eventPtr, &rv);
|
||||
|
||||
if (!event || NS_FAILED(rv)) {
|
||||
PR_LOG(JavaDOMGlobals::log, PR_LOG_DEBUG,
|
||||
("MouseEventImpl::nativeGetClientY: cannot QI to nsIDOMMouseEvent from nsIDOMEvent"));
|
||||
JavaDOMGlobals::ThrowException(env,
|
||||
"MouseEvent.getClientY: NULL pointer");
|
||||
return 0;
|
||||
return JNI_FALSE;
|
||||
}
|
||||
|
||||
PRInt32 clientY = 0;
|
||||
nsresult rv = event->GetClientY(&clientY);
|
||||
rv = event->GetClientY(&clientY);
|
||||
if (NS_FAILED(rv)) {
|
||||
JavaDOMGlobals::ThrowException(env,
|
||||
"MouseEvent.getClientY: failed", rv);
|
||||
return 0;
|
||||
}
|
||||
PR_LOG(JavaDOMGlobals::log, PR_LOG_DEBUG,
|
||||
("MouseEventImpl::nativeGetClientY: result: %d", clientY));
|
||||
|
||||
return (jint) clientY;
|
||||
}
|
||||
|
@ -145,21 +177,28 @@ JNIEXPORT jint JNICALL Java_org_mozilla_dom_events_MouseEventImpl_nativeGetClien
|
|||
JNIEXPORT jboolean JNICALL Java_org_mozilla_dom_events_MouseEventImpl_nativeGetCtrlKey
|
||||
(JNIEnv *env, jobject jthis)
|
||||
{
|
||||
nsIDOMMouseEvent* event = (nsIDOMMouseEvent*)
|
||||
env->GetLongField(jthis, JavaDOMEventsGlobals::eventPtrFID);
|
||||
if (!event) {
|
||||
nsresult rv = NS_OK;
|
||||
nsIDOMEvent *eventPtr = (nsIDOMEvent*)
|
||||
env->GetLongField(jthis, JavaDOMEventsGlobals::eventPtrFID);
|
||||
nsCOMPtr<nsIDOMMouseEvent> event = do_QueryInterface(eventPtr, &rv);
|
||||
|
||||
if (!event || NS_FAILED(rv)) {
|
||||
PR_LOG(JavaDOMGlobals::log, PR_LOG_DEBUG,
|
||||
("MouseEventImpl::nativeGetCtrlKey: cannot QI to nsIDOMMouseEvent from nsIDOMEvent"));
|
||||
JavaDOMGlobals::ThrowException(env,
|
||||
"MouseEvent.getCtrlKey: NULL pointer");
|
||||
return JNI_FALSE;
|
||||
}
|
||||
|
||||
PRBool ctrlKey = PR_FALSE;
|
||||
nsresult rv = event->GetCtrlKey(&ctrlKey);
|
||||
rv = event->GetCtrlKey(&ctrlKey);
|
||||
if (NS_FAILED(rv)) {
|
||||
JavaDOMGlobals::ThrowException(env,
|
||||
"MouseEvent.getCtrlKey: failed", rv);
|
||||
return JNI_FALSE;
|
||||
}
|
||||
PR_LOG(JavaDOMGlobals::log, PR_LOG_DEBUG,
|
||||
("MouseEventImpl::nativeGetCtrlKey: result: %d", ctrlKey));
|
||||
|
||||
return (ctrlKey == PR_TRUE) ? JNI_TRUE : JNI_FALSE;
|
||||
}
|
||||
|
@ -173,21 +212,28 @@ JNIEXPORT jboolean JNICALL Java_org_mozilla_dom_events_MouseEventImpl_nativeGetC
|
|||
JNIEXPORT jboolean JNICALL Java_org_mozilla_dom_events_MouseEventImpl_nativeGetMetaKey
|
||||
(JNIEnv *env, jobject jthis)
|
||||
{
|
||||
nsIDOMMouseEvent* event = (nsIDOMMouseEvent*)
|
||||
env->GetLongField(jthis, JavaDOMEventsGlobals::eventPtrFID);
|
||||
if (!event) {
|
||||
nsresult rv = NS_OK;
|
||||
nsIDOMEvent *eventPtr = (nsIDOMEvent*)
|
||||
env->GetLongField(jthis, JavaDOMEventsGlobals::eventPtrFID);
|
||||
nsCOMPtr<nsIDOMMouseEvent> event = do_QueryInterface(eventPtr, &rv);
|
||||
|
||||
if (!event || NS_FAILED(rv)) {
|
||||
PR_LOG(JavaDOMGlobals::log, PR_LOG_DEBUG,
|
||||
("MouseEventImpl::nativeGetMetaKey: cannot QI to nsIDOMMouseEvent from nsIDOMEvent"));
|
||||
JavaDOMGlobals::ThrowException(env,
|
||||
"MouseEvent.getMetaKey: NULL pointer");
|
||||
return JNI_FALSE;
|
||||
}
|
||||
|
||||
PRBool metaKey = PR_FALSE;
|
||||
nsresult rv = event->GetMetaKey(&metaKey);
|
||||
rv = event->GetMetaKey(&metaKey);
|
||||
if (NS_FAILED(rv)) {
|
||||
JavaDOMGlobals::ThrowException(env,
|
||||
"MouseEvent.getMetaKey: failed", rv);
|
||||
return JNI_FALSE;
|
||||
}
|
||||
PR_LOG(JavaDOMGlobals::log, PR_LOG_DEBUG,
|
||||
("MouseEventImpl::nativeGetMetaKey: result: %d", metaKey));
|
||||
|
||||
return (metaKey == PR_TRUE) ? JNI_TRUE : JNI_FALSE;
|
||||
}
|
||||
|
@ -201,21 +247,28 @@ JNIEXPORT jboolean JNICALL Java_org_mozilla_dom_events_MouseEventImpl_nativeGetM
|
|||
JNIEXPORT jint JNICALL Java_org_mozilla_dom_events_MouseEventImpl_nativeGetScreenX
|
||||
(JNIEnv *env, jobject jthis)
|
||||
{
|
||||
nsIDOMMouseEvent* event = (nsIDOMMouseEvent*)
|
||||
env->GetLongField(jthis, JavaDOMEventsGlobals::eventPtrFID);
|
||||
if (!event) {
|
||||
nsresult rv = NS_OK;
|
||||
nsIDOMEvent *eventPtr = (nsIDOMEvent*)
|
||||
env->GetLongField(jthis, JavaDOMEventsGlobals::eventPtrFID);
|
||||
nsCOMPtr<nsIDOMMouseEvent> event = do_QueryInterface(eventPtr, &rv);
|
||||
|
||||
if (!event || NS_FAILED(rv)) {
|
||||
PR_LOG(JavaDOMGlobals::log, PR_LOG_DEBUG,
|
||||
("MouseEventImpl::nativeGetScreenX: cannot QI to nsIDOMMouseEvent from nsIDOMEvent"));
|
||||
JavaDOMGlobals::ThrowException(env,
|
||||
"MouseEvent.getScreenX: NULL pointer\n");
|
||||
return 0;
|
||||
"MouseEvent.getScreenX: NULL pointer");
|
||||
return JNI_FALSE;
|
||||
}
|
||||
|
||||
PRInt32 screenX = 0;
|
||||
nsresult rv = event->GetScreenX(&screenX);
|
||||
rv = event->GetScreenX(&screenX);
|
||||
if (NS_FAILED(rv)) {
|
||||
JavaDOMGlobals::ThrowException(env,
|
||||
"MouseEvent.getScreenX: failed", rv);
|
||||
return 0;
|
||||
}
|
||||
PR_LOG(JavaDOMGlobals::log, PR_LOG_DEBUG,
|
||||
("MouseEventImpl::nativeGetScreenX: result: %d", screenX));
|
||||
|
||||
return (jint) screenX;
|
||||
}
|
||||
|
@ -228,21 +281,28 @@ JNIEXPORT jint JNICALL Java_org_mozilla_dom_events_MouseEventImpl_nativeGetScree
|
|||
JNIEXPORT jint JNICALL Java_org_mozilla_dom_events_MouseEventImpl_nativeGetScreenY
|
||||
(JNIEnv *env, jobject jthis)
|
||||
{
|
||||
nsIDOMMouseEvent* event = (nsIDOMMouseEvent*)
|
||||
env->GetLongField(jthis, JavaDOMEventsGlobals::eventPtrFID);
|
||||
if (!event) {
|
||||
nsresult rv = NS_OK;
|
||||
nsIDOMEvent *eventPtr = (nsIDOMEvent*)
|
||||
env->GetLongField(jthis, JavaDOMEventsGlobals::eventPtrFID);
|
||||
nsCOMPtr<nsIDOMMouseEvent> event = do_QueryInterface(eventPtr, &rv);
|
||||
|
||||
if (!event || NS_FAILED(rv)) {
|
||||
PR_LOG(JavaDOMGlobals::log, PR_LOG_DEBUG,
|
||||
("MouseEventImpl::nativeGetScreenY: cannot QI to nsIDOMMouseEvent from nsIDOMEvent"));
|
||||
JavaDOMGlobals::ThrowException(env,
|
||||
"MouseEvent.getScreenY: NULL pointer");
|
||||
return 0;
|
||||
return JNI_FALSE;
|
||||
}
|
||||
|
||||
PRInt32 screenY = 0;
|
||||
nsresult rv = event->GetScreenY(&screenY);
|
||||
rv = event->GetScreenY(&screenY);
|
||||
if (NS_FAILED(rv)) {
|
||||
JavaDOMGlobals::ThrowException(env,
|
||||
"MouseEvent.getScreenY: failed", rv);
|
||||
return 0;
|
||||
}
|
||||
PR_LOG(JavaDOMGlobals::log, PR_LOG_DEBUG,
|
||||
("MouseEventImpl::nativeGetScreenY: result: %d", screenY));
|
||||
|
||||
return (jint) screenY;
|
||||
}
|
||||
|
@ -256,8 +316,15 @@ JNIEXPORT jint JNICALL Java_org_mozilla_dom_events_MouseEventImpl_nativeGetScree
|
|||
JNIEXPORT jboolean JNICALL Java_org_mozilla_dom_events_MouseEventImpl_nativeGetShiftKey
|
||||
(JNIEnv *env, jobject jthis)
|
||||
{
|
||||
nsIDOMMouseEvent* event = (nsIDOMMouseEvent*)
|
||||
env->GetLongField(jthis, JavaDOMEventsGlobals::eventPtrFID);
|
||||
nsresult rv = NS_OK;
|
||||
nsIDOMEvent *eventPtr = (nsIDOMEvent*)
|
||||
env->GetLongField(jthis, JavaDOMEventsGlobals::eventPtrFID);
|
||||
PR_LOG(JavaDOMGlobals::log, PR_LOG_DEBUG,
|
||||
("MouseEventImpl::nativeGetShiftKey: eventPtr: %p", eventPtr));
|
||||
nsCOMPtr<nsIDOMMouseEvent> event = do_QueryInterface(eventPtr, &rv);
|
||||
PR_LOG(JavaDOMGlobals::log, PR_LOG_DEBUG,
|
||||
("MouseEventImpl::nativeGetShiftKey: QI nsCOMPtr<nsIDOMMouseEvent> from: %p, rv: %d", eventPtr, rv));
|
||||
|
||||
if (!event) {
|
||||
JavaDOMGlobals::ThrowException(env,
|
||||
"MouseEvent.getShiftKey: NULL pointer");
|
||||
|
@ -265,12 +332,16 @@ JNIEXPORT jboolean JNICALL Java_org_mozilla_dom_events_MouseEventImpl_nativeGetS
|
|||
}
|
||||
|
||||
PRBool shiftKey = PR_FALSE;
|
||||
nsresult rv = event->GetShiftKey(&shiftKey);
|
||||
rv = event->GetShiftKey(&shiftKey);
|
||||
if (NS_FAILED(rv)) {
|
||||
PR_LOG(JavaDOMGlobals::log, PR_LOG_DEBUG,
|
||||
("MouseEventImpl::nativeGetShiftKey: rv: %d", rv));
|
||||
JavaDOMGlobals::ThrowException(env,
|
||||
"MouseEvent.getShiftKey: failed", rv);
|
||||
return JNI_FALSE;
|
||||
}
|
||||
PR_LOG(JavaDOMGlobals::log, PR_LOG_DEBUG,
|
||||
("MouseEventImpl::nativeGetShiftKey: result: %d", shiftKey));
|
||||
|
||||
return (shiftKey == PR_TRUE) ? JNI_TRUE : JNI_FALSE;
|
||||
}
|
||||
|
@ -283,29 +354,51 @@ JNIEXPORT jboolean JNICALL Java_org_mozilla_dom_events_MouseEventImpl_nativeGetS
|
|||
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_events_MouseEventImpl_nativeGetRelatedTarget
|
||||
(JNIEnv *env, jobject jthis)
|
||||
{
|
||||
nsIDOMMouseEvent* event = (nsIDOMMouseEvent*)
|
||||
env->GetLongField(jthis, JavaDOMEventsGlobals::eventPtrFID);
|
||||
if (!event) {
|
||||
JavaDOMGlobals::ThrowException(env,
|
||||
"MouseEvent.getRelatedNode: NULL pointer");
|
||||
return NULL;
|
||||
}
|
||||
nsresult rv = NS_OK;
|
||||
nsIDOMEvent *eventPtr = (nsIDOMEvent*)
|
||||
env->GetLongField(jthis, JavaDOMEventsGlobals::eventPtrFID);
|
||||
nsCOMPtr<nsIDOMMouseEvent> event = do_QueryInterface(eventPtr, &rv);
|
||||
|
||||
nsIDOMEventTarget* ret = nsnull;
|
||||
nsresult rv = event->GetRelatedTarget(&ret);
|
||||
if (NS_FAILED(rv)) {
|
||||
JavaDOMGlobals::ThrowException(env,
|
||||
"MouseEvent.getRelatedNode: failed", rv);
|
||||
return NULL;
|
||||
}
|
||||
if (!ret)
|
||||
return NULL;
|
||||
if (!event || NS_FAILED(rv)) {
|
||||
PR_LOG(JavaDOMGlobals::log, PR_LOG_DEBUG,
|
||||
("MouseEventImpl::getRelatedTarget: cannot QI nsIDOMMouseEvent from nsIDOMEvent"));
|
||||
JavaDOMGlobals::ThrowException(env,
|
||||
"MouseEvent.getRelatedNode: NULL pointer");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMEventTarget> ret = nsnull;
|
||||
rv = event->GetRelatedTarget(getter_AddRefs(ret));
|
||||
if (NS_FAILED(rv)) {
|
||||
PR_LOG(JavaDOMGlobals::log, PR_LOG_DEBUG,
|
||||
("MouseEventImpl::getRelatedTarget: cannot get related target"));
|
||||
|
||||
nsIDOMNode* node = nsnull;
|
||||
rv = ret->QueryInterface(NS_GET_IID(nsIDOMNode), (void**)&node);
|
||||
printf("========== rv:%x node:%x", rv, node);
|
||||
// return JavaDOMGlobals::CreateNodeSubtype(env, ret);
|
||||
return JavaDOMGlobals::CreateNodeSubtype(env, node);
|
||||
JavaDOMGlobals::ThrowException(env,
|
||||
"MouseEvent.getRelatedNode: failed", rv);
|
||||
return NULL;
|
||||
}
|
||||
if (!ret) {
|
||||
PR_LOG(JavaDOMGlobals::log, PR_LOG_DEBUG,
|
||||
("MouseEventImpl::getRelatedTarget: related target is null"));
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMNode> node = nsnull;
|
||||
node = do_QueryInterface(ret, &rv);
|
||||
jobject result = nsnull;
|
||||
if (NS_SUCCEEDED(rv) && node) {
|
||||
result = JavaDOMGlobals::CreateNodeSubtype(env, node);
|
||||
}
|
||||
else {
|
||||
PR_LOG(JavaDOMGlobals::log, PR_LOG_DEBUG,
|
||||
("MouseEventImpl::getRelatedTarget: can't QI nsIDOMNode from nsIDOMEventTarget"));
|
||||
|
||||
}
|
||||
PR_LOG(JavaDOMGlobals::log, PR_LOG_DEBUG,
|
||||
("MouseEventImpl::getRelatedTarget: returning %p", result));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -105,7 +105,7 @@ EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
|||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
DEFINES += -DMOZILLA_INTERNAL_API
|
||||
DEFINES += -DMOZILLA_INTERNAL_API -DFORCE_PR_LOG
|
||||
|
||||
edburns:
|
||||
@echo $(XPCOM_LIBS)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* $Id: MCP.java,v 1.7 2007-03-13 06:21:44 edburns%acm.org Exp $
|
||||
* $Id: MCP.java,v 1.8 2007-03-14 21:02:13 edburns%acm.org Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@ -51,7 +51,10 @@ import org.w3c.dom.Document;
|
|||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
*
|
||||
* <p>The main class for the Mozilla Control Program. Please see <a
|
||||
* href="package-summary.html">the package description</a> for an
|
||||
* overview.</p>
|
||||
|
||||
* @author edburns
|
||||
*/
|
||||
public class MCP {
|
||||
|
@ -60,12 +63,12 @@ public class MCP {
|
|||
public MCP() {
|
||||
}
|
||||
|
||||
public static final String MCP_LOG = "org.mozilla.mcp";
|
||||
public static final String MCP_LOG_STRINGS = "org.mozilla.mcp.MCPLogStrings";
|
||||
private static final String MCP_LOG = "org.mozilla.mcp";
|
||||
private static final String MCP_LOG_STRINGS = "org.mozilla.mcp.MCPLogStrings";
|
||||
|
||||
public static final Logger LOGGER = getLogger(MCP_LOG);
|
||||
private static final Logger LOGGER = getLogger(MCP_LOG);
|
||||
|
||||
static Logger getLogger( String loggerName ) {
|
||||
private static Logger getLogger( String loggerName ) {
|
||||
return Logger.getLogger(loggerName, MCP_LOG_STRINGS );
|
||||
}
|
||||
|
||||
|
@ -212,31 +215,76 @@ public class MCP {
|
|||
}
|
||||
return pageInfoListener;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
* <p>Add the argument <code>AjaxListener</code> to this MCP
|
||||
* instance.</p>
|
||||
|
||||
*/
|
||||
|
||||
public void addAjaxListener(AjaxListener listener) {
|
||||
getEventRegistration().addDocumentLoadListener(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
* <p>Remove the argument <code>AjaxListener</code> to this MCP
|
||||
* instance.</p>
|
||||
|
||||
*/
|
||||
public void removeAjaxListener(AjaxListener listener) {
|
||||
getEventRegistration().removeDocumentLoadListener(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
* <p>Add the argument <code>MouseListener</code> to the
|
||||
* <code>Canvas</code> for this MCP instance.</p>
|
||||
|
||||
*/
|
||||
public void addMouseListener(MouseListener listener) {
|
||||
getBrowserControlCanvas().addMouseListener(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
* <p>Remove the argument <code>MouseListener</code> from the
|
||||
* <code>Canvas</code> for this MCP instance.</p>
|
||||
|
||||
*/
|
||||
public void removeMouseListener(MouseListener listener) {
|
||||
getBrowserControlCanvas().removeMouseListener(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
* <p>Add the argument <code>KeyListener</code> to the
|
||||
* <code>Canvas</code> for this MCP instance.</p>
|
||||
|
||||
*/
|
||||
public void addKeyListener(KeyListener listener) {
|
||||
getBrowserControlCanvas().addKeyListener(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
* <p>Remove the argument <code>KeyListener</code> from the
|
||||
* <code>Canvas</code> for this MCP instance.</p>
|
||||
|
||||
*/
|
||||
public void removeKeyListener(KeyListener listener) {
|
||||
getBrowserControlCanvas().removeKeyListener(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
* <p>Return the Webclient <code>BrowserControl</code> instance used
|
||||
* by this <code>MCP</code> instance. This is useful for operations
|
||||
* that require more complex browser control than that offered by
|
||||
* <code>MCP</code>.</p>
|
||||
|
||||
*/
|
||||
public BrowserControl getBrowserControl() {
|
||||
if (!initialized) {
|
||||
IllegalStateException ise = new IllegalStateException("Not initialized. Call setAppData()");
|
||||
|
@ -264,6 +312,15 @@ public class MCP {
|
|||
}
|
||||
return browserControl;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
* <p>Return the realized and visible <code>java.awt.Frame</code>
|
||||
* containing the actual browser window. There is no need to put
|
||||
* this Frame inside of any surrounding Swing or AWT windows. It is
|
||||
* sufficient to stand alone.</p>
|
||||
|
||||
*/
|
||||
|
||||
public Frame getRealizedVisibleBrowserWindow() {
|
||||
if (null == frame) {
|
||||
|
@ -288,11 +345,50 @@ public class MCP {
|
|||
}
|
||||
return frame;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
* <p>Make invisible, and delete the <code>BrowserControl</code>
|
||||
* instance for this MCP instance. Reset internal state of the
|
||||
* instance so that a subsequent call to {@link
|
||||
* #getRealizedVisibleBrowserWindow} will create a new
|
||||
* <code>Frame</code>.</p>
|
||||
|
||||
*/
|
||||
|
||||
public void deleteBrowserControl() {
|
||||
getRealizedVisibleBrowserWindow().setVisible(false);
|
||||
BrowserControlFactory.deleteBrowserControl(getBrowserControl());
|
||||
browserControl = null;
|
||||
navigation = null;
|
||||
eventRegistration = null;
|
||||
canvas = null;
|
||||
pageInfoListener = null;
|
||||
frame = null;
|
||||
x = 0;
|
||||
y = 0;
|
||||
width = 1280;
|
||||
height = 960;
|
||||
initialized = false;
|
||||
robot = null;
|
||||
treeDumper = null;
|
||||
if (null != latch) {
|
||||
latch.countDown();
|
||||
}
|
||||
latch = null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
* <p>Return the DOM <code>Element</code> with the given id or name.
|
||||
* First, <code>Document.getElementById()</code> is called, passing
|
||||
* the argument <code>id</code>. If an element is found, it is
|
||||
* returned. Otherwise, the document is traversed and the first
|
||||
* element encountered with a <code>name</code> equal to the argument
|
||||
* <code>id</code> is returned. If no such element exists,
|
||||
* <code>null</code> is returned.</p>
|
||||
|
||||
*/
|
||||
|
||||
public Element findElement(String id) {
|
||||
Element result = null;
|
||||
|
@ -309,12 +405,32 @@ public class MCP {
|
|||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
* <p>Return <code>true</code> if and only if the argument
|
||||
* <code>toFind</code> occurs within the current page. Case is not
|
||||
* significant. Users desiring more detailed find behavior should
|
||||
* use {@link #getBrowserControl} to obtain a reference to the
|
||||
* <code>CurrentPage</code> interface, which has more advanced
|
||||
* methods pertaining to the current page. </p>
|
||||
|
||||
*/
|
||||
|
||||
public boolean findInPage(String toFind) {
|
||||
boolean found = false;
|
||||
found = getCurrentPage().find(toFind, true, true);
|
||||
found = getCurrentPage().find(toFind, true, false);
|
||||
return found;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
* <p>Find the DOM element within the current page matching the
|
||||
* argument <code>id</code> using {@link #findElement}. Use
|
||||
* <code>java.awt.Robot</code> to click the element. Return
|
||||
* immediately after clicking the element.</p>
|
||||
|
||||
*/
|
||||
|
||||
public void clickElement(String id) {
|
||||
Element element = findElement(id);
|
||||
|
@ -345,6 +461,16 @@ public class MCP {
|
|||
throw new IllegalStateException("Unable to click element " + id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
* <p>Find the DOM element within the current page matching the
|
||||
* argument <code>id</code> using {@link #findElement}. Use
|
||||
* <code>java.awt.Robot</code> to click the element. Block until the
|
||||
* document load triggered by the click has completed.</p>
|
||||
|
||||
*/
|
||||
|
||||
|
||||
public void blockingClickElement(String idOrName) {
|
||||
synchronized (this) {
|
||||
|
@ -359,6 +485,13 @@ public class MCP {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
* <p>Load the url, blocking until the load has completed.</p>
|
||||
|
||||
*/
|
||||
|
||||
|
||||
public void blockingLoad(String url) {
|
||||
Navigation2 nav = getNavigation();
|
||||
|
|
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 69 KiB |
|
@ -0,0 +1,200 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||
|
||||
<!--
|
||||
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
||||
* Ed Burns >edburns@acm.org<
|
||||
|
||||
-->
|
||||
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>org.mozilla.mcp</title>
|
||||
<style type="text/css">/* GeSHi (c) Nigel McNie 2004 (http://qbnz.com/highlighter) */
|
||||
.java .de1, .java .de2 {font-family: 'Courier New', Courier, monospace; font-weight: normal;}
|
||||
.java {font-family: monospace;}
|
||||
.java .imp {font-weight: bold; color: red;}
|
||||
.java li {background: #ffffff;}
|
||||
.java li.li2 {background: #f4f4f4;}
|
||||
.java .kw1 {color: #b1b100;}
|
||||
.java .kw2 {color: #000000; font-weight: bold;}
|
||||
.java .kw3 {color: #aaaadd; font-weight: bold;}
|
||||
.java .kw4 {color: #993333;}
|
||||
.java .co1 {color: #808080; font-style: italic;}
|
||||
.java .co2 {color: #a1a100;}
|
||||
.java .coMULTI {color: #808080; font-style: italic;}
|
||||
.java .es0 {color: #000099; font-weight: bold;}
|
||||
.java .br0 {color: #66cc66;}
|
||||
.java .st0 {color: #ff0000;}
|
||||
.java .nu0 {color: #cc66cc;}
|
||||
.java .me1 {color: #006600;}
|
||||
.java .me2 {color: #006600;}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<p>Mozilla Control Program</p>
|
||||
|
||||
<img width="120" height="86" src="mcp.jpg" style="float:left; padding:1%;" alt="Master Control Program, from TRON" />
|
||||
|
||||
<p>This package is a simple layer on top of the <a
|
||||
href="../webclient/package.html">Webclient API</a> to enable automated
|
||||
testing of web applications using software such as <a target="_"
|
||||
href="http://www.junit.org/">JUnit</a> or <a
|
||||
href="http://testng.org/">TestNG</a>. It fulfills a similar role as
|
||||
HtmlUnit or HttpUnit, but unlike those two, MCP has a real browser
|
||||
behind it. MCP also fulfills a similar role as Selenium. However,
|
||||
unlike Selenium, MCP allows you to make assertions about the response
|
||||
content of actual XMLHttpRequest responses, including getting an actual
|
||||
DOM instance of the response XML.</p>
|
||||
|
||||
<p>The main class in the package is <a href="MCP.html">MCP</a>. An
|
||||
instance of <code>MCP</code> corresponds to one browser window. Methods
|
||||
doing the following obvious tasks are provided:</p>
|
||||
|
||||
<br />
|
||||
|
||||
<ul>
|
||||
|
||||
<li><p><a href="MCP.html#getRealizedVisibleBrowserWindow()">create
|
||||
and show the actual browser window</a> as a
|
||||
<code>java.awt.Frame</code>. </p></li>
|
||||
|
||||
<li><p><a href="MCP.html#findInPage(java.lang.String)">find some text within the current page</a>.
|
||||
</p></li>
|
||||
|
||||
<li><p><a href="MCP.html#findElement(java.lang.String)">get a DOM <code>Element</code> given an id or name</a>.
|
||||
</p></li>
|
||||
|
||||
<li><p><a href="MCP.html#blockingClickElement(java.lang.String)">click on an element (given its id or name) and wait for the page to load before returning</a>.
|
||||
</p></li>
|
||||
|
||||
<li><p><a href="MCP.html#blockingLoad(java.lang.String)">load a URL and wait for it to finish loading before returning</a>.
|
||||
</p></li>
|
||||
|
||||
<li><p><a href="MCP.html#addAjaxListener(org.mozilla.mcp.AjaxListener)">add an AjaxListener that enables making assertions about the response of XMLHTTPRequest transactions made by the browser</a>.
|
||||
</p></li>
|
||||
|
||||
<li><p>add AWT <a
|
||||
href="MCP.html#addMouseListener(java.awt.event.MouseListener)">mouse</a>
|
||||
and <a
|
||||
href="MCP.html#addKeyListener(java.awt.event.KeyListener)">key</a>
|
||||
listeners. These can be used in conjunction with the
|
||||
<code>java.awt.Robot</code> class to drive the browser.</p></li>
|
||||
|
||||
</ul>
|
||||
|
||||
<p>Here is a code excerpt that illustrates the use of MCP and JUnit to
|
||||
test a JSF application that uses <a
|
||||
href="http://developers.sun.com/web/swdp/index.jsp">Project Dynamic
|
||||
Faces</a> for Ajax.</p>
|
||||
|
||||
|
||||
<div class="syntax"><div class="java" style="font-family: monospace;"><ol><li class="li1"><div class="de1"><span class="kw2">enum</span> TestFeature <span class="br0">{</span></div></li>
|
||||
<li class="li2"><div class="de2"> RECEIVED_END_AJAX_EVENT,</div></li>
|
||||
<li class="li1"><div class="de1"> HAS_MAP,</div></li>
|
||||
<li class="li2"><div class="de2"> HAS_VALID_PARTIAL_RESPONSE,</div></li>
|
||||
<li class="li1"><div class="de1"> HAS_VALID_READYSTATE,</div></li>
|
||||
<li class="li2"><div class="de2"> STOP_WAITING</div></li>
|
||||
<li class="li1"><div class="de1"><span class="br0">}</span></div></li>
|
||||
<li class="li2"><div class="de2"> </div></li>
|
||||
<li class="li1"><div class="de1"><span class="kw2">public</span> <span class="kw4">void</span> testCardemo<span class="br0">(</span><span class="br0">)</span> <span class="kw2">throws</span> <span class="kw3">Exception</span> <span class="br0">{</span></div></li>
|
||||
<li class="li2"><div class="de2"> </div></li>
|
||||
<li class="li1"><div class="de1"> MCP mcp = <span class="kw2">new</span> MCP<span class="br0">(</span><span class="br0">)</span>;</div></li>
|
||||
<li class="li2"><div class="de2"> <span class="kw2">try</span> <span class="br0">{</span></div></li>
|
||||
<li class="li1"><div class="de1"> mcp.<span class="me1">setAppData</span><span class="br0">(</span>getBrowserBinDir<span class="br0">(</span><span class="br0">)</span><span class="br0">)</span>;</div></li>
|
||||
<li class="li2"><div class="de2"> <span class="br0">}</span></div></li>
|
||||
<li class="li1"><div class="de1"> <span class="kw2">catch</span> <span class="br0">(</span><span class="kw3">Exception</span> e<span class="br0">)</span> <span class="br0">{</span></div></li>
|
||||
<li class="li2"><div class="de2"> fail<span class="br0">(</span><span class="br0">)</span>;</div></li>
|
||||
<li class="li1"><div class="de1"> <span class="br0">}</span></div></li>
|
||||
<li class="li2"><div class="de2"> </div></li>
|
||||
<li class="li1"><div class="de1"> mcp.<span class="me1">getRealizedVisibleBrowserWindow</span><span class="br0">(</span><span class="br0">)</span>;</div></li>
|
||||
<li class="li2"><div class="de2"> <span class="kw2">final</span> <span class="kw3">BitSet</span> bitSet = <span class="kw2">new</span> <span class="kw3">BitSet</span><span class="br0">(</span><span class="br0">)</span>;</div></li>
|
||||
<li class="li1"><div class="de1"> AjaxListener listener = <span class="kw2">new</span> AjaxListener<span class="br0">(</span><span class="br0">)</span> <span class="br0">{</span></div></li>
|
||||
<li class="li2"><div class="de2"> <span class="kw2">public</span> <span class="kw4">void</span> endAjax<span class="br0">(</span><span class="kw3">Map</span> eventMap<span class="br0">)</span> <span class="br0">{</span></div></li>
|
||||
<li class="li1"><div class="de1"> bitSet.<span class="me1">flip</span><span class="br0">(</span>TestFeature.<span class="me1">RECEIVED_END_AJAX_EVENT</span>.<span class="me1">ordinal</span><span class="br0">(</span><span class="br0">)</span><span class="br0">)</span>;</div></li>
|
||||
<li class="li2"><div class="de2"> <span class="kw1">if</span> <span class="br0">(</span><span class="kw2">null</span> != eventMap<span class="br0">)</span> <span class="br0">{</span></div></li>
|
||||
<li class="li1"><div class="de1"> bitSet.<span class="me1">flip</span><span class="br0">(</span>TestFeature.<span class="me1">HAS_MAP</span>.<span class="me1">ordinal</span><span class="br0">(</span><span class="br0">)</span><span class="br0">)</span>;</div></li>
|
||||
<li class="li2"><div class="de2"> <span class="br0">}</span></div></li>
|
||||
<li class="li1"><div class="de1"> <span class="kw3">String</span> responseText = <span class="br0">(</span><span class="kw3">String</span><span class="br0">)</span> eventMap.<span class="me1">get</span><span class="br0">(</span><span class="st0">"responseText"</span><span class="br0">)</span>;</div></li>
|
||||
<li class="li2"><div class="de2"> <span class="kw1">if</span> <span class="br0">(</span><span class="kw2">null</span> != responseText<span class="br0">)</span> <span class="br0">{</span></div></li>
|
||||
<li class="li1"><div class="de1"> <span class="kw1">if</span> <span class="br0">(</span><span class="nu0">-1</span> != responseText.<span class="me1">indexOf</span><span class="br0">(</span><span class="st0">"<partial-response>"</span><span class="br0">)</span> &&</div></li>
|
||||
<li class="li2"><div class="de2"> <span class="nu0">-1</span> != responseText.<span class="me1">indexOf</span><span class="br0">(</span><span class="st0">"</partial-response>"</span><span class="br0">)</span><span class="br0">)</span> <span class="br0">{</span></div></li>
|
||||
<li class="li1"><div class="de1"> bitSet.<span class="me1">flip</span><span class="br0">(</span>TestFeature.</div></li>
|
||||
<li class="li2"><div class="de2"> <span class="me1">HAS_VALID_PARTIAL_RESPONSE</span>.<span class="me1">ordinal</span><span class="br0">(</span><span class="br0">)</span><span class="br0">)</span>;</div></li>
|
||||
<li class="li1"><div class="de1"> <span class="br0">}</span></div></li>
|
||||
<li class="li2"><div class="de2"> <span class="br0">}</span></div></li>
|
||||
<li class="li1"><div class="de1"> <span class="kw3">String</span> readyState = <span class="br0">(</span><span class="kw3">String</span><span class="br0">)</span> eventMap.<span class="me1">get</span><span class="br0">(</span><span class="st0">"readyState"</span><span class="br0">)</span>;</div></li>
|
||||
<li class="li2"><div class="de2"> bitSet.<span class="me1">set</span><span class="br0">(</span>TestFeature.<span class="me1">HAS_VALID_READYSTATE</span>.<span class="me1">ordinal</span><span class="br0">(</span><span class="br0">)</span>, </div></li>
|
||||
<li class="li1"><div class="de1"> <span class="kw2">null</span> != readyState && readyState.<span class="me1">equals</span><span class="br0">(</span><span class="st0">"4"</span><span class="br0">)</span><span class="br0">)</span>;</div></li>
|
||||
<li class="li2"><div class="de2"> bitSet.<span class="me1">flip</span><span class="br0">(</span>TestFeature.<span class="me1">STOP_WAITING</span>.<span class="me1">ordinal</span><span class="br0">(</span><span class="br0">)</span><span class="br0">)</span>;</div></li>
|
||||
<li class="li1"><div class="de1"> </div></li>
|
||||
<li class="li2"><div class="de2"> <span class="br0">}</span></div></li>
|
||||
<li class="li1"><div class="de1"> <span class="br0">}</span>;</div></li>
|
||||
<li class="li2"><div class="de2"> mcp.<span class="me1">addAjaxListener</span><span class="br0">(</span>listener<span class="br0">)</span>;</div></li>
|
||||
<li class="li1"><div class="de1"> </div></li>
|
||||
<li class="li2"><div class="de2"> <span class="co1">// Load the main page of the app</span></div></li>
|
||||
<li class="li1"><div class="de1"> mcp.<span class="me1">blockingLoad</span><span class="br0">(</span><span class="st0">"http://javaserver.org/jsf-ajax-cardemo/faces/chooseLocale.jsp"</span><span class="br0">)</span>;</div></li>
|
||||
<li class="li2"><div class="de2"> <span class="co1">// Choose the "German" language button</span></div></li>
|
||||
<li class="li1"><div class="de1"> mcp.<span class="me1">blockingClickElement</span><span class="br0">(</span><span class="st0">"j_id_id73:Germany"</span><span class="br0">)</span>;</div></li>
|
||||
<li class="li2"><div class="de2"> <span class="co1">// Choose the roadster</span></div></li>
|
||||
<li class="li1"><div class="de1"> mcp.<span class="me1">blockingClickElement</span><span class="br0">(</span><span class="st0">"j_id_id18:j_id_id43"</span><span class="br0">)</span>;</div></li>
|
||||
<li class="li2"><div class="de2"> <span class="co1">// Sample the Basis-Preis and Ihr Preis before the ajax transaction</span></div></li>
|
||||
<li class="li1"><div class="de1"> <span class="kw3">Element</span> pricePanel = mcp.<span class="me1">findElement</span><span class="br0">(</span><span class="st0">"j_id_id10:zone1"</span><span class="br0">)</span>;</div></li>
|
||||
<li class="li2"><div class="de2"> assertNotNull<span class="br0">(</span>pricePanel<span class="br0">)</span>;</div></li>
|
||||
<li class="li1"><div class="de1"> <span class="kw3">String</span> pricePanelText = pricePanel.<span class="me1">getTextContent</span><span class="br0">(</span><span class="br0">)</span>;</div></li>
|
||||
<li class="li2"><div class="de2"> </div></li>
|
||||
<li class="li1"><div class="de1"> assertNotNull<span class="br0">(</span>pricePanelText<span class="br0">)</span>;</div></li>
|
||||
<li class="li2"><div class="de2"> assertTrue<span class="br0">(</span>pricePanelText.<span class="me1">matches</span><span class="br0">(</span><span class="st0">"(?s).*Basis-Preis<span class="es0">\\</span>s*15700.*"</span><span class="br0">)</span><span class="br0">)</span>;</div></li>
|
||||
<li class="li1"><div class="de1"> assertTrue<span class="br0">(</span>pricePanelText.<span class="me1">matches</span><span class="br0">(</span><span class="st0">"(?s).*Ihr Preis<span class="es0">\\</span>s*15700.*"</span><span class="br0">)</span><span class="br0">)</span>;</div></li>
|
||||
<li class="li2"><div class="de2"> </div></li>
|
||||
<li class="li1"><div class="de1"> <span class="co1">// Choose the "Tempomat" checkbox</span></div></li>
|
||||
<li class="li2"><div class="de2"> bitSet.<span class="me1">clear</span><span class="br0">(</span><span class="br0">)</span>;</div></li>
|
||||
<li class="li1"><div class="de1"> mcp.<span class="me1">clickElement</span><span class="br0">(</span><span class="st0">"j_id_id10:j_id_id63j_id_1"</span><span class="br0">)</span>;</div></li>
|
||||
<li class="li2"><div class="de2"> </div></li>
|
||||
<li class="li1"><div class="de1"> <span class="kw1">while</span> <span class="br0">(</span>!bitSet.<span class="me1">get</span><span class="br0">(</span>TestFeature.<span class="me1">STOP_WAITING</span>.<span class="me1">ordinal</span><span class="br0">(</span><span class="br0">)</span><span class="br0">)</span><span class="br0">)</span> <span class="br0">{</span></div></li>
|
||||
<li class="li2"><div class="de2"> <span class="kw3">Thread</span>.<span class="me1">currentThread</span><span class="br0">(</span><span class="br0">)</span>.<span class="me1">sleep</span><span class="br0">(</span><span class="nu0">5000</span><span class="br0">)</span>;</div></li>
|
||||
<li class="li1"><div class="de1"> <span class="br0">}</span></div></li>
|
||||
<li class="li2"><div class="de2"> </div></li>
|
||||
<li class="li1"><div class="de1"> <span class="co1">// assert that the ajax transaction succeeded</span></div></li>
|
||||
<li class="li2"><div class="de2"> assertTrue<span class="br0">(</span>bitSet.<span class="me1">get</span><span class="br0">(</span>TestFeature.<span class="me1">RECEIVED_END_AJAX_EVENT</span>.<span class="me1">ordinal</span><span class="br0">(</span><span class="br0">)</span><span class="br0">)</span><span class="br0">)</span>;</div></li>
|
||||
<li class="li1"><div class="de1"> assertTrue<span class="br0">(</span>bitSet.<span class="me1">get</span><span class="br0">(</span>TestFeature.<span class="me1">HAS_MAP</span>.<span class="me1">ordinal</span><span class="br0">(</span><span class="br0">)</span><span class="br0">)</span><span class="br0">)</span>;</div></li>
|
||||
<li class="li2"><div class="de2"> assertTrue<span class="br0">(</span>bitSet.<span class="me1">get</span><span class="br0">(</span>TestFeature.<span class="me1">HAS_VALID_PARTIAL_RESPONSE</span>.<span class="me1">ordinal</span><span class="br0">(</span><span class="br0">)</span><span class="br0">)</span><span class="br0">)</span>;</div></li>
|
||||
<li class="li1"><div class="de1"> assertTrue<span class="br0">(</span>bitSet.<span class="me1">get</span><span class="br0">(</span>TestFeature.<span class="me1">HAS_VALID_READYSTATE</span>.<span class="me1">ordinal</span><span class="br0">(</span><span class="br0">)</span><span class="br0">)</span><span class="br0">)</span>;</div></li>
|
||||
<li class="li2"><div class="de2"> bitSet.<span class="me1">clear</span><span class="br0">(</span><span class="br0">)</span>;</div></li>
|
||||
<li class="li1"><div class="de1"> </div></li>
|
||||
<li class="li2"><div class="de2"> <span class="co1">// Sample the Basis-Preis and Ihr-Preis after the ajax transaction</span></div></li>
|
||||
<li class="li1"><div class="de1"> pricePanel = mcp.<span class="me1">findElement</span><span class="br0">(</span><span class="st0">"j_id_id10:zone1"</span><span class="br0">)</span>;</div></li>
|
||||
<li class="li2"><div class="de2"> assertNotNull<span class="br0">(</span>pricePanel<span class="br0">)</span>;</div></li>
|
||||
<li class="li1"><div class="de1"> pricePanelText = pricePanel.<span class="me1">getTextContent</span><span class="br0">(</span><span class="br0">)</span>;</div></li>
|
||||
<li class="li2"><div class="de2"> </div></li>
|
||||
<li class="li1"><div class="de1"> assertNotNull<span class="br0">(</span>pricePanelText<span class="br0">)</span>;</div></li>
|
||||
<li class="li2"><div class="de2"> assertTrue<span class="br0">(</span>pricePanelText.<span class="me1">matches</span><span class="br0">(</span><span class="st0">"(?s).*Basis-Preis<span class="es0">\\</span>s*15700.*"</span><span class="br0">)</span><span class="br0">)</span>;</div></li>
|
||||
<li class="li1"><div class="de1"> assertTrue<span class="br0">(</span>pricePanelText.<span class="me1">matches</span><span class="br0">(</span><span class="st0">"(?s).*Ihr Preis<span class="es0">\\</span>s*16600.*"</span><span class="br0">)</span><span class="br0">)</span>;</div></li>
|
||||
<li class="li2"><div class="de2"> </div></li>
|
||||
<li class="li1"><div class="de1"> mcp.<span class="me1">deleteBrowserControl</span><span class="br0">(</span><span class="br0">)</span>;</div></li>
|
||||
<li class="li2"><div class="de2"><span class="br0">}</span> </div></li></ol></div></div>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -30,9 +30,12 @@ import java.io.File;
|
|||
import java.io.FileNotFoundException;
|
||||
|
||||
/**
|
||||
* <p>Do per-app one-time initialization and shutdown, as well as being
|
||||
* the factory for per-window {@link BrowserControl} instances. This
|
||||
* interface allows a pluggable webclient API implementation. The
|
||||
*
|
||||
* <p>An implementation for this interface must be provided by the
|
||||
* Webclient implementation. This interface is not to be called by the
|
||||
* end user. Do per-app one-time initialization and shutdown, as well
|
||||
* as being the factory for per-window {@link BrowserControl} instances.
|
||||
* This interface allows a pluggable webclient API implementation. The
|
||||
* static methods in {@link BrowserControlFactory} call through to
|
||||
* methods on this interface. The implementation of this interface must
|
||||
* be a singleton and its the lifetime must be the same as the
|
||||
|
|
|
@ -178,7 +178,7 @@ endif
|
|||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
DEFINES += -DMOZILLA_INTERNAL_API
|
||||
DEFINES += -DMOZILLA_INTERNAL_API -DFORCE_PR_LOG
|
||||
|
||||
ifdef MOZ_ENABLE_GTK
|
||||
ifndef MOZ_MONOLITHIC_TOOLKIT
|
||||
|
|
|
@ -48,7 +48,7 @@ FORCE_STATIC_LIB = 1
|
|||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
DEFINES += -DMOZILLA_INTERNAL_API
|
||||
DEFINES += -DMOZILLA_INTERNAL_API -DFORCE_PR_LOG
|
||||
|
||||
ifneq ($(BAL_INTERFACE),)
|
||||
INCLUDES := -I../bal -I../bal/solaris $(INCLUDES)
|
||||
|
|
Загрузка…
Ссылка в новой задаче