Initial add of files to support a JavaScript console.

r=jband, r=ben

(though I've changed things slightly since they saw it.)


git-svn-id: svn://10.0.0.236/trunk@64105 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
mccabe%netscape.com
2000-03-25 04:23:31 +00:00
parent fe8ca33e54
commit b107f3ff5f
22 changed files with 1132 additions and 0 deletions

View File

@@ -0,0 +1,60 @@
#
# 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):
#
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
IS_COMPONENT = 1
DIRS = resources
MODULE = consoleservice
LIBRARY_NAME = consoleservice
IS_COMPONENT = 1
CPPSRCS = \
nsConsoleMessage.cpp \
nsConsoleService.cpp \
nsConsoleServiceModule.cpp \
$(NULL)
XPIDLSRCS = \
nsIConsoleService.idl \
nsIConsoleMessage.idl \
nsIConsoleListener.idl \
nsIScriptError.idl \
$(NULL)
include $(topsrcdir)/config/rules.mk

View File

@@ -0,0 +1,69 @@
#!nmake
#
# 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):
# copied in part from ../timebomb/makefile.win
DEPTH = ..\..\..
MODULE = consoleservice
DLL = .\$(OBJDIR)\$(MODULE).dll
MAKE_OBJ_TYPE = DLL
include <$(DEPTH)/config/config.mak>
DIRS = resources
EXPORTS = \
$(NULL)
XPIDLSRCS = \
nsIConsoleService.idl \
nsIConsoleMessage.idl \
nsIConsoleListener.idl \
nsIScriptError.idl \
$(NULL)
LINCS = \
$(NULL)
LLIBS = \
$(LIBNSPR) \
$(DIST)\lib\xpcom.lib \
$(NULL)
OBJS = \
nsConsoleMessage.obj \
nsConsoleService.obj \
nsConsoleServiceModule.cpp \
$(NULL)
include <$(DEPTH)\config\rules.mak>
install:: $(DLL)
$(MAKE_INSTALL) .\$(OBJDIR)\$(MODULE).dll $(DIST)\bin\components
clobber::
rm -f $(DIST)\bin\components\$(MODULE).dll

View File

@@ -0,0 +1,38 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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.
*
*/
/*
* Base interface for console messages.
*/
#include "nsConsoleMessage.h"
NS_IMPL_THREADSAFE_ISUPPORTS(nsConsoleMessage, NS_GET_IID(nsIConsoleMessage));
nsConsoleMessage::nsConsoleMessage() {};
nsConsoleMessage::~nsConsoleMessage() {};
NS_IMETHODIMP
nsConsoleMessage::GetMessage(PRUnichar **result) {
*result = mMessage.ToNewUnicode();
return NS_OK;
}

View File

@@ -0,0 +1,44 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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.
*
*/
/*
* 'lil description of this file.
*/
#include "nsIConsoleMessage.h"
#include "nsString.h"
class nsConsoleMessage : public nsIConsoleMessage {
public:
nsConsoleMessage();
virtual ~nsConsoleMessage();
nsConsoleMessage(const PRUnichar *message) {
mMessage.SetString(message);
}
NS_DECL_ISUPPORTS
NS_DECL_NSICONSOLEMESSAGE
private:
nsAutoString mMessage;
};

View File

@@ -0,0 +1,182 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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.
*
*/
/*
* Maintains a circular buffer of recent messages, and notifies
* listeners when new messages are logged.
*/
#include "nsConsoleService.h"
#include "nsConsoleMessage.h"
#include "nsIAllocator.h"
NS_IMPL_THREADSAFE_ISUPPORTS(nsConsoleService, NS_GET_IID(nsIConsoleService));
nsConsoleService::nsConsoleService()
{
mCurrent = 0;
mFull = PR_FALSE;
// XXX grab this from a pref!
mBufferSize = 250;
// Any reasonable way to deal with failure of the below two?
nsresult rv;
rv = nsSupportsArray::Create(NULL, NS_GET_IID(nsISupportsArray),
(void**)&mListeners);
mMessages = (nsIConsoleMessage **)
nsAllocator::Alloc(mBufferSize * sizeof(nsIConsoleMessage *));
// Array elements should be 0 initially for circular buffer algorithm.
for (PRUint32 i = 0; i < mBufferSize; i++) {
mMessages[i] = nsnull;
}
NS_INIT_REFCNT();
}
nsConsoleService::~nsConsoleService()
{
PRUint32 i = 0;
while (i < mBufferSize && mMessages[i] != nsnull) {
NS_RELEASE(mMessages[i]);
i++;
}
nsAllocator::Free(mMessages);
}
NS_IMETHODIMP
nsConsoleService::LogMessage(nsIConsoleMessage *message)
{
if (message == nsnull)
return NS_ERROR_FAILURE;
// If there's already a message in the slot we're about to replace,
// we've wrapped around, and we need to release the old message before
// overwriting it.
if (mMessages[mCurrent] != nsnull)
NS_RELEASE(mMessages[mCurrent]);
NS_ADDREF(message);
mMessages[mCurrent++] = message;
if (mCurrent == mBufferSize) {
mCurrent = 0;
mFull = PR_TRUE;
}
// Iterate through any registered listeners and tell them about the message.
nsIConsoleListener *listener;
nsresult rv;
PRUint32 listenerCount;
rv = mListeners->Count(&listenerCount);
if (NS_FAILED(rv))
return rv;
for (PRUint32 i = 0; i < listenerCount; i++) {
rv = mListeners->GetElementAt(i, (nsISupports **)&listener);
if (NS_FAILED(rv))
return rv;
listener->Observe(message);
NS_RELEASE(listener);
}
return NS_OK;
}
NS_IMETHODIMP
nsConsoleService::LogStringMessage(const PRUnichar *message)
{
// LogMessage adds a ref to this, and eventual release does delete.
nsConsoleMessage *msg = new nsConsoleMessage(message);
return this->LogMessage(msg);
}
NS_IMETHODIMP
nsConsoleService::GetMessageArray(nsIConsoleMessage ***messages, PRUint32 *count)
{
nsIConsoleMessage **messageArray;
if (mCurrent == 0 && !mFull) {
// not sure how to return a 0-length array...
*messages = nsnull;
*count = 0;
return NS_ERROR_FAILURE;
}
PRUint32 resultSize = mFull ? mBufferSize : mCurrent;
messageArray =
(nsIConsoleMessage **)nsAllocator::Alloc((sizeof (nsIConsoleMessage *))
* resultSize);
// XXX jband sez malloc array with 1 member and return 0 count;
// might not work; if not, bug jband.
// could also return null if I want to do such.
// open question about interface contract here.
//
// jband sez: should guard against both b/c the interface doesn't specify
// which. And add my convention to /** */ in the interface.
if (messageArray == nsnull) {
*messages = nsnull;
*count = 0;
return NS_ERROR_FAILURE;
}
PRUint32 i;
if (mFull) {
for (i = 0; i < mBufferSize; i++) {
// if full, fill the buffer starting from mCurrent (which'll be
// oldest) wrapping around the buffer to the most recent.
messageArray[i] = mMessages[(mCurrent + i) % mBufferSize];
NS_ADDREF(messageArray[i]);
}
} else {
for (i = 0; i < mCurrent; i++) {
messageArray[i] = mMessages[i];
NS_ADDREF(messageArray[i]);
}
}
*count = resultSize;
*messages = messageArray;
return NS_OK;
}
NS_IMETHODIMP
nsConsoleService::RegisterListener(nsIConsoleListener *listener) {
// ignore rv for now, as a comment says it returns prbool instead of
// nsresult.
// Any need to check for multiply registered listeners?
mListeners->AppendElement(listener);
return NS_OK;
}
NS_IMETHODIMP
nsConsoleService::UnregisterListener(nsIConsoleListener *listener) {
// ignore rv for now, as a comment says it returns prbool instead of
// nsresult.
mListeners->RemoveElement(listener);
return NS_OK;
}

View File

@@ -0,0 +1,55 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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):
*/
/*
* 'lil description of this file.
*/
#include "nsIConsoleService.h"
#include "nsSupportsArray.h"
#include "nsCOMPtr.h"
class nsConsoleService : public nsIConsoleService
{
public:
nsConsoleService();
virtual ~nsConsoleService();
NS_DECL_ISUPPORTS
NS_DECL_NSICONSOLESERVICE
private:
// Circular buffer of saved messages
nsIConsoleMessage **mMessages;
// How big?
PRUint32 mBufferSize;
// Index of slot in mMessages that'll be filled by *next* log message
PRUint32 mCurrent;
// Is the buffer full? (Has mCurrent wrapped around at least once?)
PRBool mFull;
// Listeners to notify whenever a new message is logged.
nsCOMPtr<nsSupportsArray> mListeners;
};

