Bug 1002702 - SharedWorker should always close MessagePort. r=khuey, a=sledru
authorAndrea Marchesini <amarchesini@mozilla.com>
Fri, 27 Jun 2014 10:24:56 -0700
changeset 208780 2bbc56ea0d3dbfc215fc39d0d3281d96dba293bc
parent 208779 bb5036debda7b1975d3f9d5b133962d7b35455a8
child 208781 45d2500c62ef6392d7eb0d07418819d9fc7dc13b
push id494
push userraliiev@mozilla.com
push dateMon, 25 Aug 2014 18:42:16 +0000
treeherdermozilla-release@a3cc3e46b571 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskhuey, sledru
bugs1002702
milestone32.0a2
Bug 1002702 - SharedWorker should always close MessagePort. r=khuey, a=sledru
dom/workers/SharedWorker.cpp
dom/workers/test/mochitest.ini
dom/workers/test/test_bug1002702.html
--- a/dom/workers/SharedWorker.cpp
+++ b/dom/workers/SharedWorker.cpp
@@ -35,16 +35,17 @@ SharedWorker::SharedWorker(nsPIDOMWindow
   mSerial = aWorkerPrivate->NextMessagePortSerial();
 
   mMessagePort = new MessagePort(aWindow, this, mSerial);
 }
 
 SharedWorker::~SharedWorker()
 {
   AssertIsOnMainThread();
+  Close();
   MOZ_ASSERT(!mWorkerPrivate);
 }
 
 // static
 already_AddRefed<SharedWorker>
 SharedWorker::Constructor(const GlobalObject& aGlobal, JSContext* aCx,
                           const nsAString& aScriptURL,
                           const mozilla::dom::Optional<nsAString>& aName,
--- a/dom/workers/test/mochitest.ini
+++ b/dom/workers/test/mochitest.ini
@@ -77,16 +77,17 @@ support-files =
   subdir/relativeLoad_sub_worker2.js
   subdir/relativeLoad_sub_import.js
 
 [test_404.html]
 [test_atob.html]
 [test_blobConstructor.html]
 [test_blobWorkers.html]
 [test_bug949946.html]
+[test_bug1002702.html]
 [test_bug1010784.html]
 [test_bug1014466.html]
 [test_bug1020226.html]
 [test_chromeWorker.html]
 [test_clearTimeouts.html]
 [test_close.html]
 [test_closeOnGC.html]
 skip-if = (buildapp == 'b2g' && (toolkit != 'gonk' || debug)) || toolkit == 'android' #bug 881404 # b2g-debug(times out) b2g-desktop(times out)
new file mode 100644
--- /dev/null
+++ b/dom/workers/test/test_bug1002702.html
@@ -0,0 +1,27 @@
+<!--
+  Any copyright is dedicated to the Public Domain.
+  http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Test for bug 1002702</title>
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<p id="display"></p>
+<div id="content" style="display: none"></div>
+<pre id="test"></pre>
+<script class="testbody" type="text/javascript">
+
+var port = new SharedWorker('data:application/javascript,1').port;
+port.close();
+SpecialPowers.forceGC();
+ok(true, "No crash \\o/");
+
+</script>
+</pre>
+</body>
+</html>
+