2009-06-16 Jian Li <jianli@chromium.org>
authorjianli@chromium.org <jianli@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 16 Jun 2009 22:28:21 +0000 (22:28 +0000)
committerjianli@chromium.org <jianli@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 16 Jun 2009 22:28:21 +0000 (22:28 +0000)
        Reviewed by Dimitri Glazkov.

        Bug 26456: Hook up V8 bindings for Worker's importScripts functionality.
        https://bugs.webkit.org/show_bug.cgi?id=26456

        * bindings/v8/custom/V8WorkerContextCustom.cpp:
        (WebCore::CALLBACK_FUNC_DECL):
        * bindings/v8/custom/V8WorkerCustom.cpp: Fixed missing exception code
          handling in Worker constructor for V8 bindings.
        (WebCore::CALLBACK_FUNC_DECL):

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

WebCore/ChangeLog
WebCore/bindings/v8/custom/V8WorkerContextCustom.cpp
WebCore/bindings/v8/custom/V8WorkerCustom.cpp

index 4bfefae..3eb5899 100644 (file)
@@ -1,3 +1,16 @@
+2009-06-16  Jian Li  <jianli@chromium.org>
+
+        Reviewed by Dimitri Glazkov.
+
+        Bug 26456: Hook up V8 bindings for Worker's importScripts functionality.
+        https://bugs.webkit.org/show_bug.cgi?id=26456
+
+        * bindings/v8/custom/V8WorkerContextCustom.cpp:
+        (WebCore::CALLBACK_FUNC_DECL):
+        * bindings/v8/custom/V8WorkerCustom.cpp: Fixed missing exception code
+          handling in Worker constructor for V8 bindings.
+        (WebCore::CALLBACK_FUNC_DECL):
+
 2009-06-16  Brent Fulgham  <bfulgham@webkit.org>
 
         Reviewed by Maciej Stachowiak.
index a67cb10..aa36bac 100755 (executable)
@@ -36,7 +36,6 @@
 
 #include "ExceptionCode.h"
 #include "DOMTimer.h"
-#include "NotImplemented.h"
 #include "ScheduledAction.h"
 #include "V8Binding.h"
 #include "V8CustomBinding.h"
@@ -129,7 +128,29 @@ v8::Handle<v8::Value> SetTimeoutOrInterval(const v8::Arguments& args, bool singl
 CALLBACK_FUNC_DECL(WorkerContextImportScripts)
 {
     INC_STATS(L"DOM.WorkerContext.importScripts()");
-    notImplemented();
+    if (!args.Length())
+        return v8::Undefined();
+
+    String callerURL = V8Proxy::GetSourceName();
+    int callerLine = V8Proxy::GetSourceLineNumber() + 1;
+
+    Vector<String> urls;
+    for (int i = 0; i < args.Length(); i++) {
+        v8::TryCatch tryCatch;
+        v8::Handle<v8::String> scriptUrl = args[i]->ToString();
+        if (tryCatch.HasCaught() || scriptUrl.IsEmpty())
+            return v8::Undefined();
+        urls.append(toWebCoreString(scriptUrl));
+    }
+
+    WorkerContext* workerContext = V8Proxy::ToNativeObject<WorkerContext>(V8ClassIndex::WORKERCONTEXT, args.Holder());
+
+    ExceptionCode ec = 0;
+    workerContext->importScripts(urls, callerURL, callerLine, ec);
+
+    if (ec)
+        return throwError(ec);
+
     return v8::Undefined();
 }
 
index 3edaa8e..fd3ed6e 100755 (executable)
@@ -87,6 +87,9 @@ CALLBACK_FUNC_DECL(WorkerConstructor)
     ExceptionCode ec = 0;
     RefPtr<Worker> obj = Worker::create(toWebCoreString(scriptUrl), context, ec);
 
+    if (ec)
+        return throwError(ec);
+
     // Setup the standard wrapper object internal fields.
     v8::Handle<v8::Object> wrapperObject = args.Holder();
     V8Proxy::SetDOMWrapper(wrapperObject, V8ClassIndex::WORKER, obj.get());