Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test Failure on master: TypeError: Cannot read property 'fetch' of null in test/sanitize-html.test.js #343

Closed
humphd opened this issue Nov 24, 2019 · 6 comments · Fixed by #344
Labels
type: bug Something isn't working type: test Creation and development of test

Comments

@humphd
Copy link
Contributor

humphd commented Nov 24, 2019

I'm not clear what started triggering this all of a sudden, but it just failed for me when I merged on master:

 FAIL  test/sanitize-html.test.js

  ● Tests for sanitized HTML

    TypeError: Cannot read property 'fetch' of null

      at PerDocumentResourceLoader.fetch (node_modules/jsdom/lib/jsdom/browser/resources/per-document-resource-loader.js:17:42)

      at HTMLImageElementImpl._attrModified (node_modules/jsdom/lib/jsdom/living/nodes/HTMLImageElement-impl.js:39:36)

      at Object.<anonymous>.exports.appendAttribute (node_modules/jsdom/lib/jsdom/living/attributes.js:62:11)

      at Object.<anonymous>.exports.setAttributeValue (node_modules/jsdom/lib/jsdom/living/attributes.js:218:13)

      at JSDOMParse5Adapter.adoptAttributes (node_modules/jsdom/lib/jsdom/browser/parser/html.js:152:18)

      at JSDOMParse5Adapter.createElement (node_modules/jsdom/lib/jsdom/browser/parser/html.js:73:10)

      at Parser._appendElement (node_modules/parse5/lib/parser/index.js:553:42)

      at areaStartTagInBody (node_modules/parse5/lib/parser/index.js:1519:7)

      at Object.startTagInBody [as START_TAG_TOKEN] (node_modules/parse5/lib/parser/index.js:1725:17)

      at Parser._processToken (node_modules/parse5/lib/parser/index.js:657:55)

cc @shmooey did you ever hit this?

@humphd humphd added type: bug Something isn't working type: test Creation and development of test labels Nov 24, 2019
@humphd
Copy link
Contributor Author

humphd commented Nov 24, 2019

@humphd
Copy link
Contributor Author

humphd commented Nov 24, 2019

cc @miggs125, who probably knows the most about JSDOM among us. I suspect that not having a proper document is causing issues here, using a fragment like this. But I could be wrong. It seems odd to me that DOMPurify can pass all their unit tests with JSDOM and we can't. Look at https://github.com/cure53/DOMPurify/blob/dd053931337b457da156530c4db0c1d5c92f66a4/test/jsdom-node.js.

@humphd
Copy link
Contributor Author

humphd commented Nov 24, 2019

This test is literally doing what we're doing now, but with what looks like a more robust document setup, https://github.com/cure53/DOMPurify/blob/3bc348bf5882b200e559f65f3fc749733afb812d/test/bootstrap-test-suite.js#L13-L37.

@manekenpix
Copy link
Member

@humphd could it be that DOMPurify uses "jsdom": "8.x.x" and we're using "jsdom": "15.2.1",?
I noticed that what they do in line 15 is syntax from before v10

@miggs125
Copy link
Contributor

@manekenpix DOMPurify works with jsdom v10+

@miggs125
Copy link
Contributor

perhaps we should try writing the code that is causing the error with the previous version of the jsdom API and determine if that makes any difference

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working type: test Creation and development of test
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants