Bug 472585 - 'Workers: 'importScripts()' with no args throws an exception against spec'. r+sr+a=sicking.
authorBen Turner <bent.mozilla@gmail.com>
Tue, 13 Jan 2009 10:43:23 -0800
changeset 23616 3c0b74a013d753a8150a565d3a314231cd4ad706
parent 23615 8056ab7076d58341448552e65ff1c97afdd3f5a0
child 23617 557bc4bcdc30869b043f4c4a5b1f853850e5325f
child 23618 f957a14faefdce34f35b3720cccf6bf41c3f81b2
push id4639
push userbturner@mozilla.com
push dateTue, 13 Jan 2009 18:43:58 +0000
treeherdermozilla-central@3c0b74a013d7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs472585
milestone1.9.2a1pre
Bug 472585 - 'Workers: 'importScripts()' with no args throws an exception against spec'. r+sr+a=sicking.
dom/src/threads/nsDOMWorker.cpp
dom/src/threads/test/importScripts_worker.js
dom/src/threads/test/test_importScripts.html
--- a/dom/src/threads/nsDOMWorker.cpp
+++ b/dom/src/threads/nsDOMWorker.cpp
@@ -206,18 +206,18 @@ nsDOMWorkerFunctions::LoadScripts(JSCont
   nsDOMWorker* worker = static_cast<nsDOMWorker*>(JS_GetContextPrivate(aCx));
   NS_ASSERTION(worker, "This should be set by the DOM thread service!");
 
   if (worker->IsCanceled()) {
     return JS_FALSE;
   }
 
   if (!aArgc) {
-    JS_ReportError(aCx, "Function must have at least one argument!");
-    return JS_FALSE;
+    // No argument is ok according to spec.
+    return JS_TRUE;
   }
 
   nsAutoTArray<nsString, 10> urls;
 
   if (!urls.SetCapacity((PRUint32)aArgc)) {
     JS_ReportOutOfMemory(aCx);
     return JS_FALSE;
   }
--- a/dom/src/threads/test/importScripts_worker.js
+++ b/dom/src/threads/test/importScripts_worker.js
@@ -1,8 +1,11 @@
+// Try no args. This shouldn't do anything.
+importScripts();
+
 onmessage = function(event) {
   switch (event.data) {
     case 'start':
       importScripts("importScripts_worker_imported2.js");
       importedScriptFunction2();
       tryBadScripts();
       postMessage('started');
       break;
--- a/dom/src/threads/test/test_importScripts.html
+++ b/dom/src/threads/test/test_importScripts.html
@@ -24,23 +24,23 @@ Tests of DOM Worker Threads (Bug 437152)
     switch (event.data) {
       case "started":
         worker.postMessage("stop");
         break;
       case "stopped":
         SimpleTest.finish();
         break;
       default:
-        ok(false, "Unexpected message:" + message);
+        ok(false, "Unexpected message:" + event.data);
         SimpleTest.finish();
     }
   };
 
   worker.onerror = function(event) {
-    ok(false, "Worker had an error:" + event.data);
+    ok(false, "Worker had an error:" + event.message);
     SimpleTest.finish();
   }
 
   worker.postMessage("start");
 
   SimpleTest.waitForExplicitFinish();
 
 </script>