B2G/gecko/dom/system/gonk/tests/header_helpers.js
/**
 * Start a new RIL worker.
 * 
 * @param custom_ns
 *        Namespace with symbols to be injected into the new worker
 *        namespace.
 *
 * @return an object that represents the worker's namespace.
 *
 * @note that this does not start an actual worker thread. The worker
 * is executed on the main thread, within a separate namespace object.
 */
Start a new RIL worker.

@param custom_ns
Namespace with symbols to be injected into the new worker
namespace.

@return an object that represents the worker's namespace.

@note that this does not start an actual worker thread. The worker
is executed on the main thread, within a separate namespace object.
Start a new RIL worker . @param custom_ns Namespace with symbols to be injected into the new worker namespace . @return an object that represents the worker ' s namespace . @note that this does not start an actual worker thread . The worker is executed on the main thread within a separate namespace object .
function newWorker(custom_ns) {
  let worker_ns = {
    importScripts: function fakeImportScripts() {
      Array.slice(arguments).forEach(function (script) {
        subscriptLoader.loadSubScript("resource://gre/modules/" + script, this);
      }, this);
    },
    postRILMessage: function fakePostRILMessage(message) {
    },
    postMessage: function fakepostMessage(message) {
    },
    onmessage: undefined,
    onerror: undefined,
    DEBUG: true
  };
  worker_ns.self = worker_ns;
  Cu.import("resource://gre/modules/ctypes.jsm", worker_ns);
  for (let key in custom_ns) {
    worker_ns[key] = custom_ns[key];
  }
  worker_ns.importScripts("ril_worker.js");
  return worker_ns;
}
function newWorker ( custom_ns ) { let worker_ns = { importScripts : function fakeImportScripts ( ) { Array . slice ( arguments ) . forEach ( function ( script ) { subscriptLoader . loadSubScript ( "resource://gre/modules/" + script , this ) ; } , this ) ; } , postRILMessage : function fakePostRILMessage ( message ) { } , postMessage : function fakepostMessage ( message ) { } , onmessage : undefined , onerror : undefined , DEBUG : true } ; worker_ns . self = worker_ns ; Cu . import ( "resource://gre/modules/ctypes.jsm" , worker_ns ) ; for ( let key in custom_ns ) { worker_ns [ key ] = custom_ns [ key ] ; } worker_ns . importScripts ( "ril_worker.js" ) ; return worker_ns ; }
Start a new RIL worker.
Start a new RIL worker .
// Define these variables inside the worker scope so ES5 strict mode // doesn't flip out. // The 'self' variable in a worker points to the worker's own namespace. // systemlibs.js utilizes ctypes for loading native libraries. // Copy the custom definitions over. // Load the RIL worker itself.