Skip to content

Commit 0143c6c

Browse files
committed
Fix using Cesium inside of Electron apps.
Our Node.js detection was imperfect and unnecessary, we should have been checking for the existence of `XMLHttpRequest` instead. Fixes #6671
1 parent 58ba7b5 commit 0143c6c

File tree

3 files changed

+2
-14
lines changed

3 files changed

+2
-14
lines changed

Source/Core/FeatureDetection.js

-9
Original file line numberDiff line numberDiff line change
@@ -163,14 +163,6 @@ define([
163163
return isFirefox() && firefoxVersionResult;
164164
}
165165

166-
var isNodeJsResult;
167-
function isNodeJs() {
168-
if (!defined(isNodeJsResult)) {
169-
isNodeJsResult = typeof process === 'object' && Object.prototype.toString.call(process) === '[object process]'; // eslint-disable-line
170-
}
171-
return isNodeJsResult;
172-
}
173-
174166
var hasPointerEvents;
175167
function supportsPointerEvents() {
176168
if (!defined(hasPointerEvents)) {
@@ -238,7 +230,6 @@ define([
238230
isFirefox : isFirefox,
239231
firefoxVersion : firefoxVersion,
240232
isWindows : isWindows,
241-
isNodeJs: isNodeJs,
242233
hardwareConcurrency : defaultValue(theNavigator.hardwareConcurrency, 3),
243234
supportsPointerEvents : supportsPointerEvents,
244235
supportsImageRenderingPixelated: supportsImageRenderingPixelated,

Source/Core/Resource.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1834,14 +1834,15 @@ define([
18341834
}).end();
18351835
}
18361836

1837+
var noXMLHttpRequest = typeof XMLHttpRequest === 'undefined';
18371838
Resource._Implementations.loadWithXhr = function(url, responseType, method, data, headers, deferred, overrideMimeType) {
18381839
var dataUriRegexResult = dataUriRegex.exec(url);
18391840
if (dataUriRegexResult !== null) {
18401841
deferred.resolve(decodeDataUri(dataUriRegexResult, responseType));
18411842
return;
18421843
}
18431844

1844-
if (FeatureDetection.isNodeJs()) {
1845+
if (noXMLHttpRequest) {
18451846
loadWithHttpRequest(url, responseType, method, data, headers, deferred, overrideMimeType);
18461847
return;
18471848
}

Specs/Core/FeatureDetectionSpec.js

-4
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,4 @@ defineSuite([
115115
expect(FeatureDetection.imageRenderingValue()).not.toBeDefined();
116116
}
117117
});
118-
119-
it('detects Node.js', function() {
120-
expect(FeatureDetection.isNodeJs()).toBe(false);
121-
});
122118
});

0 commit comments

Comments
 (0)