JavaScriptCore:
authorkdecker <kdecker@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 28 May 2004 02:06:05 +0000 (02:06 +0000)
committerkdecker <kdecker@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 28 May 2004 02:06:05 +0000 (02:06 +0000)
        Reviewed by Ken.

-revised generated error message content

        * kjs/error_object.cpp:
        (ErrorProtoFuncImp::call):
        * kjs/internal.cpp:
        (Parser::parse):
        * kjs/object.cpp:
        (KJS::Error::create):

WebCore:

        Reviewed by Ken.

-wired up JavaScript error message handling to
the WebCoreBridge

        * khtml/ecma/kjs_events.cpp:
        (JSEventListener::handleEvent):
        * khtml/ecma/kjs_proxy.cpp:
        (KJSProxyImpl::evaluate):
        * khtml/ecma/kjs_window.cpp:
        (Window::isSafeScript):
        (ScheduledAction::execute):
        * kwq/KWQKHTMLPart.h:
        * kwq/KWQKHTMLPart.mm:
        (KWQKHTMLPart::addMessageToConsole):
        * kwq/WebCoreBridge.h:
        * kwq/WebCoreBridge.mm:

WebKit:

        Reviewed by Ken.

-wired up JavaScript error message handling through
the WebCoreBridge

        * WebCoreSupport.subproj/WebBridge.m:
        (-[WebBridge addMessageToConsole:]):
        * WebKit.pbproj/project.pbxproj:
        * WebView.subproj/WebUIDelegatePrivate.h:

WebBrowser:

        Reviewed by Ken.

-added the JavaScript Console feature

        * BrowserWebController.m:
        (-[BrowserWebView setWindowFocusDisabled:]):
        (-[BrowserWebView webView:addMessageToConsole:]):
        * Debug/DebugUtilities.m:
        (-[DebugUtilities createDebugMenu]):
        (-[BrowserDocument showJavaScriptConsole:]):
        * WebBrowser.pbproj/project.pbxproj:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@6717 268f45cc-cd09-0410-ab3c-d52691b4dbfc

16 files changed:
JavaScriptCore/ChangeLog
JavaScriptCore/kjs/error_object.cpp
JavaScriptCore/kjs/internal.cpp
JavaScriptCore/kjs/object.cpp
WebCore/ChangeLog-2005-08-23
WebCore/khtml/ecma/kjs_events.cpp
WebCore/khtml/ecma/kjs_proxy.cpp
WebCore/khtml/ecma/kjs_window.cpp
WebCore/kwq/KWQKHTMLPart.h
WebCore/kwq/KWQKHTMLPart.mm
WebCore/kwq/WebCoreBridge.h
WebCore/kwq/WebCoreBridge.mm
WebKit/ChangeLog
WebKit/WebCoreSupport.subproj/WebBridge.m
WebKit/WebKit.pbproj/project.pbxproj
WebKit/WebView.subproj/WebUIDelegatePrivate.h

index e081cbd3388d1a9bdc703453e0963d9f6d7828d8..4f0f8922324e774af4d74f31f3cf411a777ac6bb 100644 (file)
@@ -1,3 +1,14 @@
+2004-05-27  Kevin Decker  <kdecker@apple.com>
+
+        Reviewed by NOBODY (OOPS!).
+
+        * kjs/error_object.cpp:
+        (ErrorProtoFuncImp::call):
+        * kjs/internal.cpp:
+        (Parser::parse):
+        * kjs/object.cpp:
+        (KJS::Error::create):
+
 === Safari-142 ===
 
 2004-05-27  Richard Williamson   <rjw@apple.com>
