Jsdom: Support for Web Workers?

Created on 19 Oct 2017  路  4Comments  路  Source: jsdom/jsdom

Basic info:

  • Node.js version: v8.6.0
  • jsdom version: 11.3.0

Minimal reproduction case

const { JSDOM } = require("jsdom");

const options = {
  url: "http://example.com/",
};
const dom = new JSDOM(`
  <!DOCTYPE html><html><head></head><body></div></body></html>
`, options);

var w = new dom.window.Worker("demo_workers.js");
var w = new dom.window.Worker("demo_workers.js");
        ^

TypeError: dom.window.Worker is not a constructor
    at Object.<anonymous> (/Users/andrew/projects/swagger-linter/no-worker.js:10:9)
    at Module._compile (module.js:624:30)
    at Object.Module._extensions..js (module.js:635:10)
    at Module.load (module.js:545:32)
    at tryModuleLoad (module.js:508:12)
    at Function.Module._load (module.js:500:3)
    at Function.Module.runMain (module.js:665:10)
    at startup (bootstrap_node.js:187:16)
    at bootstrap_node.js:607:3

How does similar code behave in browsers?

You'd probably get the error that the file doesn't exist but Worker would be defined.

feature

Most helpful comment

Now that node supports the worker threads API should this be investigated again?

All 4 comments

+1

Can people refrain from adding +1 comments? They are not helpful.

Fixing this will depend on Worker support in Node.js core, which is already supported by Ayo.js but yet to be backmerged into Node.js. Both the primary author of the feature and I are unfortunately short on time to make this happen soon.

People like @jcjolley might have overlooked (being so overwhelmed by trump election) this 2016 github feature: reactions.

Now that node supports the worker threads API should this be investigated again?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

josephrexme picture josephrexme  路  4Comments

machineghost picture machineghost  路  4Comments

jhegedus42 picture jhegedus42  路  4Comments

Progyan1997 picture Progyan1997  路  3Comments

philipwalton picture philipwalton  路  4Comments