Title: [97836] trunk
Revision
97836
Author
[email protected]
Date
2011-10-18 23:57:36 -0700 (Tue, 18 Oct 2011)

Log Message

Generate a SharedWorker constructor of V8 using [Constructor] IDL
https://bugs.webkit.org/show_bug.cgi?id=67879

Reviewed by Hajime Morita.

Source/WebCore:

Spec: http://dev.w3.org/html5/workers/#shared-workers-and-the-sharedworker-interface
This patch changed SharedWorker::create(..., context, ec) to
SharedWorker::create(context, ..., ec), since a parameter specified by [CallWith]
should come at the beginning (c.f. bug 69799).

Test: ui_tests:WorkerTest.FLAKY_SharedWorkerFastConstructor
      ui_tests:WorkerTest.FLAKY_SharedWorkerFastName

* WebCore.gypi: Removed bindings/v8/custom/V8SharedWorkerCustom.cpp
* WebCore.pro: Ditto.
* bindings/js/JSSharedWorkerCustom.cpp: Moved ScriptExecutionContext parameter to the beginning.
(WebCore::JSSharedWorkerConstructor::constructJSSharedWorker):
* bindings/v8/custom/V8SharedWorkerCustom.cpp: Removed.
* workers/SharedWorker.cpp: Moved ScriptExecutionContext parameter to the beginning.
(WebCore::SharedWorker::create): Ditto.
* workers/SharedWorker.h: Ditto.
* workers/SharedWorker.idl: Added [Constructor] IDL.

LayoutTests:

Added test cases for an undefined name and a null name on SharedWorker constructor.

* fast/workers/resources/shared-worker-name.js:
(test7.try.worker.port.onmessage):
(test7): A test case for a null name.
(test8.worker.port.onmessage):
(test8): Ditto.
(test9.try.worker.port.onmessage):
(test9): A test case for an undefined name.
(test10.worker.port.onmessage):
(test10): Ditto.
* fast/workers/shared-worker-constructor-expected.txt:
* fast/workers/shared-worker-constructor.html:
* fast/workers/shared-worker-name-expected.txt:
* platform/chromium-win/fast/workers/shared-worker-constructor-expected.txt: Updated SyntaxError with TypeError. The reason why ui_tests has been so far working without updating this error type is that shared-worker-constructor.html is marked FLAKY in chromium.

Modified Paths

Removed Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (97835 => 97836)


--- trunk/LayoutTests/ChangeLog	2011-10-19 06:42:29 UTC (rev 97835)
+++ trunk/LayoutTests/ChangeLog	2011-10-19 06:57:36 UTC (rev 97836)
@@ -1,3 +1,26 @@
+2011-10-18  Kentaro Hara  <[email protected]>
+
+        Generate a SharedWorker constructor of V8 using [Constructor] IDL
+        https://bugs.webkit.org/show_bug.cgi?id=67879
+
+        Reviewed by Hajime Morita.
+
+        Added test cases for an undefined name and a null name on SharedWorker constructor.
+
+        * fast/workers/resources/shared-worker-name.js:
+        (test7.try.worker.port.onmessage):
+        (test7): A test case for a null name.
+        (test8.worker.port.onmessage):
+        (test8): Ditto.
+        (test9.try.worker.port.onmessage):
+        (test9): A test case for an undefined name.
+        (test10.worker.port.onmessage):
+        (test10): Ditto.
+        * fast/workers/shared-worker-constructor-expected.txt:
+        * fast/workers/shared-worker-constructor.html:
+        * fast/workers/shared-worker-name-expected.txt:
+        * platform/chromium-win/fast/workers/shared-worker-constructor-expected.txt: Updated SyntaxError with TypeError. The reason why ui_tests has been so far working without updating this error type is that shared-worker-constructor.html is marked FLAKY in chromium.
+
 2011-10-18  Johnny Ding  <[email protected]>
 
         Enable touch tests on Mac Leopard. 

Modified: trunk/LayoutTests/fast/workers/resources/shared-worker-name.js (97835 => 97836)