index 543f5fbee14b6c069429459aab51623f3ec9d723..047ddd7fff7dc010642b87a948cba08b617b36e0 100644 (file)
@@ -66,13 +66,7 @@ Value ErrorProtoFuncImp::call(ExecState *exec, Object &thisObj, const List &/*ar
   // toString()
   UString s;
 
-  Value v = thisObj.get(exec, "line");
-  if (v.type() != UndefinedType) {
-    s += v.toString(exec) += ": ";
-  }
-
-
-  v = thisObj.get(exec, namePropertyName);
+  Value v = thisObj.get(exec, namePropertyName);
   if (v.type() != UndefinedType) {
     s += v.toString(exec);
   }
index c95a03558d424deeb34e624bb26749222db0d359..8cbf2f62bc7ad847ec4e63d3bd89af21dd49917a 100644 (file)
@@ -462,7 +462,7 @@ ProgramNode *Parser::parse(const UChar *code, unsigned int length, int *sourceId
     if (errLine)
       *errLine = eline;
     if (errMsg)
-      *errMsg = "Parse error at line " + UString::from(eline);
+      *errMsg = "Parse error";
     if (prog) {
       // must ref and deref to clean up properly
       prog->ref();
index a4ebd17f2cc04a2298638ecc576ea91fc3505fed..6c26619db58b75dfffc025d181df6326b7464005 100644 (file)
@@ -495,7 +495,6 @@ Object Error::create(ExecState *exec, ErrorType errtype, const char *message,
                      int lineno, int sourceId)
 {
   Object cons;
-
   switch (errtype) {
   case EvalError:
     cons = exec->lexicalInterpreter()->builtinEvalError();
index 547d374cd1559ff9b412f33857ad6d5334e21873..e3066a6873ff3328d86204227e5197acbf3fac90 100644 (file)
@@ -1,3 +1,20 @@
+2004-05-27  Kevin Decker  <kdecker@apple.com>
+
+        Reviewed by NOBODY (OOPS!).
+
+        * khtml/ecma/kjs_events.cpp:
+        (JSEventListener::handleEvent):
+        * khtml/ecma/kjs_proxy.cpp:
+        (KJSProxyImpl::evaluate):
+        * khtml/ecma/kjs_window.cpp:
+        (Window::isSafeScript):
+        (ScheduledAction::execute):
+        * kwq/KWQKHTMLPart.h:
+        * kwq/KWQKHTMLPart.mm:
+        (KWQKHTMLPart::addMessageToConsole):
+        * kwq/WebCoreBridge.h:
+        * kwq/WebCoreBridge.mm:
+
 2004-05-27  Trey Matteson  <trey@apple.com>
 
        Two dragging tweaks:  ondragleave events are sent before ondragenter events when
index f7d807eeffc9adc8310af9a1e9b2e1451601f38c..42d18d995cd14d7497f1a955c0edc2360607e36e 100644 (file)
@@ -18,7 +18,7 @@
  *  License along with this library; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
-
+#include "khtml_part.h"
 #include "kjs_window.h"
 #include "kjs_events.h"
 #include "kjs_events.lut.h"
@@ -111,10 +111,14 @@ void JSEventListener::handleEvent(DOM::Event &evt, bool isWindowEvent)
     interpreter->setCurrentEvent( 0 );
 #if APPLE_CHANGES
     if ( exec->hadException() ) {
+        KJS::Interpreter::lock();
+        char *message = exec->exception().toObject(exec).get(exec, messagePropertyName).toString(exec).ascii();
+        int lineNumber =  exec->exception().toObject(exec).get(exec, "line").toInt32(exec);
+        KJS::Interpreter::unlock();
         if (Interpreter::shouldPrintExceptions()) {
-           char *message = exec->exception().toObject(exec).get(exec, messagePropertyName).toString(exec).ascii();
            printf("(event handler):%s\n", message);
        }
+        KWQ(part)->addMessageToConsole(message, lineNumber );
         exec->clearException();
     }
 #else
index de890526a55a7d3e89972d7165816521c7880684..31f733ee2eb6f8ddaf145cb9b21a3b103dbb6005 100644 (file)
@@ -116,8 +116,7 @@ QVariant KJSProxyImpl::evaluate(QString filename, int baseLine,
 
   UString code( str );
   Completion comp = m_script->evaluate(code, thisNode, filename);
-  bool success = ( comp.complType() == Normal ) || ( comp.complType() == ReturnValue );
-
+  bool success = ( comp.complType() == Normal ) || ( comp.complType() == ReturnValue );  
 #ifdef KJS_DEBUGGER
     //    KJSDebugWin::instance()->setCode(QString::null);
 #endif
@@ -131,8 +130,13 @@ QVariant KJSProxyImpl::evaluate(QString filename, int baseLine,
     {
         KJS::Interpreter::lock();
         UString msg = comp.value().toString(m_script->globalExec());
+        int lineNumber =  comp.value().toObject(m_script->globalExec()).get(m_script->globalExec(), "line").toInt32(m_script->globalExec());
         KJS::Interpreter::unlock();
+#if APPLE_CHANGES
+        KWQ(m_part)->addMessageToConsole(msg.qstring(), lineNumber);
+#else
         kdWarning(6070) << "Script threw exception: " << msg.qstring() << endl;
+#endif
     }
     return QVariant();
   }
index 70360150246c15e8fb2b25486dce62308932ba4d..4ab08425dee8d09811f0e40cfa0b75a5a94a7548 100644 (file)
@@ -1047,6 +1047,10 @@ bool Window::isSafeScript(ExecState *exec) const
   if (Interpreter::shouldPrintExceptions()) {
       printf("Unsafe JavaScript attempt to access frame with URL %s from frame with URL %s. Domains must match.\n", 
              thisDocument->URL().latin1(), actDocument->URL().latin1());
+      QString message;
+      message.sprintf("Unsafe JavaScript attempt to access frame with URL %s from frame with URL %s. Domains must match.\n", 
+                      thisDocument->URL().latin1(), actDocument->URL().latin1());
+      KWQ(m_part)->addMessageToConsole(message, 1);
   }
 #endif
   
@@ -1673,12 +1677,14 @@ void ScheduledAction::execute(Window *window)
        Interpreter::unlock();
        if ( exec->hadException() ) {
 #if APPLE_CHANGES
+          Interpreter::lock();
+          char *message = exec->exception().toObject(exec).get(exec, messagePropertyName).toString(exec).ascii();
+          int lineNumber =  exec->exception().toObject(exec).get(exec, "line").toInt32(exec);
+          Interpreter::unlock();
          if (Interpreter::shouldPrintExceptions()) {
-           Interpreter::lock();
-           char *message = exec->exception().toObject(exec).get(exec, messagePropertyName).toString(exec).ascii();
-           Interpreter::unlock();
            printf("(timer):%s\n", message);
          }
+          KWQ(window->m_part)->addMessageToConsole(message, lineNumber);
 #endif
          exec->clearException();
        }
index d474df80dd3c0030bcb03b30057ddbf7608640fb..9fb3766fc9a407bcd3163c918e3450db3c151d87 100644 (file)
@@ -179,7 +179,7 @@ public:
     void runJavaScriptAlert(const QString &message);
     bool runJavaScriptConfirm(const QString &message);
     bool runJavaScriptPrompt(const QString &message, const QString &defaultValue, QString &result);
-
+    void KWQKHTMLPart::addMessageToConsole(const QString &message, const unsigned int lineNumber);
     using KHTMLPart::xmlDocImpl;
     khtml::RenderObject *renderer();
     void forceLayout();
index 0563f40509dd31c8930a79d4e124b4b15040d609..7adb67cf38aa8dee8cfe458691914966a9e34cce 100644 (file)
@@ -1579,6 +1579,13 @@ bool KWQKHTMLPart::runJavaScriptPrompt(const QString &prompt, const QString &def
     return false;
 }
 
+void KWQKHTMLPart::addMessageToConsole(const QString &message, const unsigned int lineNumber)
+{
+    NSDictionary *dictionary = [NSDictionary dictionaryWithObjectsAndKeys:
+        message.getNSString(), @"message",[NSNumber numberWithInt: lineNumber], @"lineNumber", NULL];
+    [_bridge addMessageToConsole:dictionary];
+}
+
 void KWQKHTMLPart::createEmptyDocument()
 {
     // Although it's not completely clear from the name of this function,
index 62e5ff5dab0507d83b76e03cdd049e2f03d26cdd..20e4884bd90090e88f56e76e36cce08da0b77641 100644 (file)
@@ -372,6 +372,7 @@ typedef enum {
 - (void)runJavaScriptAlertPanelWithMessage:(NSString *)message;
 - (BOOL)runJavaScriptConfirmPanelWithMessage:(NSString *)message;
 - (BOOL)runJavaScriptTextInputPanelWithPrompt:(NSString *)prompt defaultText:(NSString *)defaultText returningText:(NSString **)result;
+- (void)addMessageToConsole:(NSDictionary *)message;
 
 - (id <WebCoreResourceHandle>)startLoadingResource:(id <WebCoreResourceLoader>)loader withURL:(NSURL *)URL customHeaders:(NSDictionary *)customHeaders;
 - (id <WebCoreResourceHandle>)startLoadingResource:(id <WebCoreResourceLoader>)loader withURL:(NSURL *)URL customHeaders:(NSDictionary *)customHeaders postData:(NSData *)data;
index a85ba7804b2aa91cd951f273dbf3b43f8caf042a..514de7bc4c9ae5313ccc8d3db0065cddc89bac31 100644 (file)
@@ -259,7 +259,6 @@ static bool initializedKJS = FALSE;
     _part->provisionalLoadStarted();
 }
 
-
 - (void)openURL:(NSURL *)URL reload:(BOOL)reload contentType:(NSString *)contentType refresh:(NSString *)refresh lastModified:(NSDate *)lastModified pageCache:(NSDictionary *)pageCache
 {
     if (pageCache) {
index 4c7b68bf3a33a45b29d4d2e62b739af474defaff..53902d794d299c4d1930819f11cdeb87982d1e62 100644 (file)
@@ -1,3 +1,12 @@
+2004-05-27  Kevin Decker  <kdecker@apple.com>
+
+        Reviewed by NOBODY (OOPS!).
+
+        * WebCoreSupport.subproj/WebBridge.m:
+        (-[WebBridge addMessageToConsole:]):
+        * WebKit.pbproj/project.pbxproj:
+        * WebView.subproj/WebUIDelegatePrivate.h:
+
 === Safari-142 ===
 
 2004-05-27  Trey Matteson  <trey@apple.com>
index f9e4c674c67894c1016fb375690ade03876f1eaf..123ed543548c5e66de747116b66ab23349b47a28 100644 (file)
@@ -337,6 +337,14 @@ NSString *WebPluginContainerKey =   @"WebPluginContainer";
     return *result != nil;
 }
 
+- (void)addMessageToConsole:(NSDictionary *)message
+{
+    WebView *wv = [_frame webView];
+    id wd = [wv UIDelegate];
+    if ([wd respondsToSelector: @selector(webView:addMessageToConsole:)])
+        [wd webView:wv addMessageToConsole:message];
+}
+
 - (NSView <WebCoreFileButton> *)fileButtonWithDelegate:(id <WebCoreFileButtonDelegate>)delegate
 {
     return [[WebFileButton alloc] initWithBridge:self delegate:delegate];
index 50d40f574b1670d969ab78c5be69c95f079c1d7c..011829fd4c314d30e63a5e8e34e4c9448f1f2e1b 100644 (file)
                                F5E0E10902BC45F8018635CA,
                                F5B36B410281DF55018635CB,
                                F5B36B420281DF55018635CB,
-                               F5B36B450281DF9C018635CB,
                                F5B36B460281DF9C018635CB,
+                               F5B36B450281DF9C018635CB,
                                F5F7174C02885C5B018635CA,
                                F5F7174D02885C5B018635CA,
                        );
index 78eca1a00edacca929b65ad22084fac93a08b3ce..b29226dd58568fe68b3dd9239d4994ec6192d21a 100644 (file)
@@ -13,7 +13,7 @@
 - (float)webViewFooterHeight:(WebView *)sender;
 - (void)webView:(WebView *)sender drawHeaderInRect:(NSRect)rect;
 - (void)webView:(WebView *)sender drawFooterInRect:(NSRect)rect;
-
+- (void)webView:(WebView *)webView addMessageToConsole:(NSDictionary *)message;
 - (BOOL)webView:(WebView *)webView shouldBeginDragForElement:(NSDictionary *)element pasteboard:(NSPasteboard *)pasteboard mouseDownEvent:(NSEvent *)mouseDownEvent mouseDraggedEvent:(NSEvent *)mouseDraggedEvent;
 - (BOOL)webView:(WebView *)webView shouldDetermineDragOperationForDraggingInfo:(id <NSDraggingInfo>)draggingInfo dragOperation:(NSDragOperation *)dragOperation;
 - (BOOL)webView:(WebView *)webView shouldProcessDragWithDraggingInfo:(id <NSDraggingInfo>)draggingInfo;