非标
此特征是非标准的,且不在标准轨道中。不要在面向 Web 的生产站点中使用它:它不适用于每个用户。实现之间可能存在大的不兼容性,且行为将来可能改变。

摘要

If you're developing privileged code, and would like to create a worker that can use js-ctypes to perform calls to native code, you can do so by using ChromeWorker instead of the standard Worker object. It works exactly like a standard Worker , except that it has access to js-ctypes via a global ctypes object available in the global scope of the worker. Examples of ChromeWorker's using js-ctypes are availabe on Github and are linked to from the See Also section below . To use a postMessage with callback version of ChromeWorker that features promises, see PromiseWorker .

Addons must use absolute URLs to load their workers, and those URLs have to be using a chrome:// or resource:// 协议 ( file:// is not accepted). Addons that wish to use file:// URLs must first register a resource replacement path, using code like this:

var fileuri = Services.io.newFileURI(file);
Services.io.getProtocolHandler('resource').
              QueryInterface(Ci.nsIResProtocolHandler).
              setSubstitution('my-cool-addon', fileuri);
  var worker = new Worker('resource://my-cool-addon/worker.js');
					

More references:

另请参阅

元数据

  • 最后修改:
  1. Mozilla