View File

@@ -0,0 +1,53 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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):
*/
#include "nsIModule.h"
#include "nsIGenericFactory.h"
#include "nsConsoleService.h"
NS_GENERIC_FACTORY_CONSTRUCTOR(nsConsoleService)
static nsModuleComponentInfo components[] =
{
{ "Console Service", NS_CONSOLESERVICE_CID, NS_CONSOLESERVICE_PROGID,
nsConsoleServiceConstructor,
nsnull, // RegisterConsoleService
nsnull, // UnregisterConsoleService
}
};
////////////////////////////////////////////////////////////////////////
// Implement the NSGetModule() exported function for your module
// and the entire implementation of the module object.
//
// NOTE: If you want to use the module shutdown to release any
// module specific resources, use the macro
// NS_IMPL_NSGETMODULE_WITH_DTOR() instead of the vanilla
// NS_IMPL_NSGETMODULE()
//
// e.g. xpconnect uses this to release some singletons;
// xdr search on ..._WITH_DTOR
NS_IMPL_NSGETMODULE("nsConsoleServiceModule", components)

View File

@@ -0,0 +1,34 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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):
*/
/*
* Used by the console service to notify listeners of new console messages.
*/
#include "nsISupports.idl"
#include "nsIConsoleMessage.idl"
[scriptable, uuid(eaaf61d6-1dd1-11b2-bc6e-8fc96480f20d)]
interface nsIConsoleListener : nsISupports
{
void observe(in nsIConsoleMessage aMessage);
};

