diff options
Diffstat (limited to 'WebCore/bindings/js/JSSharedWorkerCustom.cpp')
-rw-r--r-- | WebCore/bindings/js/JSSharedWorkerCustom.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/WebCore/bindings/js/JSSharedWorkerCustom.cpp b/WebCore/bindings/js/JSSharedWorkerCustom.cpp index 4617087..261ae2b 100644 --- a/WebCore/bindings/js/JSSharedWorkerCustom.cpp +++ b/WebCore/bindings/js/JSSharedWorkerCustom.cpp @@ -35,7 +35,9 @@ #include "JSSharedWorker.h" #include "JSDOMGlobalObject.h" +#include "JSDOMWindowCustom.h" #include "SharedWorker.h" +#include <runtime/Error.h> using namespace JSC; @@ -49,6 +51,30 @@ void JSSharedWorker::markChildren(MarkStack& markStack) markDOMObjectWrapper(markStack, *Heap::heap(this)->globalData(), port); } +EncodedJSValue JSC_HOST_CALL JSSharedWorkerConstructor::constructJSSharedWorker(ExecState* exec) +{ + JSSharedWorkerConstructor* jsConstructor = static_cast<JSSharedWorkerConstructor*>(exec->callee()); + + if (exec->argumentCount() < 1) + return throwVMError(exec, createSyntaxError(exec, "Not enough arguments")); + + UString scriptURL = exec->argument(0).toString(exec); + UString name; + if (exec->argumentCount() > 1) + name = exec->argument(1).toString(exec); + + if (exec->hadException()) + return JSValue::encode(JSValue()); + + // FIXME: We need to use both the dynamic scope and the lexical scope (dynamic scope for resolving the worker URL) + DOMWindow* window = asJSDOMWindow(exec->lexicalGlobalObject())->impl(); + ExceptionCode ec = 0; + RefPtr<SharedWorker> worker = SharedWorker::create(ustringToString(scriptURL), ustringToString(name), window->document(), ec); + setDOMException(exec, ec); + + return JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), worker.release()))); +} + } // namespace WebCore #endif // ENABLE(SHARED_WORKERS) |