--- trunk/LayoutTests/fast/workers/resources/shared-worker-name.js	2011-10-19 06:42:29 UTC (rev 97835)
+++ trunk/LayoutTests/fast/workers/resources/shared-worker-name.js	2011-10-19 06:57:36 UTC (rev 97836)
@@ -19,8 +19,6 @@
         done();
 }
 
-
-
 function test1()
 {
     // Make sure we can create a shared worker with no name.
@@ -93,6 +91,62 @@
     };
 }
 
+function test7()
+{
+    // Make sure we can create a shared worker with name 'null'.
+    try {
+        var worker = new SharedWorker('resources/shared-worker-common.js', 'null');
+        testPassed("created SharedWorker with name 'null'");
+        worker.port.postMessage("eval self.foo = 5678");
+        worker.port._onmessage_ = function(event) {
+            shouldBeEqual("setting self.foo", event.data, "self.foo = 5678: 5678");
+            nextTest();
+        };
+    } catch (e) {
+        testFailed("SharedWorker with name 'null' threw an exception: " + e);
+        done();
+    }
+}
+
+function test8()
+{
+    // Creating a worker with a null name should match an existing worker with name 'null'
+    var worker = new SharedWorker('resources/shared-worker-common.js', null);
+    worker.port.postMessage("eval self.foo");
+    worker.port._onmessage_ = function(event) {
+        shouldBeEqual("creating worker with a null name", event.data, "self.foo: 5678");
+        nextTest();
+    }
+}
+
+function test9()
+{
+    // Make sure we can create a shared worker with name 'undefined'.
+    try {
+        var worker = new SharedWorker('resources/shared-worker-common.js', 'undefined');
+        testPassed("created SharedWorker with name 'undefined'");
+        worker.port.postMessage("eval self.foo = 1111");
+        worker.port._onmessage_ = function(event) {
+            shouldBeEqual("setting self.foo", event.data, "self.foo = 1111: 1111");
+            nextTest();
+        };
+    } catch (e) {
+        testFailed("SharedWorker with name 'undefined' threw an exception: " + e);
+        done();
+    }
+}
+
+function test10()
+{
+    // Creating a worker with an undefined name should match an existing worker with name 'undefined'
+    var worker = new SharedWorker('resources/shared-worker-common.js', undefined);
+    worker.port.postMessage("eval self.foo");
+    worker.port._onmessage_ = function(event) {
+        shouldBeEqual("creating worker with an undefined name", event.data, "self.foo: 1111");
+        nextTest();
+    }
+}
+
 function shouldBeEqual(description, a, b)
 {
     if (a == b)

Modified: trunk/LayoutTests/fast/workers/shared-worker-constructor-expected.txt (97835 => 97836)


--- trunk/LayoutTests/fast/workers/shared-worker-constructor-expected.txt	2011-10-19 06:42:29 UTC (rev 97835)
+++ trunk/LayoutTests/fast/workers/shared-worker-constructor-expected.txt	2011-10-19 06:57:36 UTC (rev 97836)
@@ -4,6 +4,8 @@
 PASS: trying to create workers recursively resulted in an exception (RangeError: Maximum call stack size exceeded.)
 PASS: invoking SharedWorker constructor without arguments resulted in an exception (TypeError: Not enough arguments)
 PASS: invoking SharedWorker constructor without name did not result in an exception
+PASS: invoking SharedWorker constructor with null name did not result in an exception
+PASS: invoking SharedWorker constructor with undefined name did not result in an exception
 PASS: SharedWorker constructor succeeded: [object SharedWorker]
 DONE
 

Modified: trunk/LayoutTests/fast/workers/shared-worker-constructor.html (97835 => 97836)


--- trunk/LayoutTests/fast/workers/shared-worker-constructor.html	2011-10-19 06:42:29 UTC (rev 97835)
+++ trunk/LayoutTests/fast/workers/shared-worker-constructor.html	2011-10-19 06:57:36 UTC (rev 97836)
@@ -45,6 +45,20 @@
 }
 
 try {
+    new SharedWorker("resources/shared-worker-common.js", null);
+    log("PASS: invoking SharedWorker constructor with null name did not result in an exception");
+} catch (ex) {
+    log("FAIL: invoking SharedWorker constructor with null name resulted in an exception (" + ex + ")");
+}
+
+try {
+    new SharedWorker("resources/shared-worker-common.js", undefined);
+    log("PASS: invoking SharedWorker constructor with undefined name did not result in an exception");
+} catch (ex) {
+    log("FAIL: invoking SharedWorker constructor with undefined name resulted in an exception (" + ex + ")");
+}
+
+try {
     var worker = new SharedWorker("resources/shared-worker-common.js", "name");
     log ("PASS: SharedWorker constructor succeeded: " + worker);
 } catch (ex) {

Modified: trunk/LayoutTests/fast/workers/shared-worker-name-expected.txt (97835 => 97836)


--- trunk/LayoutTests/fast/workers/shared-worker-name-expected.txt	2011-10-19 06:42:29 UTC (rev 97835)
+++ trunk/LayoutTests/fast/workers/shared-worker-name-expected.txt	2011-10-19 06:57:36 UTC (rev 97836)
@@ -10,6 +10,12 @@
 PASS creating worker with different name but same URL
 PASS creating no-name worker with alternate URL
 PASS creating empty name worker with alternate URL
+PASS created SharedWorker with name 'null'
+PASS setting self.foo
+PASS creating worker with a null name
+PASS created SharedWorker with name 'undefined'
+PASS setting self.foo
+PASS creating worker with an undefined name
 
 TEST COMPLETE
 

Modified: trunk/LayoutTests/platform/chromium-win/fast/workers/shared-worker-constructor-expected.txt (97835 => 97836)


--- trunk/LayoutTests/platform/chromium-win/fast/workers/shared-worker-constructor-expected.txt	2011-10-19 06:42:29 UTC (rev 97835)
+++ trunk/LayoutTests/platform/chromium-win/fast/workers/shared-worker-constructor-expected.txt	2011-10-19 06:57:36 UTC (rev 97836)
@@ -2,8 +2,10 @@
 
 PASS: toString exception propagated correctly.
 PASS: trying to create workers recursively resulted in an exception (RangeError: Maximum call stack size exceeded)
-PASS: invoking SharedWorker constructor without arguments resulted in an exception (SyntaxError: Not enough arguments)
+PASS: invoking SharedWorker constructor without arguments resulted in an exception (TypeError: Not enough arguments)
 PASS: invoking SharedWorker constructor without name did not result in an exception
+PASS: invoking SharedWorker constructor with null name did not result in an exception
+PASS: invoking SharedWorker constructor with undefined name did not result in an exception
 PASS: SharedWorker constructor succeeded: [object SharedWorker]
 DONE
 

Modified: trunk/Source/WebCore/ChangeLog (97835 => 97836)


--- trunk/Source/WebCore/ChangeLog	2011-10-19 06:42:29 UTC (rev 97835)
+++ trunk/Source/WebCore/ChangeLog	2011-10-19 06:57:36 UTC (rev 97836)
@@ -1,3 +1,28 @@
+2011-10-18  Kentaro Hara  <[email protected]>
+
+        Generate a SharedWorker constructor of V8 using [Constructor] IDL
+        https://bugs.webkit.org/show_bug.cgi?id=67879
+
+        Reviewed by Hajime Morita.
+
+        Spec: http://dev.w3.org/html5/workers/#shared-workers-and-the-sharedworker-interface
+        This patch changed SharedWorker::create(..., context, ec) to
+        SharedWorker::create(context, ..., ec), since a parameter specified by [CallWith]
+        should come at the beginning (c.f. bug 69799).
+
+        Test: ui_tests:WorkerTest.FLAKY_SharedWorkerFastConstructor
+              ui_tests:WorkerTest.FLAKY_SharedWorkerFastName
+
+        * WebCore.gypi: Removed bindings/v8/custom/V8SharedWorkerCustom.cpp
+        * WebCore.pro: Ditto.
+        * bindings/js/JSSharedWorkerCustom.cpp: Moved ScriptExecutionContext parameter to the beginning.
+        (WebCore::JSSharedWorkerConstructor::constructJSSharedWorker):
+        * bindings/v8/custom/V8SharedWorkerCustom.cpp: Removed.
+        * workers/SharedWorker.cpp: Moved ScriptExecutionContext parameter to the beginning.
+        (WebCore::SharedWorker::create): Ditto.
+        * workers/SharedWorker.h: Ditto.
+        * workers/SharedWorker.idl: Added [Constructor] IDL.
+
 2011-10-18  Johnny Ding  <[email protected]>
 
         Implement NSProcessInfo::systemUptime on Mac Leopard.

Modified: trunk/Source/WebCore/WebCore.gypi (97835 => 97836)


--- trunk/Source/WebCore/WebCore.gypi	2011-10-19 06:42:29 UTC (rev 97835)
+++ trunk/Source/WebCore/WebCore.gypi	2011-10-19 06:57:36 UTC (rev 97836)
@@ -2231,7 +2231,6 @@
             'bindings/v8/custom/V8SVGPathSegCustom.cpp',
             'bindings/v8/custom/V8ScriptProfileCustom.cpp',
             'bindings/v8/custom/V8ScriptProfileNodeCustom.cpp',
-            'bindings/v8/custom/V8SharedWorkerCustom.cpp',
             'bindings/v8/custom/V8StorageCustom.cpp',
             'bindings/v8/custom/V8StyleSheetCustom.cpp',
             'bindings/v8/custom/V8StyleSheetListCustom.cpp',

Modified: trunk/Source/WebCore/WebCore.pro (97835 => 97836)


--- trunk/Source/WebCore/WebCore.pro	2011-10-19 06:42:29 UTC (rev 97835)
+++ trunk/Source/WebCore/WebCore.pro	2011-10-19 06:57:36 UTC (rev 97836)
@@ -203,7 +203,6 @@
         bindings/v8/custom/V8SQLTransactionCustom.cpp \
         bindings/v8/custom/V8WebSocketCustom.cpp \
         \
-        bindings/v8/custom/V8SharedWorkerCustom.cpp \
         bindings/v8/custom/V8StorageCustom.cpp \
         bindings/v8/custom/V8StyleSheetCustom.cpp \
         bindings/v8/custom/V8StyleSheetListCustom.cpp \

Modified: trunk/Source/WebCore/bindings/js/JSSharedWorkerCustom.cpp (97835 => 97836)


--- trunk/Source/WebCore/bindings/js/JSSharedWorkerCustom.cpp	2011-10-19 06:42:29 UTC (rev 97835)
+++ trunk/Source/WebCore/bindings/js/JSSharedWorkerCustom.cpp	2011-10-19 06:57:36 UTC (rev 97836)
@@ -73,7 +73,7 @@
     // 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);
+    RefPtr<SharedWorker> worker = SharedWorker::create(window->document(), ustringToString(scriptURL), ustringToString(name), ec);
     if (ec) {
         setDOMException(exec, ec);
         return JSValue::encode(JSValue());

Deleted: trunk/Source/WebCore/bindings/v8/custom/V8SharedWorkerCustom.cpp (97835 => 97836)


--- trunk/Source/WebCore/bindings/v8/custom/V8SharedWorkerCustom.cpp	2011-10-19 06:42:29 UTC (rev 97835)
+++ trunk/Source/WebCore/bindings/v8/custom/V8SharedWorkerCustom.cpp	2011-10-19 06:57:36 UTC (rev 97836)
@@ -1,93 +0,0 @@
-/*
- * Copyright (C) 2009 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *     * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- *     * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#if ENABLE(SHARED_WORKERS)
-
-#include "V8SharedWorker.h"
-
-#include "ExceptionCode.h"
-#include "Frame.h"
-#include "V8Binding.h"
-#include "V8Proxy.h"
-#include "V8Utilities.h"
-#include "WorkerContext.h"
-#include "WorkerContextExecutionProxy.h"
-
-namespace WebCore {
-
-v8::Handle<v8::Value> V8SharedWorker::constructorCallback(const v8::Arguments& args)
-{
-    INC_STATS(L"DOM.SharedWorker.Constructor");
-
-    if (!args.IsConstructCall())
-        return throwError("DOM object constructor cannot be called as a function.", V8Proxy::TypeError);
-
-    if (!args.Length())
-        return throwError("Not enough arguments", V8Proxy::TypeError);
-
-    v8::TryCatch tryCatch;
-    v8::Handle<v8::String> scriptUrl = args[0]->ToString();
-    String name;
-    if (args.Length() > 1)
-        name = toWebCoreString(args[1]->ToString());
-
-    if (tryCatch.HasCaught())
-        return throwError(tryCatch.Exception());
-
-    if (scriptUrl.IsEmpty())
-        return v8::Undefined();
-
-    // Get the script execution context.
-    ScriptExecutionContext* context = getScriptExecutionContext();
-    if (!context)
-        return v8::Undefined();
-
-    // Create the SharedWorker object.
-    // Note: it's OK to let this RefPtr go out of scope because we also call SetDOMWrapper(), which effectively holds a reference to obj.
-    ExceptionCode ec = 0;
-    RefPtr<SharedWorker> obj = SharedWorker::create(toWebCoreString(scriptUrl), name, context, ec);
-    if (ec)
-        return throwError(ec);
-
-    // Setup the standard wrapper object internal fields.
-    v8::Handle<v8::Object> wrapperObject = args.Holder();
-    V8DOMWrapper::setDOMWrapper(wrapperObject, &info, obj.get());
-
-    obj->ref();
-    V8DOMWrapper::setJSWrapperForActiveDOMObject(obj.get(), v8::Persistent<v8::Object>::New(wrapperObject));
-
-    return wrapperObject;
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(SHARED_WORKERS)

Modified: trunk/Source/WebCore/workers/SharedWorker.cpp (97835 => 97836)


--- trunk/Source/WebCore/workers/SharedWorker.cpp	2011-10-19 06:42:29 UTC (rev 97835)
+++ trunk/Source/WebCore/workers/SharedWorker.cpp	2011-10-19 06:57:36 UTC (rev 97836)
@@ -49,7 +49,7 @@
 {
 }
 
-PassRefPtr<SharedWorker> SharedWorker::create(const String& url, const String& name, ScriptExecutionContext* context, ExceptionCode& ec)
+PassRefPtr<SharedWorker> SharedWorker::create(ScriptExecutionContext* context, const String& url, const String& name, ExceptionCode& ec)
 {
     RefPtr<SharedWorker> worker = adoptRef(new SharedWorker(context));
 

Modified: trunk/Source/WebCore/workers/SharedWorker.h (97835 => 97836)


--- trunk/Source/WebCore/workers/SharedWorker.h	2011-10-19 06:42:29 UTC (rev 97835)
+++ trunk/Source/WebCore/workers/SharedWorker.h	2011-10-19 06:57:36 UTC (rev 97836)
@@ -40,7 +40,7 @@
 
     class SharedWorker : public AbstractWorker {
     public:
-        static PassRefPtr<SharedWorker> create(const String& url, const String& name, ScriptExecutionContext*, ExceptionCode&);
+        static PassRefPtr<SharedWorker> create(ScriptExecutionContext*, const String& url, const String& name, ExceptionCode&);
         virtual ~SharedWorker();
 
         MessagePort* port() const { return m_port.get(); }

Modified: trunk/Source/WebCore/workers/SharedWorker.idl (97835 => 97836)


--- trunk/Source/WebCore/workers/SharedWorker.idl	2011-10-19 06:42:29 UTC (rev 97835)
+++ trunk/Source/WebCore/workers/SharedWorker.idl	2011-10-19 06:57:36 UTC (rev 97836)
@@ -35,8 +35,12 @@
         Conditional=SHARED_WORKERS,
         ActiveDOMObject,
         CanBeConstructed,
-        CustomConstructor,
+        JSCustomConstructor,
         ConstructorParameters=2,
+        Constructor(in DOMString scriptURL, in [Optional=CallWithNullValue] DOMString name),
+        CallWith=ScriptExecutionContext,
+        ConstructorRaisesException,
+        V8ConstructorSetsActiveDOMWrapper,
         CustomMarkFunction,
         GenerateNativeConverter,
         GenerateToJS
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to