{"action":"opened","issue":{"url":"https://api.github.com/repos/jsdom/jsdom/issues/2371","repository_url":"https://api.github.com/repos/jsdom/jsdom","labels_url":"https://api.github.com/repos/jsdom/jsdom/issues/2371/labels{/name}","comments_url":"https://api.github.com/repos/jsdom/jsdom/issues/2371/comments","events_url":"https://api.github.com/repos/jsdom/jsdom/issues/2371/events","html_url":"https://github.com/jsdom/jsdom/issues/2371","id":365218353,"node_id":"MDU6SXNzdWUzNjUyMTgzNTM=","number":2371,"title":"resourceloader can not work with http requests sent by xmlhttprequest ?","user":{"login":"lovetingyuan","id":7310471,"node_id":"MDQ6VXNlcjczMTA0NzE=","avatar_url":"https://avatars3.githubusercontent.com/u/7310471?v=4","gravatar_id":"","url":"https://api.github.com/users/lovetingyuan","html_url":"https://github.com/lovetingyuan","followers_url":"https://api.github.com/users/lovetingyuan/followers","following_url":"https://api.github.com/users/lovetingyuan/following{/other_user}","gists_url":"https://api.github.com/users/lovetingyuan/gists{/gist_id}","starred_url":"https://api.github.com/users/lovetingyuan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lovetingyuan/subscriptions","organizations_url":"https://api.github.com/users/lovetingyuan/orgs","repos_url":"https://api.github.com/users/lovetingyuan/repos","events_url":"https://api.github.com/users/lovetingyuan/events{/privacy}","received_events_url":"https://api.github.com/users/lovetingyuan/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-09-30T11:46:11Z","updated_at":"2018-09-30T11:46:11Z","closed_at":null,"author_association":"NONE","body":"### Basic info:\r\n\r\n- **Node.js version:** v8\r\n- **jsdom version:** v12.1.0\r\n\r\n### Minimal reproduction case\r\n\r\n```js\r\nconst { JSDOM } = require(\"jsdom\");\r\nclass ResLoader extends jsdom.ResourceLoader {\r\n  fetch(url, options) {\r\n     // url only contains resource in html tags, not includes requests sent by xhr\r\n  }\r\n}\r\nconst options = {\r\n  resources: new ResLoader,\r\n  // resources: 'usable',\r\n  runScripts: 'dangerously',\r\n  pretendToBeVisual: true,\r\n  contentType: 'text/html',\r\n  // includeNodeLocations: true,\r\n  storageQuota: 10000\r\n};\r\nconst dom = new JSDOM(`\r\n  ... your HTML here ...\r\n`, options);\r\n\r\n... your code that reproduces the problem here, probably using dom.window ...\r\n```\r\n\r\n<!--\r\nPlease create a minimal repro. Any reports involving third party libraries\r\nwill be closed, as we cannot debug third-party library interactions for you.\r\n\r\nPlease do not use syntax that is not supported in Node.js, such as JSX or\r\n`import` statements. If we cannot run the code in Node.js, we will close the\r\nissue, as we cannot debug whatever toolchain you are using.\r\n-->\r\n\r\nfor example, when I request an API from backend in my javascript code using `XMLHttpRequest`, I want to use my own `fetch` method defined in `class ResLoader extends jsdom.ResourceLoader ` to handle the `xhr` (or `fetch`) request, not only the static resources declared in html file.\r\n\r\nthanks!\r\n"}}
{"actor":{"display_login":"lovetingyuan"}}