View File

@@ -0,0 +1,34 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* 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):
*/
#include "nsISupports.idl"
/**
* This is intended as a base interface; implementations may want to
* provide an object that can be qi'ed to provide more specific
* message information.
*/
[scriptable, uuid(41bd8784-1dd2-11b2-9553-8606958fffe1)]
interface nsIConsoleMessage : nsISupports
{
readonly attribute wstring message;
};

View File

@@ -0,0 +1,50 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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):
*/
#include "nsISupports.idl"
#include "nsIConsoleListener.idl"
#include "nsIConsoleMessage.idl"
[scriptable, uuid(a647f184-1dd1-11b2-a9d1-8537b201161b)]
interface nsIConsoleService : nsISupports
{
void logMessage(in nsIConsoleMessage message);
// Needed for folks who need to avoid nsIConsoleMessage hassle
void logStringMessage(in wstring message);
void getMessageArray([array, size_is(count)] out nsIConsoleMessage messages,
out PRUint32 count);
void registerListener(in nsIConsoleListener listener);
void unregisterListener(in nsIConsoleListener listener);
};
%{ C++
#define NS_CONSOLESERVICE_CID \
{ 0x7e3ff85c, 0x1dd2, 0x11b2, { 0x8d, 0x4b, 0xeb, 0x45, 0x2c, 0xb0, 0xff, 0x40 }}
#define NS_CONSOLESERVICE_PROGID "consoleservice"
%}

