[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.15.1-1414-gc69ee75
atwilson at chromium.org
atwilson at chromium.org
Thu Oct 29 20:32:20 UTC 2009
The following commit has been merged in the webkit-1.1 branch:
commit 76983f5f3f891dfb6a2237376ceea99c5cac9590
Author: atwilson at chromium.org <atwilson at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Wed Sep 23 04:16:27 2009 +0000
WebCore: SharedWorkers "name" attribute is now optional.
https://bugs.webkit.org/show_bug.cgi?id=28897
Reviewed by David Levin.
Test: fast/workers/shared-worker-name.html
* bindings/js/JSSharedWorkerConstructor.cpp:
(WebCore::constructSharedWorker):
Default 'name' attribute to empty string if it is not provided.
* bindings/v8/custom/V8SharedWorkerCustom.cpp:
(WebCore::CALLBACK_FUNC_DECL):
Default 'name' attribute to empty string if it is not provided.
* workers/DefaultSharedWorkerRepository.cpp:
(WebCore::SharedWorkerProxy::matches):
Now matches URLs if names are empty strings.
(WebCore::DefaultSharedWorkerRepository::getProxy):
Pass URL in to SharedWorkerProxy::matches().
LayoutTests: SharedWorkers "name" attribute is now optional
https://bugs.webkit.org/show_bug.cgi?id=28897
Reviewed by David Levin.
* fast/workers/resources/worker-name.js:
New tests for optional name parameter.
* fast/workers/resources/worker-util.js:
(done):
Now invokes done via a timer to ensure any pending console errors are written out.
* fast/workers/shared-worker-constructor-expected.txt:
* fast/workers/shared-worker-constructor.html:
Updated test/expectations now that constructor's "name" param is optional.
* fast/workers/shared-worker-name-expected.txt:
* fast/workers/shared-worker-name.html:
New tests for optional name parameter.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@48666 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index c413d27..9648f01 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,22 @@
+2009-09-22 Drew Wilson <atwilson at google.com>
+
+ Reviewed by David Levin.
+
+ SharedWorkers "name" attribute is now optional
+ https://bugs.webkit.org/show_bug.cgi?id=28897
+
+ * fast/workers/resources/worker-name.js:
+ New tests for optional name parameter.
+ * fast/workers/resources/worker-util.js:
+ (done):
+ Now invokes done via a timer to ensure any pending console errors are written out.
+ * fast/workers/shared-worker-constructor-expected.txt:
+ * fast/workers/shared-worker-constructor.html:
+ Updated test/expectations now that constructor's "name" param is optional.
+ * fast/workers/shared-worker-name-expected.txt:
+ * fast/workers/shared-worker-name.html:
+ New tests for optional name parameter.
+
2009-09-22 Darin Adler <darin at apple.com>
Reviewed by Sam Weinig.
diff --git a/LayoutTests/fast/workers/resources/shared-worker-name.js b/LayoutTests/fast/workers/resources/shared-worker-name.js
new file mode 100644
index 0000000..eb8668f
--- /dev/null
+++ b/LayoutTests/fast/workers/resources/shared-worker-name.js
@@ -0,0 +1,102 @@
+if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+ layoutTestController.waitUntilDone();
+}
+
+description("Checks the various use cases around the SharedWorker constructor's optional name parameter");
+
+var currentTest = 0;
+nextTest();
+
+// Iterates through the tests until none are left.
+function nextTest()
+{
+ currentTest++;
+ var testFunction = window["test" + currentTest];
+ if (testFunction)
+ testFunction();
+ else
+ done();
+}
+
+
+
+function test1()
+{
+ // Make sure we can create a shared worker with no name.
+ try {
+ var worker = new SharedWorker('resources/shared-worker-common.js');
+ testPassed("created SharedWorker with no name");
+ worker.port.postMessage("eval self.foo = 1234");
+ worker.port.onmessage = function(event) {
+ shouldBeEqual("setting self.foo", event.data, "self.foo = 1234: 1234");
+ nextTest();
+ };
+ } catch (e) {
+ testFailed("SharedWorker with no name threw an exception: " + e);
+ done();
+ }
+}
+
+function test2()
+{
+ // Creating a worker with no name should match an existing worker with no name
+ var worker = new SharedWorker('resources/shared-worker-common.js');
+ worker.port.postMessage("eval self.foo");
+ worker.port.onmessage = function(event) {
+ shouldBeEqual("creating worker with no name", event.data, "self.foo: 1234");
+ nextTest();
+ }
+}
+
+function test3()
+{
+ // Creating a worker with an empty name should be the same as a worker with no name.
+ var worker = new SharedWorker('resources/shared-worker-common.js', '');
+ worker.port.postMessage("eval self.foo");
+ worker.port.onmessage = function(event) {
+ shouldBeEqual("creating worker with empty name", event.data, "self.foo: 1234");
+ nextTest();
+ };
+}
+
+function test4()
+{
+ // Creating a worker with a different name should not be the same as a worker with no name.
+ var worker = new SharedWorker('resources/shared-worker-common.js', 'name');
+ worker.port.postMessage("eval self.foo");
+ worker.port.onmessage = function(event) {
+ shouldBeEqual("creating worker with different name but same URL", event.data, "self.foo: undefined");
+ nextTest();
+ };
+}
+
+function test5()
+{
+ // Creating a worker for an alternate URL with no name should work.
+ var worker = new SharedWorker('resources/shared-worker-common.js?url=1');
+ worker.port.postMessage("eval self.foo");
+ worker.port.onmessage = function(event) {
+ shouldBeEqual("creating no-name worker with alternate URL", event.data, "self.foo: undefined");
+ nextTest();
+ };
+}
+
+function test6()
+{
+ // Creating a worker for an alternate URL with empty name should work.
+ var worker = new SharedWorker('resources/shared-worker-common.js?url=2', '');
+ worker.port.postMessage("eval self.foo");
+ worker.port.onmessage = function(event) {
+ shouldBeEqual("creating empty name worker with alternate URL", event.data, "self.foo: undefined");
+ nextTest();
+ };
+}
+
+function shouldBeEqual(description, a, b)
+{
+ if (a == b)
+ testPassed(description);
+ else
+ testFailed(description + " - passed value: " + a + ", expected value: " + b);
+}
diff --git a/LayoutTests/fast/workers/resources/worker-util.js b/LayoutTests/fast/workers/resources/worker-util.js
index 37943e7..206eed1 100644
--- a/LayoutTests/fast/workers/resources/worker-util.js
+++ b/LayoutTests/fast/workers/resources/worker-util.js
@@ -53,6 +53,9 @@ function done()
else
log("DONE");
- if (window.layoutTestController)
- layoutTestController.notifyDone();
+ // Call notifyDone via the queue so any pending console messages/exceptions are written out first.
+ setTimeout(function() {
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+ }, 0);
}
diff --git a/LayoutTests/fast/workers/shared-worker-constructor-expected.txt b/LayoutTests/fast/workers/shared-worker-constructor-expected.txt
index 224c1c3..9f0c090 100644
--- a/LayoutTests/fast/workers/shared-worker-constructor-expected.txt
+++ b/LayoutTests/fast/workers/shared-worker-constructor-expected.txt
@@ -3,7 +3,7 @@ Test SharedWorker constructor functionality. Should print a series of PASS messa
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 name resulted in an exception (SyntaxError: Not enough arguments)
+PASS: invoking SharedWorker constructor without name did not result in an exception
PASS: SharedWorker constructor succeeded: [object SharedWorker]
DONE
diff --git a/LayoutTests/fast/workers/shared-worker-constructor.html b/LayoutTests/fast/workers/shared-worker-constructor.html
index de7fa3f..7160cba 100644
--- a/LayoutTests/fast/workers/shared-worker-constructor.html
+++ b/LayoutTests/fast/workers/shared-worker-constructor.html
@@ -39,9 +39,9 @@ try {
try {
var worker = new SharedWorker("resources/shared-worker-common.js");
- log("FAIL: Constructor succeeded when no name is passed");
+ log("PASS: invoking SharedWorker constructor without name did not result in an exception");
} catch (ex) {
- log("PASS: invoking SharedWorker constructor without name resulted in an exception (" + ex + ")");
+ log("FAIL: Constructor failed when no name is passed: (" + ex + ")");
}
try {
diff --git a/LayoutTests/fast/workers/shared-worker-name-expected.txt b/LayoutTests/fast/workers/shared-worker-name-expected.txt
new file mode 100644
index 0000000..b69afa8
--- /dev/null
+++ b/LayoutTests/fast/workers/shared-worker-name-expected.txt
@@ -0,0 +1,15 @@
+Checks the various use cases around the SharedWorker constructor's optional name parameter
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS created SharedWorker with no name
+PASS setting self.foo
+PASS creating worker with no name
+PASS creating worker with empty name
+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
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/workers/shared-worker-name.html b/LayoutTests/fast/workers/shared-worker-name.html
new file mode 100644
index 0000000..ce4fec6
--- /dev/null
+++ b/LayoutTests/fast/workers/shared-worker-name.html
@@ -0,0 +1,10 @@
+<head>
+<link rel="stylesheet" href="../js/resources/js-test-style.css">
+<script src="../js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src="resources/worker-util.js"></script>
+<script src="resources/shared-worker-name.js"></script>
+</body>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 842becc..d53f2e1 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,24 @@
+2009-09-22 Drew Wilson <atwilson at google.com>
+
+ Reviewed by David Levin.
+
+ SharedWorkers "name" attribute is now optional.
+ https://bugs.webkit.org/show_bug.cgi?id=28897
+
+ Test: fast/workers/shared-worker-name.html
+
+ * bindings/js/JSSharedWorkerConstructor.cpp:
+ (WebCore::constructSharedWorker):
+ Default 'name' attribute to empty string if it is not provided.
+ * bindings/v8/custom/V8SharedWorkerCustom.cpp:
+ (WebCore::CALLBACK_FUNC_DECL):
+ Default 'name' attribute to empty string if it is not provided.
+ * workers/DefaultSharedWorkerRepository.cpp:
+ (WebCore::SharedWorkerProxy::matches):
+ Now matches URLs if names are empty strings.
+ (WebCore::DefaultSharedWorkerRepository::getProxy):
+ Pass URL in to SharedWorkerProxy::matches().
+
2009-09-22 Dimitri Glazkov <dglazkov at chromium.org>
Unreviewed, another build fix.
diff --git a/WebCore/bindings/js/JSSharedWorkerConstructor.cpp b/WebCore/bindings/js/JSSharedWorkerConstructor.cpp
index 651805c..c05b3d2 100644
--- a/WebCore/bindings/js/JSSharedWorkerConstructor.cpp
+++ b/WebCore/bindings/js/JSSharedWorkerConstructor.cpp
@@ -57,11 +57,14 @@ static JSObject* constructSharedWorker(ExecState* exec, JSObject* constructor, c
{
JSSharedWorkerConstructor* jsConstructor = static_cast<JSSharedWorkerConstructor*>(constructor);
- if (args.size() < 2)
+ if (args.size() < 1)
return throwError(exec, SyntaxError, "Not enough arguments");
UString scriptURL = args.at(0).toString(exec);
- UString name = args.at(1).toString(exec);
+ UString name;
+ if (args.size() > 1)
+ name = args.at(1).toString(exec);
+
if (exec->hadException())
return 0;
diff --git a/WebCore/bindings/v8/custom/V8SharedWorkerCustom.cpp b/WebCore/bindings/v8/custom/V8SharedWorkerCustom.cpp
index 755977c..e470bc8 100644
--- a/WebCore/bindings/v8/custom/V8SharedWorkerCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8SharedWorkerCustom.cpp
@@ -53,12 +53,15 @@ CALLBACK_FUNC_DECL(SharedWorkerConstructor)
if (!args.IsConstructCall())
return throwError("DOM object constructor cannot be called as a function.");
- if (args.Length() < 2)
+ if (args.Length() < 1)
return throwError("Not enough arguments", V8Proxy::SyntaxError);
v8::TryCatch tryCatch;
v8::Handle<v8::String> scriptUrl = args[0]->ToString();
- v8::Handle<v8::String> name = args[1]->ToString();
+ String name;
+ if (args.Length() > 1)
+ name = toWebCoreString(args[1]->ToString());
+
if (tryCatch.HasCaught())
return throwError(tryCatch.Exception());
@@ -73,7 +76,7 @@ CALLBACK_FUNC_DECL(SharedWorkerConstructor)
// Create the worker 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), toWebCoreString(name), context, ec);
+ RefPtr<SharedWorker> obj = SharedWorker::create(toWebCoreString(scriptUrl), name, context, ec);
// Setup the standard wrapper object internal fields.
v8::Handle<v8::Object> wrapperObject = args.Holder();
diff --git a/WebCore/workers/DefaultSharedWorkerRepository.cpp b/WebCore/workers/DefaultSharedWorkerRepository.cpp
index e955f24..dd8c5ef 100644
--- a/WebCore/workers/DefaultSharedWorkerRepository.cpp
+++ b/WebCore/workers/DefaultSharedWorkerRepository.cpp
@@ -64,7 +64,7 @@ public:
bool isClosing() const { return m_closing; }
KURL url() const { return m_url.copy(); }
String name() const { return m_name.copy(); }
- bool matches(const String& name, PassRefPtr<SecurityOrigin> origin) const { return name == m_name && origin->equal(m_origin.get()); }
+ bool matches(const String& name, PassRefPtr<SecurityOrigin> origin, const KURL& urlToMatch) const;
// WorkerLoaderProxy
virtual void postTaskToLoader(PassRefPtr<ScriptExecutionContext::Task>);
@@ -109,6 +109,19 @@ SharedWorkerProxy::SharedWorkerProxy(const String& name, const KURL& url, PassRe
ASSERT(m_origin->hasOneRef());
}
+bool SharedWorkerProxy::matches(const String& name, PassRefPtr<SecurityOrigin> origin, const KURL& urlToMatch) const
+{
+ // If the origins don't match, or the names don't match, then this is not the proxy we are looking for.
+ if (!origin->equal(m_origin.get()))
+ return false;
+
+ // If the names are both empty, compares the URLs instead per the Web Workers spec.
+ if (name.isEmpty() && m_name.isEmpty())
+ return urlToMatch == url();
+
+ return name == m_name;
+}
+
void SharedWorkerProxy::postTaskToLoader(PassRefPtr<ScriptExecutionContext::Task> task)
{
MutexLocker lock(m_workerDocumentsLock);
@@ -365,7 +378,7 @@ PassRefPtr<SharedWorkerProxy> DefaultSharedWorkerRepository::getProxy(const Stri
// Items in the cache are freed on another thread, so copy the URL before creating the origin, to make sure no references to external strings linger.
RefPtr<SecurityOrigin> origin = SecurityOrigin::create(url.copy());
for (unsigned i = 0; i < m_proxies.size(); i++) {
- if (!m_proxies[i]->isClosing() && m_proxies[i]->matches(name, origin))
+ if (!m_proxies[i]->isClosing() && m_proxies[i]->matches(name, origin, url))
return m_proxies[i];
}
// Proxy is not in the repository currently - create a new one.
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list