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 200749 cc906edb11c0f3c0de3b06fa2167ae65a54bc19b
parent 200748 60bda4a9bf6062da2d1716c6d899a7a8cb0ffa7b
child 200750 acd930a6f1748867791c3cf9a071c742b16e73ae
push id486
push userasasaki@mozilla.com
push dateMon, 14 Jul 2014 18:39:42 +0000
treeherdermozilla-release@d33428174ff1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskhuey, sledru
bugs1002702
milestone31.0
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
@@ -74,16 +74,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_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)
 [test_console.html]
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>
+