MessagePort must set m_closed to be true at the end of MessagePort::close function
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 29 Apr 2012 01:14:05 +0000 (01:14 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 29 Apr 2012 01:14:05 +0000 (01:14 +0000)
https://bugs.webkit.org/show_bug.cgi?id=85139

Source/WebCore:

In the function MessagePort::close, the "m_closed = true" must be executed at the end, not at the beginning.
Or, the m_entangledChannel->close() will not be executed.
And it resulted in the failure of MS bench mark messagechannel_close.htm.
http://samples.msdn.microsoft.com/ietestcenter/WebWorkers/messagechannel_close.htm

Patch by Li Yin <li.yin@intel.com> on 2012-04-28
Reviewed by Kentaro Hara.

Test: fast/events/message-port-close.html

* dom/MessagePort.cpp:
(WebCore::MessagePort::close):

LayoutTests:

Test MessageChannel.port whether can receive message after it is closed.

Patch by Li Yin <li.yin@intel.com> on 2012-04-28
Reviewed by Kentaro Hara.

* fast/events/message-port-close-expected.txt: Added.
* fast/events/message-port-close.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@115588 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/events/message-port-close-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/message-port-close.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/dom/MessagePort.cpp

index f72f024..d4cf10c 100644 (file)
@@ -1,3 +1,15 @@
+2012-04-28  Li Yin  <li.yin@intel.com>
+
+        MessagePort must set m_closed to be true at the end of MessagePort::close function
+        https://bugs.webkit.org/show_bug.cgi?id=85139
+
+        Test MessageChannel.port whether can receive message after it is closed.
+
+        Reviewed by Kentaro Hara.
+
+        * fast/events/message-port-close-expected.txt: Added.
+        * fast/events/message-port-close.html: Added.
+
 2012-04-28  Sam Weinig  <sam@webkit.org>
 
         Add support for the Blob constructor
diff --git a/LayoutTests/fast/events/message-port-close-expected.txt b/LayoutTests/fast/events/message-port-close-expected.txt
new file mode 100644 (file)
index 0000000..92cfedc
--- /dev/null
@@ -0,0 +1,7 @@
+Test Closed MessagePort Whether Receive Message Or Not.
+
+Should be a START message, followed with DONE.
+
+START
+DONE
+
diff --git a/LayoutTests/fast/events/message-port-close.html b/LayoutTests/fast/events/message-port-close.html
new file mode 100644 (file)
index 0000000..ca1c886
--- /dev/null
@@ -0,0 +1,36 @@
+<body>
+<p>Test Closed MessagePort Whether Receive Message Or Not.</p>
+<p>Should be a START message, followed with DONE.</p>
+<pre id=log></pre>
+<script>
+function log(message)
+{
+    document.getElementById("log").innerHTML += message + "<br>";
+}
+
+if (window.layoutTestController) {
+    layoutTestController.dumpAsText();
+    layoutTestController.waitUntilDone();
+}
+
+log("START");
+
+var channel = new MessageChannel;
+channel.port1.onmessage = function(evt) {
+    log("Closed port receiving: FAIL. Got Message: " +  evt.data + " after close");
+}
+channel.port1.close();
+channel.port2.postMessage("This message can't be received");
+done();
+
+function done() {
+    // Wait a short period of time to ensure no messages come in from previous tests.
+    setTimeout(function() {
+        log("DONE");
+        if (window.layoutTestController)
+            layoutTestController.notifyDone();
+    }, 100);
+}
+
+</script>
+</body>
index 1cf031c..bcb629a 100644 (file)
@@ -1,3 +1,20 @@
+2012-04-28  Li Yin  <li.yin@intel.com>
+
+        MessagePort must set m_closed to be true at the end of MessagePort::close function
+        https://bugs.webkit.org/show_bug.cgi?id=85139
+
+        In the function MessagePort::close, the "m_closed = true" must be executed at the end, not at the beginning.
+        Or, the m_entangledChannel->close() will not be executed.
+        And it resulted in the failure of MS bench mark messagechannel_close.htm.
+        http://samples.msdn.microsoft.com/ietestcenter/WebWorkers/messagechannel_close.htm
+
+        Reviewed by Kentaro Hara.
+
+        Test: fast/events/message-port-close.html
+
+        * dom/MessagePort.cpp:
+        (WebCore::MessagePort::close):
+
 2012-04-28  Sam Weinig  <sam@webkit.org>
 
         And again.
index ade249c..ab4dcdc 100644 (file)
@@ -133,10 +133,10 @@ void MessagePort::start()
 
 void MessagePort::close()
 {
-    m_closed = true;
     if (!isEntangled())
         return;
     m_entangledChannel->close();
+    m_closed = true;
 }
 
 void MessagePort::entangle(PassOwnPtr<MessagePortChannel> remote)