Bug 890928 - Crashfix for URL.createURL in subworker. r=bent
authorAndrea Marchesini <amarchesini@mozilla.com>
Thu, 18 Jul 2013 10:30:41 -0400
changeset 152256 b96c56413b5e9426e4da3e7f63a45bd5902910cb
parent 152255 16eb4d747d4eefc3e6091de53b94d240ae7d556d
child 152257 f57adec8f404fed0db383f9dff485d46535ff6d8
push id382
push userakeybl@mozilla.com
push dateMon, 21 Oct 2013 21:47:13 +0000
treeherdermozilla-release@5f1868ee45cb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbent
bugs890928
milestone25.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 890928 - Crashfix for URL.createURL in subworker. r=bent
dom/workers/URL.cpp
dom/workers/test/Makefile.in
dom/workers/test/jsm_url_worker.js
dom/workers/test/test_bug883784.jsm
dom/workers/test/test_url.html
dom/workers/test/url_worker.js
--- a/dom/workers/URL.cpp
+++ b/dom/workers/URL.cpp
@@ -139,17 +139,17 @@ public:
       doc = window->GetExtantDoc();
       if (!doc) {
         SetDOMStringToNull(mURL);
         return;
       }
 
       principal = doc->NodePrincipal();
     } else {
-      MOZ_ASSERT(mWorkerPrivate->IsChromeWorker());
+      MOZ_ASSERT_IF(!mWorkerPrivate->GetParent(), mWorkerPrivate->IsChromeWorker());
       principal = mWorkerPrivate->GetPrincipal();
     }
 
     nsCString url;
     nsresult rv = nsHostObjectProtocolHandler::AddDataEntry(
         NS_LITERAL_CSTRING(BLOBURI_SCHEME),
         mBlob, principal, url);
 
@@ -194,17 +194,17 @@ public:
     if (window) {
       doc = window->GetExtantDoc();
       if (!doc) {
         return;
       }
 
       principal = doc->NodePrincipal();
     } else {
-      MOZ_ASSERT(mWorkerPrivate->IsChromeWorker());
+      MOZ_ASSERT_IF(!mWorkerPrivate->GetParent(), mWorkerPrivate->IsChromeWorker());
       principal = mWorkerPrivate->GetPrincipal();
     }
 
     NS_ConvertUTF16toUTF8 url(mURL);
 
     nsIPrincipal* urlPrincipal =
       nsHostObjectProtocolHandler::GetDataEntryPrincipal(url);
 
--- a/dom/workers/test/Makefile.in
+++ b/dom/workers/test/Makefile.in
@@ -139,12 +139,12 @@ MOCHITEST_CHROME_FILES = \
   WorkerTest_subworker.js \
   chromeWorker_worker.js \
   chromeWorker_subworker.js \
   test_workersDisabled.xul \
   workersDisabled_worker.js \
   dom_worker_helper.js \
   test_bug883784.xul \
   test_bug883784.jsm \
-  url_worker.js \
+  jsm_url_worker.js \
   $(NULL)
 
 include $(topsrcdir)/config/rules.mk
copy from dom/workers/test/url_worker.js
copy to dom/workers/test/jsm_url_worker.js
--- a/dom/workers/test/url_worker.js
+++ b/dom/workers/test/jsm_url_worker.js
@@ -1,9 +1,19 @@
-onmessage = function() {
+onmessage = function(event) {
+  if (event.data != 0) {
+    var worker = new Worker('jsm_url_worker.js');
+    worker.onmessage = function(event) {
+      postMessage(event.data);
+    }
+
+    worker.postMessage(event.data - 1);
+    return;
+  }
+
   status = false;
   try {
     if ((URL instanceof Object)) {
       status = true;
     }
   } catch(e) {
   }
 
--- a/dom/workers/test/test_bug883784.jsm
+++ b/dom/workers/test/test_bug883784.jsm
@@ -1,13 +1,13 @@
 this.EXPORTED_SYMBOLS = ["Test"];
 
 this.Test = {
   start: function(ok, is, finish) {
-    let worker = new ChromeWorker("url_worker.js");
+    let worker = new ChromeWorker("jsm_url_worker.js");
     worker.onmessage = function(event) {
 
       if (event.data.type == 'finish') {
         finish();
       } else if (event.data.type == 'status') {
         ok(event.data.status, event.data.msg);
       } else if (event.data.type == 'url') {
         var xhr = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"]
@@ -25,11 +25,11 @@ this.Test = {
     var self = this;
     worker.onerror = function(event) {
       is(event.target, worker);
       ok(false, "Worker had an error: " + event.data);
       self.worker.terminate();
       finish();
     };
 
-    worker.postMessage(true);
+    worker.postMessage(0);
   }
 };
--- a/dom/workers/test/test_url.html
+++ b/dom/workers/test/test_url.html
@@ -16,17 +16,17 @@
 <script class="testbody" type="text/javascript">
 
   var worker = new Worker("url_worker.js");
 
   worker.onmessage = function(event) {
     is(event.target, worker);
 
     if (event.data.type == 'finish') {
-      SimpleTest.finish();
+      runTest();
     } else if (event.data.type == 'status') {
       ok(event.data.status, event.data.msg);
     } else if (event.data.type == 'url') {
       var xhr = new XMLHttpRequest();
       xhr.open('GET', event.data.url, false);
       xhr.onreadystatechange = function() {
         if (xhr.readyState == 4) {
           ok(true, "Blob readable!");
@@ -37,17 +37,31 @@
   };
 
   worker.onerror = function(event) {
     is(event.target, worker);
     ok(false, "Worker had an error: " + event.data);
     SimpleTest.finish();
   };
 
-  worker.postMessage(true);
+  var tests = [
+    function() { worker.postMessage(0); },
+    function() { worker.postMessage(1); }
+  ];
 
+  function runTest() {
+    if (!tests.length) {
+      SimpleTest.finish();
+      return;
+    }
+
+    var test = tests.shift();
+    test();
+  }
+
+  runTest();
   SimpleTest.waitForExplicitFinish();
 
 </script>
 </pre>
 </body>
 </html>
 
--- a/dom/workers/test/url_worker.js
+++ b/dom/workers/test/url_worker.js
@@ -1,9 +1,19 @@
-onmessage = function() {
+onmessage = function(event) {
+  if (event.data != 0) {
+    var worker = new Worker('url_worker.js');
+    worker.onmessage = function(event) {
+      postMessage(event.data);
+    }
+
+    worker.postMessage(event.data - 1);
+    return;
+  }
+
   status = false;
   try {
     if ((URL instanceof Object)) {
       status = true;
     }
   } catch(e) {
   }