Bug 827193: fix typo in WorkerScope, r=khuey, a=akeybl
authorGavin Sharp <gavin@gavinsharp.com>
Mon, 07 Jan 2013 11:18:19 -0800
changeset 122540 9461ce8b252a8f2a8e4c2ceae7d247ad190f6129
parent 122539 1f8edd0f51780f926a3ed580d01765de5ef28de2
child 122541 6285b50a21ac3484941b8b7be41a35bcf2bb9acb
child 122544 0e60886f3a5b6eb8fbfa25e3bffecc041b0bb7cb
child 122546 b26c4eeb9716d9cf304d1816b0a9d6dc52f3d5b3
push id2000
push usergsharp@mozilla.com
push dateTue, 08 Jan 2013 00:20:02 +0000
treeherdermozilla-beta@9461ce8b252a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskhuey, akeybl
bugs827193
milestone19.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
@@ -961,24 +961,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>