View File

@@ -0,0 +1,69 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* 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):
*/
#include "nsISupports.idl"
#include "nsIConsoleMessage.idl"
[scriptable, uuid(fc9e5a94-1dd1-11b2-888b-d8907b2c6996)]
interface nsIScriptError : nsIConsoleMessage
{
/** pseudo-flag for default case */
const unsigned long ERROR = 0x0;
/** message is warning */
const unsigned long WARNING = 0x1;
/** exception was thrown for this case - exception-aware hosts can ignore */
const unsigned long EXCEPTION = 0x2;
// XXX check how strict is implemented these days.
/** error or warning is due to strict option */
const unsigned long STRICT = 0x4;
readonly attribute wstring fileName;
readonly attribute PRUint32 lineNumber;
readonly attribute wstring sourceLine;
readonly attribute PRUint32 columnNumber;
readonly attribute PRUint32 flags;
readonly attribute wstring category;
};
// jband asks: save more info for debuggy stuff in console?
// e.g. title of window, maybe weak reference to originating window?
// maybe just way to get from url to loaded document.
// struct JSErrorReport {
// const char *filename; /* source file name, URL, etc., or null */
// uintN lineno; /* source line number */
// const char *linebuf; /* offending source line without final \n */
// const char *tokenptr; /* pointer to error token in linebuf */
// const jschar *uclinebuf; /* unicode (original) line buffer */
// const jschar *uctokenptr; /* unicode (original) token pointer */
// uintN flags; /* error/warning, etc. */
// uintN errorNumber; /* the error number, e.g. see js.msg */
// const jschar *ucmessage; /* the (default) error message */
// const jschar **messageArgs; /* arguments for the error message */
// };

View File

@@ -0,0 +1,32 @@
#
# 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):
#
DEPTH = ../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
DIRS = content locale
include $(topsrcdir)/config/rules.mk

View File

@@ -0,0 +1,40 @@
#
# 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):
#
DEPTH = ../../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
EXPORT_RESOURCE_CONTENT := \
console.js \
console.xul \
$(NULL)
EXPORT_RESOURCE_CONTENT := $(addprefix $(srcdir)/, $(EXPORT_RESOURCE_CONTENT))
include $(topsrcdir)/config/rules.mk
install::
$(INSTALL) $(EXPORT_RESOURCE_CONTENT) $(DIST)/bin/chrome/global/content/default

View File

@@ -0,0 +1,120 @@
/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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):
*/
/*
* Functions for initializing and updating the JavaScript Console.
*/
/*
* Listener to be registered with the console service, called on new errors.
*/
var consoleListener = {
observe : function(messageObject) {
appendMessage(messageObject);
}
}
/*
* Gets the current context of the console service and dumps it to the window,
* and registers a listener with the service to be called on additional errors.
*/
function onLoadJSConsole()
{
dump('\n\nconsole loading\n\n');
try {
var cs_class = Components.classes['consoleservice'];
var cs_iface = Components.interfaces.nsIConsoleService;
var cs_isupports = cs_class.getService();
var cs = cs_isupports.QueryInterface(cs_iface);
} catch(exn) {
// Couldn't get the console service for some reason...
// pretend it never happened.
// XXX instead should write some message to the console re:
// unable to get console service.
return;
}
dump('\n\ngot console service\n\n');
var o1 = {}; // Throwaway references to support 'out' parameters.
var o2 = {};
var messages;
try {
cs.getMessageArray(o1, o2);
messages = o1.value;
} catch (exn) {
// getMessageArray throws an exception when there are no elements.
messages = [];
}
for (i = 0; i < messages.length; i++) {
appendMessage(messages[i]);
}
dump('\n\nregistering...\n');
cs.registerListener(consoleListener);
dump('registered listener\n\n');
}
function onUnloadJSConsole()
{
// keep a global ref. to it instead???
try {
var cs_class = Components.classes['consoleservice'];
var cs_iface = Components.interfaces.nsIConsoleService;
var cs_isupports = cs_class.getService();
var cs = cs_isupports.QueryInterface(cs_iface);
} catch(exn) {
// Couldn't get the console service for some reason...
// pretend it never happened.
return;
}
cs.unregisterListener(consoleListener);
}
/*
* Given a message, write it to the page.
*
* TODO: (When interesting subclasses of message objects become available) -
* reflect structure of messages (e.g. lineno, etc.) as CSS-decorable structure.
*/
function appendMessage(messageObject)
{
var c = document.getElementById("console");
var e = document.createElement("message");
var t = document.createTextNode(messageObject.message);
e.appendChild(t);
c.appendChild(e);
}
// XXX q: if window is open, does it grow forever? Is that OK?
// or should it do its own retiring?

