title: How to Add a new native class to WebWorker's context in JavaScriptCore?
body: <p>I have an application that extends JavaScript via JavaScriptCore, in a webkit-gtk browser. Right now I have several classes that I add to the global context like so:</p>
  
  <pre><code>void create_js(gpointer context, char* className, JSClassDefinition clasDefinition) {
      JSClassRef classDef = JSClassCreate(&amp;clasDefinition);
      JSObjectRef classObj = JSObjectMake(context, classDef, context);
      JSObjectRef globalObj = JSContextGetGlobalObject(context);
      JSStringRef str = JSStringCreateWithUTF8CString(className);
      JSObjectSetProperty(context, globalObj, str, classObj, kJSPropertyAttributeNone, NULL);
      JSStringRelease(str);
  }
  </code></pre>
  
  <p>Now, I'd like to also add those classes to the WebWorker's context, so I can call them from workers instantiated in JS.</p>
  
  <p>I've tried getting the <code>Worker</code> object like so:</p>
  
  <pre><code>JSStringRef workerStr = JSStringCreateWithUTF8CString("Worker");
  JSObjectRef worker = JSObjectGetProperty(context, globalObj, workerStr, NULL);
  JSObjectSetProperty(context, worker, str, classObj, kJSPropertyAttributeNone, NULL);
  JSStringRelease(workerStr);
  </code></pre>
  
  <p>But that adds it to the <code>WorkerConstructor</code> object, and when a <code>new Worker()</code> is called, the classes are not available.</p>