Bug 827193: fix typo in WorkerScope, r=khuey, a=akeybl
authorGavin Sharp <gavin@gavinsharp.com>
Mon, 07 Jan 2013 11:18:19 -0800
changeset 118424 e34522d6369319a3139c2c1497a50bc25494678f
parent 118423 06ddf5f299b545ccf784c65c28d4f92d9e2a7096
child 118425 fc2ad2c37df44e376059b812f8449c0103c1ca1c
push id408
push userryanvm@gmail.com
push dateFri, 01 Feb 2013 14:42:10 +0000
reviewerskhuey, akeybl
bugs827193
milestone18.0
Bug 827193: fix typo in WorkerScope, r=khuey, a=akeybl
dom/workers/WorkerScope.cpp
dom/workers/test/Makefile.in
dom/workers/test/content_worker.js
dom/workers/test/test_contentWorker.html
--- a/dom/workers/WorkerScope.cpp
+++ b/dom/workers/WorkerScope.cpp
@@ -962,24 +962,22 @@ CreateDedicatedWorkerGlobalScope(JSConte
   }
 
   JSObject* workerProto = worker::InitClass(aCx, global, eventTargetProto,
                                             false);
   if (!workerProto) {
     return NULL;
   }
 
-  if (worker->IsChromeWorker() &&
-      (!chromeworker::InitClass(aCx, global, workerProto, false) ||
-       !DefineChromeWorkerFunctions(aCx, global))) {
-    return NULL;
-  }
-
-  if (!DefineOSFileConstants(aCx, global)) {
-    return NULL;
+  if (worker->IsChromeWorker()) {
+    if (!chromeworker::InitClass(aCx, global, workerProto, false) ||
+        !DefineChromeWorkerFunctions(aCx, global) ||
+        !DefineOSFileConstants(aCx, global)) {
+      return NULL;
+    }
   }
 
   // Init other classes we care about.
   if (!events::InitClasses(aCx, global, false) ||
       !file::InitClasses(aCx, global) ||
       !exceptions::InitClasses(aCx, global) ||
       !location::InitClass(aCx, global) ||
       !imagedata::InitClass(aCx, global) ||
--- a/dom/workers/test/Makefile.in
+++ b/dom/workers/test/Makefile.in
@@ -97,16 +97,18 @@ MOCHITEST_FILES = \
   test_xhr_system.js \
   test_blobConstructor.html \
   test_csp.html \
   test_csp.js \
   test_csp.html^headers^ \
   csp_worker.js \
   test_transferable.html \
   transferable_worker.js \
+  test_contentWorker.html \
+  content_worker.js \
   $(NULL)
 
 _SUBDIRMOCHITEST_FILES = \
   relativeLoad_sub_worker.js \
   relativeLoad_sub_worker2.js \
   relativeLoad_sub_import.js \
   $(NULL)
 
new file mode 100644
--- /dev/null
+++ b/dom/workers/test/content_worker.js
@@ -0,0 +1,12 @@
+/**
+ * Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/
+ */
+var props = {
+  'ctypes': 1,
+  'OS': 1
+};
+for (var prop in props) {
+  postMessage({ "prop": prop, "value": self[prop] });
+}
+postMessage({ "testfinished": 1 });
new file mode 100644
--- /dev/null
+++ b/dom/workers/test/test_contentWorker.html
@@ -0,0 +1,48 @@
+<!--
+  Any copyright is dedicated to the Public Domain.
+  http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Test for DOM Worker privileged properties</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">
+<script class="testbody" language="javascript">
+
+  var workerFilename = "content_worker.js";
+  var worker = new Worker(workerFilename);
+
+  var props = {
+    'ctypes': 1,
+    'OS': 1
+  };
+
+  worker.onmessage = function(event) {
+    if (event.data.testfinished) {
+      SimpleTest.finish();
+      return;
+    }
+    var prop = event.data.prop;
+    ok(prop in props, "checking " + prop);
+    is(event.data.value, undefined, prop + " should be undefined");
+  };
+
+  worker.onerror = function(event) {
+    ok(false, "Worker had an error: " + event.message);
+    SimpleTest.finish();
+  }
+
+  SimpleTest.waitForExplicitFinish();
+
+</script>
+</pre>
+</body>
+</html>