diff --git a/src/HasteModuleLoader/HasteModuleLoader.js b/src/HasteModuleLoader/HasteModuleLoader.js index 596479912c99..f5a4a0a44493 100644 --- a/src/HasteModuleLoader/HasteModuleLoader.js +++ b/src/HasteModuleLoader/HasteModuleLoader.js @@ -234,7 +234,7 @@ Loader.prototype._execModule = function(moduleObj) { this._isCurrentlyExecutingManualMock = modulePath; utils.runContentWithLocalBindings( - this._environment.runSourceText.bind(this._environment), + this._environment, moduleContent, modulePath, moduleLocalBindings diff --git a/src/HasteModuleLoader/__tests__/HasteModuleLoader-currentTestPath-test.js b/src/HasteModuleLoader/__tests__/HasteModuleLoader-currentTestPath-test.js index 9e975bd80239..ea3ebc77d52c 100644 --- a/src/HasteModuleLoader/__tests__/HasteModuleLoader-currentTestPath-test.js +++ b/src/HasteModuleLoader/__tests__/HasteModuleLoader-currentTestPath-test.js @@ -15,4 +15,4 @@ describe('nodeHasteModuleLoader', function() { expect(jest.currentTestPath()).toMatch(/currentTestPath-test/); }); }); -}); \ No newline at end of file +}); diff --git a/src/JSDomEnvironment.js b/src/JSDomEnvironment.js index 17e4aaad1c51..e7e403aa1cf0 100644 --- a/src/JSDomEnvironment.js +++ b/src/JSDomEnvironment.js @@ -9,7 +9,8 @@ var FakeTimers = require('./lib/FakeTimers'); var utils = require('./lib/utils'); -var vm = require('vm'); + +var USE_JSDOM_EVAL = false; function JSDomEnvironment(config) { // We lazily require jsdom because it takes a good ~.5s to load. @@ -19,7 +20,13 @@ function JSDomEnvironment(config) { // a workerpool parent), this is the best way to ensure we only spend time // require()ing this when necessary. var jsdom = require('./lib/jsdom-compat'); - this.document = jsdom.jsdom(); + this.document = jsdom.jsdom(/* markup */undefined, { + resourceLoader: this._fetchExternalResource.bind(this), + features: { + FetchExternalResources: ['script'], + ProcessExternalResources: ['script'], + }, + }); this.global = this.document.defaultView; // Node's error-message stack size is limited at 10, but it's pretty useful to @@ -94,17 +101,40 @@ JSDomEnvironment.prototype.dispose = function() { }; /** - * Evaluates the given source text as if it were in a file with the given name - * and returns the result. + * Evaluates the given source text as if it were in a file with the given name. + * This method returns nothing. */ JSDomEnvironment.prototype.runSourceText = function(sourceText, fileName) { - // TODO: Stop using the private API and instead configure jsdom with a - // resource loader and insert