From 0143c6ca2191b1c828142a5adbde58c6300a2de7 Mon Sep 17 00:00:00 2001 From: Matthew Amato Date: Fri, 22 Jun 2018 21:32:10 -0400 Subject: [PATCH 1/2] 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 --- Source/Core/FeatureDetection.js | 9 --------- Source/Core/Resource.js | 3 ++- Specs/Core/FeatureDetectionSpec.js | 4 ---- 3 files changed, 2 insertions(+), 14 deletions(-) diff --git a/Source/Core/FeatureDetection.js b/Source/Core/FeatureDetection.js index 4d6631556557..8f34384c782a 100644 --- a/Source/Core/FeatureDetection.js +++ b/Source/Core/FeatureDetection.js @@ -163,14 +163,6 @@ define([ return isFirefox() && firefoxVersionResult; } - var isNodeJsResult; - function isNodeJs() { - if (!defined(isNodeJsResult)) { - isNodeJsResult = typeof process === 'object' && Object.prototype.toString.call(process) === '[object process]'; // eslint-disable-line - } - return isNodeJsResult; - } - var hasPointerEvents; function supportsPointerEvents() { if (!defined(hasPointerEvents)) { @@ -238,7 +230,6 @@ define([ isFirefox : isFirefox, firefoxVersion : firefoxVersion, isWindows : isWindows, - isNodeJs: isNodeJs, hardwareConcurrency : defaultValue(theNavigator.hardwareConcurrency, 3), supportsPointerEvents : supportsPointerEvents, supportsImageRenderingPixelated: supportsImageRenderingPixelated, diff --git a/Source/Core/Resource.js b/Source/Core/Resource.js index 5fc104794dd4..264f0ab3a0d7 100644 --- a/Source/Core/Resource.js +++ b/Source/Core/Resource.js @@ -1834,6 +1834,7 @@ define([ }).end(); } + var noXMLHttpRequest = typeof XMLHttpRequest === 'undefined'; Resource._Implementations.loadWithXhr = function(url, responseType, method, data, headers, deferred, overrideMimeType) { var dataUriRegexResult = dataUriRegex.exec(url); if (dataUriRegexResult !== null) { @@ -1841,7 +1842,7 @@ define([ return; } - if (FeatureDetection.isNodeJs()) { + if (noXMLHttpRequest) { loadWithHttpRequest(url, responseType, method, data, headers, deferred, overrideMimeType); return; } diff --git a/Specs/Core/FeatureDetectionSpec.js b/Specs/Core/FeatureDetectionSpec.js index 869cccdf7aae..af0087a18f9c 100644 --- a/Specs/Core/FeatureDetectionSpec.js +++ b/Specs/Core/FeatureDetectionSpec.js @@ -115,8 +115,4 @@ defineSuite([ expect(FeatureDetection.imageRenderingValue()).not.toBeDefined(); } }); - - it('detects Node.js', function() { - expect(FeatureDetection.isNodeJs()).toBe(false); - }); }); From 3d7e93649146a147d0183fadff8e56de26cfcd95 Mon Sep 17 00:00:00 2001 From: Matthew Amato Date: Fri, 22 Jun 2018 21:35:50 -0400 Subject: [PATCH 2/2] Keep concierge happy. --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index 64bd93315ff2..5242b7be96ab 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -19,6 +19,7 @@ Change Log * The `PostProcessStageLibrary.createBlackAndWhiteStage` and `PostProcessStageLibrary.createSilhouetteStage` have per-feature support. ##### Fixes :wrench: +* Fixed a bug that caused Cesium to be unable to load local resources in Electron. [#6726](https://github.com/AnalyticalGraphicsInc/cesium/pull/6726) * Fixed a bug causing crashes with custom vertex attributes on `Geometry` crossing the IDL. Attributes will be barycentrically interpolated. [#6644](https://github.com/AnalyticalGraphicsInc/cesium/pull/6644) * Fixed a bug causing Point Cloud tiles with unsigned int batch-ids to not load. [#6666](https://github.com/AnalyticalGraphicsInc/cesium/pull/6666) * Fixed a bug with Draco encoded i3dm tiles, and loading two Draco models with the same url. [#6668](https://github.com/AnalyticalGraphicsInc/cesium/issues/6668)