Changeset 97836 in webkit


Ignore:
Timestamp:
Oct 18, 2011 11:57:36 PM (13 years ago)
Author:
haraken@chromium.org
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.
Location:
trunk
Files:
1 deleted
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r97831 r97836  
     12011-10-18  Kentaro Hara  <haraken@chromium.org>
     2
     3        Generate a SharedWorker constructor of V8 using [Constructor] IDL
     4        https://bugs.webkit.org/show_bug.cgi?id=67879
     5
     6        Reviewed by Hajime Morita.
     7
     8        Added test cases for an undefined name and a null name on SharedWorker constructor.
     9
     10        * fast/workers/resources/shared-worker-name.js:
     11        (test7.try.worker.port.onmessage):
     12        (test7): A test case for a null name.
     13        (test8.worker.port.onmessage):
     14        (test8): Ditto.
     15        (test9.try.worker.port.onmessage):
     16        (test9): A test case for an undefined name.
     17        (test10.worker.port.onmessage):
     18        (test10): Ditto.
     19        * fast/workers/shared-worker-constructor-expected.txt:
     20        * fast/workers/shared-worker-constructor.html:
     21        * fast/workers/shared-worker-name-expected.txt:
     22        * 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.
     23
    1242011-10-18  Johnny Ding  <jnd@chromium.org>
    225
  • trunk/LayoutTests/fast/workers/resources/shared-worker-name.js

    r48666 r97836  
    1919        done();
    2020}
    21 
    22 
    2321
    2422function test1()
     
    9492}
    9593
     94function test7()
     95{
     96    // Make sure we can create a shared worker with name 'null'.
     97    try {
     98        var worker = new SharedWorker('resources/shared-worker-common.js', 'null');
     99        testPassed("created SharedWorker with name 'null'");
     100        worker.port.postMessage("eval self.foo = 5678");
     101        worker.port.onmessage = function(event) {
     102            shouldBeEqual("setting self.foo", event.data, "self.foo = 5678: 5678");
     103            nextTest();
     104        };
     105    } catch (e) {
     106        testFailed("SharedWorker with name 'null' threw an exception: " + e);
     107        done();
     108    }
     109}
     110
     111function test8()
     112{
     113    // Creating a worker with a null name should match an existing worker with name 'null'
     114    var worker = new SharedWorker('resources/shared-worker-common.js', null);
     115    worker.port.postMessage("eval self.foo");
     116    worker.port.onmessage = function(event) {
     117        shouldBeEqual("creating worker with a null name", event.data, "self.foo: 5678");
     118        nextTest();
     119    }
     120}
     121
     122function test9()
     123{
     124    // Make sure we can create a shared worker with name 'undefined'.
     125    try {
     126        var worker = new SharedWorker('resources/shared-worker-common.js', 'undefined');
     127        testPassed("created SharedWorker with name 'undefined'");
     128        worker.port.postMessage("eval self.foo = 1111");
     129        worker.port.onmessage = function(event) {
     130            shouldBeEqual("setting self.foo", event.data, "self.foo = 1111: 1111");
     131            nextTest();
     132        };
     133    } catch (e) {
     134        testFailed("SharedWorker with name 'undefined' threw an exception: " + e);
     135        done();
     136    }
     137}
     138
     139function test10()
     140{
     141    // Creating a worker with an undefined name should match an existing worker with name 'undefined'
     142    var worker = new SharedWorker('resources/shared-worker-common.js', undefined);
     143    worker.port.postMessage("eval self.foo");
     144    worker.port.onmessage = function(event) {
     145        shouldBeEqual("creating worker with an undefined name", event.data, "self.foo: 1111");
     146        nextTest();
     147    }
     148}
     149
    96150function shouldBeEqual(description, a, b)
    97151{
  • trunk/LayoutTests/fast/workers/shared-worker-constructor-expected.txt

    r93339 r97836  
    55PASS: invoking SharedWorker constructor without arguments resulted in an exception (TypeError: Not enough arguments)
    66PASS: invoking SharedWorker constructor without name did not result in an exception
     7PASS: invoking SharedWorker constructor with null name did not result in an exception
     8PASS: invoking SharedWorker constructor with undefined name did not result in an exception
    79PASS: SharedWorker constructor succeeded: [object SharedWorker]
    810DONE
  • trunk/LayoutTests/fast/workers/shared-worker-constructor.html

    r48666 r97836  
    4646
    4747try {
     48    new SharedWorker("resources/shared-worker-common.js", null);
     49    log("PASS: invoking SharedWorker constructor with null name did not result in an exception");
     50} catch (ex) {
     51    log("FAIL: invoking SharedWorker constructor with null name resulted in an exception (" + ex + ")");
     52}
     53
     54try {
     55    new SharedWorker("resources/shared-worker-common.js", undefined);
     56    log("PASS: invoking SharedWorker constructor with undefined name did not result in an exception");
     57} catch (ex) {
     58    log("FAIL: invoking SharedWorker constructor with undefined name resulted in an exception (" + ex + ")");
     59}
     60
     61try {
    4862    var worker = new SharedWorker("resources/shared-worker-common.js", "name");
    4963    log ("PASS: SharedWorker constructor succeeded: " + worker);
  • trunk/LayoutTests/fast/workers/shared-worker-name-expected.txt

    r48666 r97836  
    1111PASS creating no-name worker with alternate URL
    1212PASS creating empty name worker with alternate URL
     13PASS created SharedWorker with name 'null'
     14PASS setting self.foo
     15PASS creating worker with a null name
     16PASS created SharedWorker with name 'undefined'
     17PASS setting self.foo
     18PASS creating worker with an undefined name
    1319
    1420TEST COMPLETE
  • trunk/LayoutTests/platform/chromium-win/fast/workers/shared-worker-constructor-expected.txt

    r56268 r97836  
    33PASS: toString exception propagated correctly.
    44PASS: trying to create workers recursively resulted in an exception (RangeError: Maximum call stack size exceeded)
    5 PASS: invoking SharedWorker constructor without arguments resulted in an exception (SyntaxError: Not enough arguments)
     5PASS: invoking SharedWorker constructor without arguments resulted in an exception (TypeError: Not enough arguments)
    66PASS: invoking SharedWorker constructor without name did not result in an exception
     7PASS: invoking SharedWorker constructor with null name did not result in an exception
     8PASS: invoking SharedWorker constructor with undefined name did not result in an exception
    79PASS: SharedWorker constructor succeeded: [object SharedWorker]
    810DONE
  • trunk/Source/WebCore/ChangeLog

    r97831 r97836  
     12011-10-18  Kentaro Hara  <haraken@chromium.org>
     2
     3        Generate a SharedWorker constructor of V8 using [Constructor] IDL
     4        https://bugs.webkit.org/show_bug.cgi?id=67879
     5
     6        Reviewed by Hajime Morita.
     7
     8        Spec: http://dev.w3.org/html5/workers/#shared-workers-and-the-sharedworker-interface
     9        This patch changed SharedWorker::create(..., context, ec) to
     10        SharedWorker::create(context, ..., ec), since a parameter specified by [CallWith]
     11        should come at the beginning (c.f. bug 69799).
     12
     13        Test: ui_tests:WorkerTest.FLAKY_SharedWorkerFastConstructor
     14              ui_tests:WorkerTest.FLAKY_SharedWorkerFastName
     15
     16        * WebCore.gypi: Removed bindings/v8/custom/V8SharedWorkerCustom.cpp
     17        * WebCore.pro: Ditto.
     18        * bindings/js/JSSharedWorkerCustom.cpp: Moved ScriptExecutionContext parameter to the beginning.
     19        (WebCore::JSSharedWorkerConstructor::constructJSSharedWorker):
     20        * bindings/v8/custom/V8SharedWorkerCustom.cpp: Removed.
     21        * workers/SharedWorker.cpp: Moved ScriptExecutionContext parameter to the beginning.
     22        (WebCore::SharedWorker::create): Ditto.
     23        * workers/SharedWorker.h: Ditto.
     24        * workers/SharedWorker.idl: Added [Constructor] IDL.
     25
    1262011-10-18  Johnny Ding  <jnd@chromium.org>
    227
  • trunk/Source/WebCore/WebCore.gypi

    r97818 r97836  
    22322232            'bindings/v8/custom/V8ScriptProfileCustom.cpp',
    22332233            'bindings/v8/custom/V8ScriptProfileNodeCustom.cpp',
    2234             'bindings/v8/custom/V8SharedWorkerCustom.cpp',
    22352234            'bindings/v8/custom/V8StorageCustom.cpp',
    22362235            'bindings/v8/custom/V8StyleSheetCustom.cpp',
  • trunk/Source/WebCore/WebCore.pro

    r97812 r97836  
    204204        bindings/v8/custom/V8WebSocketCustom.cpp \
    205205        \
    206         bindings/v8/custom/V8SharedWorkerCustom.cpp \
    207206        bindings/v8/custom/V8StorageCustom.cpp \
    208207        bindings/v8/custom/V8StyleSheetCustom.cpp \
  • trunk/Source/WebCore/bindings/js/JSSharedWorkerCustom.cpp

    r96346 r97836  
    7474    DOMWindow* window = asJSDOMWindow(exec->lexicalGlobalObject())->impl();
    7575    ExceptionCode ec = 0;
    76     RefPtr<SharedWorker> worker = SharedWorker::create(ustringToString(scriptURL), ustringToString(name), window->document(), ec);
     76    RefPtr<SharedWorker> worker = SharedWorker::create(window->document(), ustringToString(scriptURL), ustringToString(name), ec);
    7777    if (ec) {
    7878        setDOMException(exec, ec);
  • trunk/Source/WebCore/workers/SharedWorker.cpp

    r95901 r97836  
    5050}
    5151
    52 PassRefPtr<SharedWorker> SharedWorker::create(const String& url, const String& name, ScriptExecutionContext* context, ExceptionCode& ec)
     52PassRefPtr<SharedWorker> SharedWorker::create(ScriptExecutionContext* context, const String& url, const String& name, ExceptionCode& ec)
    5353{
    5454    RefPtr<SharedWorker> worker = adoptRef(new SharedWorker(context));
  • trunk/Source/WebCore/workers/SharedWorker.h

    r95901 r97836  
    4141    class SharedWorker : public AbstractWorker {
    4242    public:
    43         static PassRefPtr<SharedWorker> create(const String& url, const String& name, ScriptExecutionContext*, ExceptionCode&);
     43        static PassRefPtr<SharedWorker> create(ScriptExecutionContext*, const String& url, const String& name, ExceptionCode&);
    4444        virtual ~SharedWorker();
    4545
  • trunk/Source/WebCore/workers/SharedWorker.idl

    r96788 r97836  
    3636        ActiveDOMObject,
    3737        CanBeConstructed,
    38         CustomConstructor,
     38        JSCustomConstructor,
    3939        ConstructorParameters=2,
     40        Constructor(in DOMString scriptURL, in [Optional=CallWithNullValue] DOMString name),
     41        CallWith=ScriptExecutionContext,
     42        ConstructorRaisesException,
     43        V8ConstructorSetsActiveDOMWrapper,
    4044        CustomMarkFunction,
    4145        GenerateNativeConverter,
Note: See TracChangeset for help on using the changeset viewer.