Bug 1221852 - SharedWorker.port should be always not null, r=smaug, a=ritu
authorAndrea Marchesini <amarchesini@mozilla.com>
Tue, 17 Nov 2015 23:38:39 +0000
changeset 305578 a80ec65ea24c786bf66b3af36558c4b5fda9f878
parent 305577 118a51d986e6dd806da0e6da837901aeb5c19bc4
child 305579 09bfa4e72dbf835a4b370d301044d92ba712cfde
push id1001
push userraliiev@mozilla.com
push dateMon, 18 Jan 2016 19:06:03 +0000
treeherdermozilla-release@8b89261f3ac4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug, ritu
bugs1221852
milestone44.0a2
Bug 1221852 - SharedWorker.port should be always not null, r=smaug, a=ritu
dom/workers/SharedWorker.cpp
dom/workers/test/sharedWorker_ports.js
dom/workers/test/test_sharedWorker_ports.html
--- a/dom/workers/SharedWorker.cpp
+++ b/dom/workers/SharedWorker.cpp
@@ -131,17 +131,16 @@ SharedWorker::QueueEvent(nsIDOMEvent* aE
 
 void
 SharedWorker::Close()
 {
   AssertIsOnMainThread();
 
   if (mMessagePort) {
     mMessagePort->Close();
-    mMessagePort = nullptr;
   }
 }
 
 void
 SharedWorker::PostMessage(JSContext* aCx, JS::Handle<JS::Value> aMessage,
                           const Optional<Sequence<JS::Value>>& aTransferable,
                           ErrorResult& aRv)
 {
--- a/dom/workers/test/sharedWorker_ports.js
+++ b/dom/workers/test/sharedWorker_ports.js
@@ -12,12 +12,13 @@ onconnect = function(evt) {
                         test: (evtFromPort.ports.length == 1),
                         msg: "1 port transferred"});
 
       evtFromPort.ports[0].onmessage = function(evtFromPort2) {
         port.postMessage({type: "status",
                           test: (evtFromPort2.data.type == "connected"),
                           msg: "The original message received" });
         port.postMessage({type: "finish"});
+        close();
       }
     }
   }
 }
--- a/dom/workers/test/test_sharedWorker_ports.html
+++ b/dom/workers/test/test_sharedWorker_ports.html
@@ -23,16 +23,19 @@ sw1.port.onmessage = function(event) {
   }
 
   if (event.data.type == "status") {
     ok(event.data.test, event.data.msg);
     return;
   }
 
   if (event.data.type == "finish") {
+    info("Finished!");
+    ok(sw1.port, "The port still exists");
+    sw1.port.foo = sw1; // Just a test to see if we leak.
     SimpleTest.finish();
   }
 }
 
 SimpleTest.waitForExplicitFinish();
     </script>
   </body>
 </html>