Diff
Modified: trunk/LayoutTests/ChangeLog (93708 => 93709)
--- trunk/LayoutTests/ChangeLog 2011-08-24 17:30:39 UTC (rev 93708)
+++ trunk/LayoutTests/ChangeLog 2011-08-24 17:42:20 UTC (rev 93709)
@@ -1,3 +1,30 @@
+2011-08-23 David Levin <le...@chromium.org>
+
+ MessageEvent.ports shouldn't ever be null.
+ https://bugs.webkit.org/show_bug.cgi?id=66789
+
+ Reviewed by Darin Adler.
+
+ Fix all tests which verified that MessageEvents.ports was null in various cases.
+
+ * fast/dom/Window/window-postmessage-args-expected.txt:
+ * fast/events/message-port-multi-expected.txt:
+ * fast/events/resources/message-port-multi.js:
+ (channel.port2.onmessage):
+ * fast/workers/resources/worker-context-multi-port.js:
+ (worker.onmessage):
+ * fast/workers/resources/worker-messageport.js:
+ (onmessage):
+ * fast/workers/resources/worker-thread-multi-port.js:
+ (onmessage):
+ * fast/workers/worker-context-multi-port-expected.txt:
+ * fast/workers/worker-messageport-expected.txt:
+ * fast/workers/worker-multi-port-expected.txt:
+ * platform/chromium-win/fast/events/message-port-multi-expected.txt:
+ * platform/chromium-win/fast/workers/worker-context-multi-port-expected.txt:
+ * platform/chromium-win/fast/workers/worker-multi-port-expected.txt:
+ * platform/chromium/fast/dom/Window/window-postmessage-args-expected.txt:
+
2011-08-24 Alexandru Chiculita <ach...@adobe.com>
https://bugs.webkit.org/show_bug.cgi?id=66799
Modified: trunk/LayoutTests/fast/dom/Window/window-postmessage-args-expected.txt (93708 => 93709)
--- trunk/LayoutTests/fast/dom/Window/window-postmessage-args-expected.txt 2011-08-24 17:30:39 UTC (rev 93708)
+++ trunk/LayoutTests/fast/dom/Window/window-postmessage-args-expected.txt 2011-08-24 17:42:20 UTC (rev 93709)
@@ -9,10 +9,10 @@
PASS: Posting message ('7', [object MessagePort],[object MessagePort]) did not throw an exception
PASS: Posting message ('2147483648', null) did not throw an exception
PASS: Posting message ('done', *) did not throw an exception
-Received message '4'
-Received message '5'
-Received message '6'
+Received message '4' with 0 ports.
+Received message '5' with 0 ports.
+Received message '6' with 0 ports.
Received message '7' with 2 ports.
-Received message '2147483648'
-Received message 'done'
+Received message '2147483648' with 0 ports.
+Received message 'done' with 0 ports.
Modified: trunk/LayoutTests/fast/events/message-port-multi-expected.txt (93708 => 93709)
--- trunk/LayoutTests/fast/events/message-port-multi-expected.txt 2011-08-24 17:30:39 UTC (rev 93708)
+++ trunk/LayoutTests/fast/events/message-port-multi-expected.txt 2011-08-24 17:42:20 UTC (rev 93709)
@@ -10,8 +10,8 @@
PASS channel.port1.postMessage("notAnArray", channel3.port1) threw exception TypeError: Type error.
PASS channel.port1.postMessage("notASequence", [{length: 3}]) threw exception TypeError: Type error.
PASS channel.port1.postMessage("largeSequence", largePortArray) threw exception Error: INVALID_STATE_ERR: DOM Exception 11.
-PASS event.ports is null when no port sent
-PASS event.ports is null when empty array sent
+PASS event.ports is non-null and zero length when no port sent
+PASS event.ports is non-null and zero length when empty array sent
PASS event.ports contains two ports when two ports sent
PASS event.ports contains two ports when two ports re-sent after error
Modified: trunk/LayoutTests/fast/events/resources/message-port-multi.js (93708 => 93709)
--- trunk/LayoutTests/fast/events/resources/message-port-multi.js 2011-08-24 17:30:39 UTC (rev 93708)
+++ trunk/LayoutTests/fast/events/resources/message-port-multi.js 2011-08-24 17:42:20 UTC (rev 93709)
@@ -35,15 +35,15 @@
channel.port2._onmessage_ = function(event) {
if (event.data == "noport") {
- if (!event.ports)
- testPassed("event.ports is null when no port sent");
+ if (event.ports && !event.ports.length)
+ testPassed("event.ports is non-null and zero length when no port sent");
else
- testFailed("event.ports should be null when no port sent");
+ testFailed("event.ports is null or non-zero length when no port sent");
} else if (event.data == "zero ports") {
- if (!event.ports)
- testPassed("event.ports is null when empty array sent");
+ if (event.ports && !event.ports.length)
+ testPassed("event.ports is non-null and zero length when empty array sent");
else
- testFailed("event.ports should be null when empty array sent");
+ testFailed("event.ports is null or non-zero length when empty array sent");
} else if (event.data == "two ports") {
if (!event.ports) {
testFailed("event.ports should be non-null when ports sent");
Modified: trunk/LayoutTests/fast/workers/resources/worker-context-multi-port.js (93708 => 93709)
--- trunk/LayoutTests/fast/workers/resources/worker-context-multi-port.js 2011-08-24 17:30:39 UTC (rev 93708)
+++ trunk/LayoutTests/fast/workers/resources/worker-context-multi-port.js 2011-08-24 17:42:20 UTC (rev 93709)
@@ -12,15 +12,15 @@
if (event.data == "done")
event.ports[0]._onmessage_ = done;
else if (event.data == "noport") {
- if (!event.ports)
- testPassed("event.ports is null when no port sent");
+ if (event.ports && !event.ports.length)
+ testPassed("event.ports is non-null and zero length when no port sent");
else
- testFailed("event.ports should be null when no port sent");
+ testFailed("event.ports is null or non-zero length when no port sent");
} else if (event.data == "zero ports") {
- if (!event.ports)
- testPassed("event.ports is null when empty array sent");
+ if (event.ports && !event.ports.length)
+ testPassed("event.ports is non-null and zero length when empty array sent");
else
- testFailed("event.ports should be null when empty array sent");
+ testFailed("event.ports is null or non-zero length when empty array sent");
} else if (event.data == "two ports") {
if (!event.ports) {
testFailed("event.ports should be non-null when ports sent");
Modified: trunk/LayoutTests/fast/workers/resources/worker-messageport.js (93708 => 93709)
--- trunk/LayoutTests/fast/workers/resources/worker-messageport.js 2011-08-24 17:30:39 UTC (rev 93708)
+++ trunk/LayoutTests/fast/workers/resources/worker-messageport.js 2011-08-24 17:42:20 UTC (rev 93709)
@@ -8,10 +8,10 @@
postMessage("FAIL: Did not receive expected MessagePort");
}
} else if (evt.data == "noport") {
- if (evt.ports) {
- postMessage("FAIL: Received message port");
+ if (!evt.ports || evt.ports.length) {
+ postMessage("FAIL: Received message port or null ports array");
} else {
- postMessage("PASS: evt.ports = null as expected");
+ postMessage("PASS: evt.ports = [] as expected");
}
} else if (evt.data == "spam") {
for (var i = 0 ; i < 1000 ; i++) {
Modified: trunk/LayoutTests/fast/workers/resources/worker-thread-multi-port.js (93708 => 93709)
--- trunk/LayoutTests/fast/workers/resources/worker-thread-multi-port.js 2011-08-24 17:30:39 UTC (rev 93708)
+++ trunk/LayoutTests/fast/workers/resources/worker-thread-multi-port.js 2011-08-24 17:42:20 UTC (rev 93709)
@@ -1,14 +1,14 @@
_onmessage_ = function(event) {
if (event.data == "noport") {
- if (!event.ports)
- testPassed("event.ports is null when no port sent");
+ if (event.ports && !event.ports.length)
+ testPassed("event.ports is non-null and zero length when no port sent");
else
- testFailed("event.ports should be null when no port sent");
+ testFailed("event.ports is null or non-zero length when no port sent");
} else if (event.data == "zero ports") {
- if (!event.ports)
- testPassed("event.ports is null when empty array sent");
+ if (event.ports && !event.ports.length)
+ testPassed("event.ports is non-null and zero length when empty array sent");
else
- testFailed("event.ports should be null when empty array sent");
+ testFailed("event.ports is null or non-zero length when empty array sent");
} else if (event.data == "two ports") {
if (!event.ports) {
testFailed("event.ports should be non-null when ports sent");
Modified: trunk/LayoutTests/fast/workers/worker-context-multi-port-expected.txt (93708 => 93709)
--- trunk/LayoutTests/fast/workers/worker-context-multi-port-expected.txt 2011-08-24 17:30:39 UTC (rev 93708)
+++ trunk/LayoutTests/fast/workers/worker-context-multi-port-expected.txt 2011-08-24 17:42:20 UTC (rev 93709)
@@ -3,8 +3,8 @@
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-PASS event.ports is null when no port sent
-PASS event.ports is null when empty array sent
+PASS event.ports is non-null and zero length when no port sent
+PASS event.ports is non-null and zero length when empty array sent
PASS event.ports contains two ports when two ports sent
PASS posting a null port did throw: Error: INVALID_STATE_ERR: DOM Exception 11
PASS posting a non-port did throw: TypeError: Type error
Modified: trunk/LayoutTests/fast/workers/worker-messageport-expected.txt (93708 => 93709)
--- trunk/LayoutTests/fast/workers/worker-messageport-expected.txt 2011-08-24 17:30:39 UTC (rev 93708)
+++ trunk/LayoutTests/fast/workers/worker-messageport-expected.txt 2011-08-24 17:42:20 UTC (rev 93709)
@@ -1,6 +1,6 @@
Test that pages and workers can send MessagePorts to one another. Should print "DONE" when done.
-PASS: evt.ports = null as expected
+PASS: evt.ports = [] as expected
PASS: Received message port
PASS: Received response from Worker via MessagePort
PASS: Got port from worker
Modified: trunk/LayoutTests/fast/workers/worker-multi-port-expected.txt (93708 => 93709)
--- trunk/LayoutTests/fast/workers/worker-multi-port-expected.txt 2011-08-24 17:30:39 UTC (rev 93708)
+++ trunk/LayoutTests/fast/workers/worker-multi-port-expected.txt 2011-08-24 17:42:20 UTC (rev 93709)
@@ -7,8 +7,8 @@
PASS worker.postMessage("notAPort", [channel3.port1, {}, channel3.port2]) threw exception TypeError: Type error.
PASS worker.postMessage("notAnArray", channel3.port1) threw exception TypeError: Type error.
PASS worker.postMessage("notASequence", [{length: 3}]) threw exception TypeError: Type error.
-PASS event.ports is null when no port sent
-PASS event.ports is null when empty array sent
+PASS event.ports is non-null and zero length when no port sent
+PASS event.ports is non-null and zero length when empty array sent
PASS event.ports contains two ports when two ports sent
PASS event.ports contains two ports when two ports re-sent after error
Modified: trunk/LayoutTests/platform/chromium/fast/dom/Window/window-postmessage-args-expected.txt (93708 => 93709)
--- trunk/LayoutTests/platform/chromium/fast/dom/Window/window-postmessage-args-expected.txt 2011-08-24 17:30:39 UTC (rev 93708)
+++ trunk/LayoutTests/platform/chromium/fast/dom/Window/window-postmessage-args-expected.txt 2011-08-24 17:42:20 UTC (rev 93709)
@@ -9,10 +9,10 @@
PASS: Posting message ('7', [object MessagePort],[object MessagePort]) did not throw an exception
PASS: Posting message ('2147483648', null) did not throw an exception
PASS: Posting message ('done', *) did not throw an exception
-Received message '4'
-Received message '5'
-Received message '6'
+Received message '4' with 0 ports.
+Received message '5' with 0 ports.
+Received message '6' with 0 ports.
Received message '7' with 2 ports.
-Received message '2147483648'
-Received message 'done'
+Received message '2147483648' with 0 ports.
+Received message 'done' with 0 ports.
Modified: trunk/LayoutTests/platform/chromium-win/fast/events/message-port-multi-expected.txt (93708 => 93709)
--- trunk/LayoutTests/platform/chromium-win/fast/events/message-port-multi-expected.txt 2011-08-24 17:30:39 UTC (rev 93708)
+++ trunk/LayoutTests/platform/chromium-win/fast/events/message-port-multi-expected.txt 2011-08-24 17:42:20 UTC (rev 93709)
@@ -9,8 +9,8 @@
PASS channel.port1.postMessage("notAPort", [channel3.port1, {}, channel3.port2]) threw exception TypeError: MessagePortArray argument must contain only MessagePorts.
PASS channel.port1.postMessage("notAnArray", channel3.port1) threw exception TypeError: MessagePortArray argument has no length attribute.
PASS channel.port1.postMessage("notASequence", [{length: 3}]) threw exception TypeError: MessagePortArray argument must contain only MessagePorts.
-PASS event.ports is null when no port sent
-PASS event.ports is null when empty array sent
+PASS event.ports is non-null and zero length when no port sent
+PASS event.ports is non-null and zero length when empty array sent
PASS event.ports contains two ports when two ports sent
PASS event.ports contains two ports when two ports re-sent after error
Modified: trunk/LayoutTests/platform/chromium-win/fast/workers/worker-context-multi-port-expected.txt (93708 => 93709)
--- trunk/LayoutTests/platform/chromium-win/fast/workers/worker-context-multi-port-expected.txt 2011-08-24 17:30:39 UTC (rev 93708)
+++ trunk/LayoutTests/platform/chromium-win/fast/workers/worker-context-multi-port-expected.txt 2011-08-24 17:42:20 UTC (rev 93709)
@@ -3,8 +3,8 @@
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-PASS event.ports is null when no port sent
-PASS event.ports is null when empty array sent
+PASS event.ports is non-null and zero length when no port sent
+PASS event.ports is non-null and zero length when empty array sent
PASS event.ports contains two ports when two ports sent
PASS posting a null port did throw: Error: INVALID_STATE_ERR: DOM Exception 11
PASS posting a non-port did throw: TypeError: MessagePortArray argument must contain only MessagePorts
Modified: trunk/LayoutTests/platform/chromium-win/fast/workers/worker-multi-port-expected.txt (93708 => 93709)
--- trunk/LayoutTests/platform/chromium-win/fast/workers/worker-multi-port-expected.txt 2011-08-24 17:30:39 UTC (rev 93708)
+++ trunk/LayoutTests/platform/chromium-win/fast/workers/worker-multi-port-expected.txt 2011-08-24 17:42:20 UTC (rev 93709)
@@ -7,8 +7,8 @@
PASS worker.postMessage("notAPort", [channel3.port1, {}, channel3.port2]) threw exception TypeError: MessagePortArray argument must contain only MessagePorts.
PASS worker.postMessage("notAnArray", channel3.port1) threw exception TypeError: MessagePortArray argument has no length attribute.
PASS worker.postMessage("notASequence", [{length: 3}]) threw exception TypeError: MessagePortArray argument must contain only MessagePorts.
-PASS event.ports is null when no port sent
-PASS event.ports is null when empty array sent
+PASS event.ports is non-null and zero length when no port sent
+PASS event.ports is non-null and zero length when empty array sent
PASS event.ports contains two ports when two ports sent
PASS event.ports contains two ports when two ports re-sent after error
Modified: trunk/Source/WebCore/ChangeLog (93708 => 93709)
--- trunk/Source/WebCore/ChangeLog 2011-08-24 17:30:39 UTC (rev 93708)
+++ trunk/Source/WebCore/ChangeLog 2011-08-24 17:42:20 UTC (rev 93709)
@@ -1,3 +1,15 @@
+2011-08-23 David Levin <le...@chromium.org>
+
+ MessageEvent.ports shouldn't ever be null.
+ https://bugs.webkit.org/show_bug.cgi?id=66789
+
+ Reviewed by Darin Adler.
+
+ * bindings/js/JSMessageEventCustom.cpp:
+ (WebCore::JSMessageEvent::ports): Never return null.
+ * bindings/v8/custom/V8MessageEventCustom.cpp:
+ (WebCore::V8MessageEvent::portsAccessorGetter): Ditto.
+
2011-08-24 Alexandru Chiculita <ach...@adobe.com>
https://bugs.webkit.org/show_bug.cgi?id=66799
Modified: trunk/Source/WebCore/bindings/js/JSMessageEventCustom.cpp (93708 => 93709)
--- trunk/Source/WebCore/bindings/js/JSMessageEventCustom.cpp 2011-08-24 17:30:39 UTC (rev 93708)
+++ trunk/Source/WebCore/bindings/js/JSMessageEventCustom.cpp 2011-08-24 17:42:20 UTC (rev 93709)
@@ -45,8 +45,8 @@
JSValue JSMessageEvent::ports(ExecState* exec) const
{
MessagePortArray* ports = static_cast<MessageEvent*>(impl())->ports();
- if (!ports || ports->isEmpty())
- return jsNull();
+ if (!ports)
+ return constructEmptyArray(exec, globalObject());
MarkedArgumentBuffer list;
for (size_t i = 0; i < ports->size(); i++)
Modified: trunk/Source/WebCore/bindings/v8/custom/V8MessageEventCustom.cpp (93708 => 93709)
--- trunk/Source/WebCore/bindings/v8/custom/V8MessageEventCustom.cpp 2011-08-24 17:30:39 UTC (rev 93708)
+++ trunk/Source/WebCore/bindings/v8/custom/V8MessageEventCustom.cpp 2011-08-24 17:42:20 UTC (rev 93709)
@@ -48,8 +48,8 @@
MessageEvent* event = V8MessageEvent::toNative(info.Holder());
MessagePortArray* ports = event->ports();
- if (!ports || ports->isEmpty())
- return v8::Null();
+ if (!ports)
+ return v8::Array::New(0);
v8::Local<v8::Array> portArray = v8::Array::New(ports->size());
for (size_t i = 0; i < ports->size(); ++i)