summaryrefslogtreecommitdiffstats
path: root/WebCore/bindings/v8/V8Utilities.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/bindings/v8/V8Utilities.cpp')
-rw-r--r--WebCore/bindings/v8/V8Utilities.cpp52
1 files changed, 49 insertions, 3 deletions
diff --git a/WebCore/bindings/v8/V8Utilities.cpp b/WebCore/bindings/v8/V8Utilities.cpp
index c1ac6d4..a66f435 100644
--- a/WebCore/bindings/v8/V8Utilities.cpp
+++ b/WebCore/bindings/v8/V8Utilities.cpp
@@ -33,8 +33,15 @@
#include <v8.h>
+#include "Document.h"
+#include "Frame.h"
+#include "ScriptExecutionContext.h"
+#include "ScriptState.h"
#include "V8CustomBinding.h"
+#include "V8Binding.h"
#include "V8Proxy.h"
+#include "WorkerContext.h"
+#include "WorkerContextExecutionProxy.h"
#include <wtf/Assertions.h>
#include "Frame.h"
@@ -43,7 +50,7 @@ namespace WebCore {
// Use an array to hold dependents. It works like a ref-counted scheme.
// A value can be added more than once to the DOM object.
-void createHiddenDependency(v8::Local<v8::Object> object, v8::Local<v8::Value> value, int cacheIndex)
+void createHiddenDependency(v8::Handle<v8::Object> object, v8::Local<v8::Value> value, int cacheIndex)
{
v8::Local<v8::Value> cache = object->GetInternalField(cacheIndex);
if (cache->IsNull() || cache->IsUndefined()) {
@@ -55,7 +62,7 @@ void createHiddenDependency(v8::Local<v8::Object> object, v8::Local<v8::Value> v
cacheArray->Set(v8::Integer::New(cacheArray->Length()), value);
}
-void removeHiddenDependency(v8::Local<v8::Object> object, v8::Local<v8::Value> value, int cacheIndex)
+void removeHiddenDependency(v8::Handle<v8::Object> object, v8::Local<v8::Value> value, int cacheIndex)
{
v8::Local<v8::Value> cache = object->GetInternalField(cacheIndex);
if (!cache->IsArray())
@@ -98,7 +105,46 @@ void navigateIfAllowed(Frame* frame, const KURL& url, bool lockHistory, bool loc
return;
if (!protocolIsJavaScript(url) || ScriptController::isSafeScript(frame))
- frame->loader()->scheduleLocationChange(url.string(), callingFrame->loader()->outgoingReferrer(), lockHistory, lockBackForwardList, processingUserGesture());
+ frame->redirectScheduler()->scheduleLocationChange(url.string(), callingFrame->loader()->outgoingReferrer(), lockHistory, lockBackForwardList, processingUserGesture());
+}
+
+ScriptExecutionContext* getScriptExecutionContext(ScriptState* scriptState)
+{
+#if ENABLE(WORKERS)
+ WorkerContextExecutionProxy* proxy = WorkerContextExecutionProxy::retrieve();
+ if (proxy)
+ return proxy->workerContext()->scriptExecutionContext();
+#endif
+
+ if (scriptState)
+ return scriptState->frame()->document()->scriptExecutionContext();
+ else {
+ Frame* frame = V8Proxy::retrieveFrameForCurrentContext();
+ if (frame)
+ return frame->document()->scriptExecutionContext();
+ }
+
+ return 0;
+}
+
+void reportException(ScriptState* scriptState, v8::TryCatch& exceptionCatcher)
+{
+ String errorMessage;
+ int lineNumber = 0;
+ String sourceURL;
+
+ // There can be a situation that an exception is thrown without setting a message.
+ v8::Local<v8::Message> message = exceptionCatcher.Message();
+ if (message.IsEmpty())
+ errorMessage = toWebCoreString(exceptionCatcher.Exception()->ToString());
+ else {
+ errorMessage = toWebCoreString(message->Get());
+ lineNumber = message->GetLineNumber();
+ sourceURL = toWebCoreString(message->GetScriptResourceName());
+ }
+
+ getScriptExecutionContext(scriptState)->reportException(errorMessage, lineNumber, sourceURL);
+ exceptionCatcher.Reset();
}
} // namespace WebCore