Bundle should expose a reportException method.
authorjberlin@webkit.org <jberlin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Oct 2010 14:56:21 +0000 (14:56 +0000)
committerjberlin@webkit.org <jberlin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Oct 2010 14:56:21 +0000 (14:56 +0000)
https://bugs.webkit.org/show_bug.cgi?id=46769

Reviewed by John Sullivan.

* WebProcess/InjectedBundle/API/c/WKBundle.cpp:
(WKBundleReportException):
* WebProcess/InjectedBundle/API/c/WKBundle.h:

* WebProcess/InjectedBundle/InjectedBundle.cpp:
(WebKit::InjectedBundle::reportException):
Mimic the behavior of WebView::reportException.
* WebProcess/InjectedBundle/InjectedBundle.h:

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

WebKit2/ChangeLog
WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp
WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.h
WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp
WebKit2/WebProcess/InjectedBundle/InjectedBundle.h

index a6b300e..156000a 100644 (file)
@@ -1,3 +1,19 @@
+2010-10-06  Jessie Berlin  <jberlin@apple.com>
+
+        Reviewed by John Sullivan.
+
+        Bundle should expose a reportException method.
+        https://bugs.webkit.org/show_bug.cgi?id=46769
+
+        * WebProcess/InjectedBundle/API/c/WKBundle.cpp:
+        (WKBundleReportException):
+        * WebProcess/InjectedBundle/API/c/WKBundle.h:
+
+        * WebProcess/InjectedBundle/InjectedBundle.cpp:
+        (WebKit::InjectedBundle::reportException):
+        Mimic the behavior of WebView::reportException.
+        * WebProcess/InjectedBundle/InjectedBundle.h:
+
 2010-10-07  Luiz Agostini  <luiz.agostini@openbossa.org>
 
         Reviewed by Adam Roben.
index 1594125..8ea9209 100644 (file)
@@ -126,3 +126,8 @@ void WKBundleOverrideXSSAuditorEnabledForTestRunner(WKBundleRef bundleRef, bool
 {
     toImpl(bundleRef)->overrideXSSAuditorEnabledForTestRunner(enabled);
 }
+
+void WKBundleReportException(JSContextRef context, JSValueRef exception)
+{
+    InjectedBundle::reportException(context, exception);
+}
index 62b2894..ec2d03d 100644 (file)
@@ -26,6 +26,7 @@
 #ifndef WKBundle_h
 #define WKBundle_h
 
+#include <JavaScriptCore/JavaScript.h>
 #include <WebKit2/WKBase.h>
 
 #ifdef __cplusplus
@@ -53,6 +54,8 @@ WK_EXPORT void WKBundleSetClient(WKBundleRef bundle, WKBundleClient * client);
 WK_EXPORT void WKBundlePostMessage(WKBundleRef bundle, WKStringRef messageName, WKTypeRef messageBody);
 WK_EXPORT void WKBundlePostSynchronousMessage(WKBundleRef bundle, WKStringRef messageName, WKTypeRef messageBody, WKTypeRef* returnData);
 
+WK_EXPORT void WKBundleReportException(JSContextRef, JSValueRef exception);
+
 #ifdef __cplusplus
 }
 #endif
index 43f2357..16f972a 100644 (file)
@@ -37,6 +37,7 @@
 #include "WebPage.h"
 #include "WebPreferencesStore.h"
 #include "WebProcess.h"
+#include <JavaScriptCore/APICast.h>
 #include <JavaScriptCore/JSLock.h>
 #include <WebCore/GCController.h>
 #include <WebCore/JSDOMWindow.h>
@@ -220,4 +221,19 @@ void InjectedBundle::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC:
     ASSERT_NOT_REACHED();
 }
 
+void InjectedBundle::reportException(JSContextRef context, JSValueRef exception)
+{
+    if (!context || !exception)
+        return;
+
+    JSLock lock(JSC::SilenceAssertionsOnly);
+    JSC::ExecState* execState = toJS(context);
+
+    // Make sure the context has a DOMWindow global object, otherwise this context didn't originate from a Page.
+    if (!toJSDOMWindow(execState->lexicalGlobalObject()))
+        return;
+
+    WebCore::reportException(execState, toJS(execState, exception));
+}
+
 } // namespace WebKit
index f540db9..3132e1d 100644 (file)
@@ -105,6 +105,8 @@ public:
 
     void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
 
+    static void reportException(JSContextRef, JSValueRef exception);
+
 private:
     InjectedBundle(const String&);