View File

@@ -0,0 +1,39 @@
<?xml version="1.0"?>
<!-- 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 Communicator client code, released
March 31, 1998.
The Initial Developer of the Original Code is Netscape
Communications Corporation. Portions created by Netscape are
Copyright (C) 1998-1999 Netscape Communications Corporation. All
Rights Reserved.
Contributor(s): ______________________________________. -->
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<!DOCTYPE window SYSTEM "chrome://global/locale/console.dtd" >
<window id="console-top" xmlns:html="http://www.w3.org/TR/REC-html40"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
title="&console.title;"
onload="onLoadJSConsole()"
onunload="onUnloadJSConsole()"
windowtype="global:console"
align="vertical" width="640" height="480">
<html:script src="chrome://global/content/console.js"></html:script>
<box align="vertical" id="console"/>
</window>

View File

@@ -0,0 +1,34 @@
#!nmake
#
# 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):
DEPTH=..\..\..\..
include <$(DEPTH)\config\rules.mak>
DISTBROWSWER=$(DIST)\bin\chrome\global\content\default
install::
$(MAKE_INSTALL) console.js $(DISTBROWSER)
$(MAKE_INSTALL) console.xul $(DISTBROWSER)
clobber::
rm -f $(DISTBROWSER)\console.js
rm -f $(DISTBROWSER)\console.xul

View File

@@ -0,0 +1,32 @@
#
# 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):
#
DEPTH = ../../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
DIRS = en-US
include $(topsrcdir)/config/rules.mk

View File

@@ -0,0 +1,37 @@
#
# 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):
#
DEPTH = ../../../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
EXPORT_RESOURCE_CONTENT = \
console.dtd \
$(NULL)
include $(topsrcdir)/config/rules.mk
install::
$(INSTALL) $(EXPORT_RESOURCE_CONTENT) $(DIST)/bin/chrome/global/locale/en-US

View File

@@ -0,0 +1,21 @@
<!-- 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 Communicator client code, released
March 31, 1998.
The Initial Developer of the Original Code is Netscape
Communications Corporation. Portions created by Netscape are
Copyright (C) 1998-1999 Netscape Communications Corporation. All
Rights Reserved.
Contributor(s): ______________________________________. -->
<!ENTITY console.title "JavaScript Console">

View File

@@ -0,0 +1,33 @@
#!nmake
#
# 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):
DEPTH=..\..\..\..\..\..
include <$(DEPTH)\config\rules.mak>
DISTBROWSER=$(DIST)\bin\chrome\global\locale\en-US
install::
$(MAKE_INSTALL) console.dtd $(DISTBROWSER)
clobber::
rm -f $(DISTBROWSER)\console.dtd

View File

@@ -0,0 +1,29 @@
#!nmake
#
# 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):
DEPTH=..\..\..\..\..
DIRS= en-US
include <$(DEPTH)\config\rules.mak>

View File

@@ -0,0 +1,27 @@
#!nmake
#
# 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):
DEPTH=..\..\..\..
DIRS= content locale
include <$(DEPTH)\config\rules.mak>