Skip to content

Commit 423581b

Browse files
committed
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. Canonical link: https://commits.webkit.org/86551@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@97836 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 3c62ad9 commit 423581b

14 files changed

Lines changed: 137 additions & 102 deletions

LayoutTests/ChangeLog

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
1+
2011-10-18 Kentaro Hara <[email protected]>
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+
124
2011-10-18 Johnny Ding <[email protected]>
225

326
Enable touch tests on Mac Leopard.

LayoutTests/fast/workers/resources/shared-worker-name.js

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ function nextTest()
1919
done();
2020
}
2121

22-
23-
2422
function test1()
2523
{
2624
// Make sure we can create a shared worker with no name.
@@ -93,6 +91,62 @@ function test6()
9391
};
9492
}
9593

94+
function 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+
111+
function 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+
122+
function 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+
139+
function 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+
96150
function shouldBeEqual(description, a, b)
97151
{
98152
if (a == b)

LayoutTests/fast/workers/shared-worker-constructor-expected.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ PASS: toString exception propagated correctly.
44
PASS: trying to create workers recursively resulted in an exception (RangeError: Maximum call stack size exceeded.)
55
PASS: invoking SharedWorker constructor without arguments resulted in an exception (TypeError: Not enough arguments)
66
PASS: invoking SharedWorker constructor without name did not result in an exception
7+
PASS: invoking SharedWorker constructor with null name did not result in an exception
8+
PASS: invoking SharedWorker constructor with undefined name did not result in an exception
79
PASS: SharedWorker constructor succeeded: [object SharedWorker]
810
DONE
911

LayoutTests/fast/workers/shared-worker-constructor.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,20 @@
4444
log("FAIL: Constructor failed when no name is passed: (" + ex + ")");
4545
}
4646

47+
try {
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+
54+
try {
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+
4761
try {
4862
var worker = new SharedWorker("resources/shared-worker-common.js", "name");
4963
log ("PASS: SharedWorker constructor succeeded: " + worker);

LayoutTests/fast/workers/shared-worker-name-expected.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ PASS creating worker with empty name
1010
PASS creating worker with different name but same URL
1111
PASS creating no-name worker with alternate URL
1212
PASS creating empty name worker with alternate URL
13+
PASS created SharedWorker with name 'null'
14+
PASS setting self.foo
15+
PASS creating worker with a null name
16+
PASS created SharedWorker with name 'undefined'
17+
PASS setting self.foo
18+
PASS creating worker with an undefined name
1319

1420
TEST COMPLETE
1521

LayoutTests/platform/chromium-win/fast/workers/shared-worker-constructor-expected.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ Test SharedWorker constructor functionality. Should print a series of PASS messa
22

33
PASS: toString exception propagated correctly.
44
PASS: 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)
5+
PASS: invoking SharedWorker constructor without arguments resulted in an exception (TypeError: Not enough arguments)
66
PASS: invoking SharedWorker constructor without name did not result in an exception
7+
PASS: invoking SharedWorker constructor with null name did not result in an exception
8+
PASS: invoking SharedWorker constructor with undefined name did not result in an exception
79
PASS: SharedWorker constructor succeeded: [object SharedWorker]
810
DONE
911

Source/WebCore/ChangeLog

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,28 @@
1+
2011-10-18 Kentaro Hara <[email protected]>
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+
126
2011-10-18 Johnny Ding <[email protected]>
227

328
Implement NSProcessInfo::systemUptime on Mac Leopard.

Source/WebCore/WebCore.gypi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2231,7 +2231,6 @@
22312231
'bindings/v8/custom/V8SVGPathSegCustom.cpp',
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',
22372236
'bindings/v8/custom/V8StyleSheetListCustom.cpp',

Source/WebCore/WebCore.pro

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,6 @@ v8 {
203203
bindings/v8/custom/V8SQLTransactionCustom.cpp \
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 \
209208
bindings/v8/custom/V8StyleSheetListCustom.cpp \

Source/WebCore/bindings/js/JSSharedWorkerCustom.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ EncodedJSValue JSC_HOST_CALL JSSharedWorkerConstructor::constructJSSharedWorker(
7373
// FIXME: We need to use both the dynamic scope and the lexical scope (dynamic scope for resolving the worker URL)
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);
7979
return JSValue::encode(JSValue());

0 commit comments

Comments
 (0)