Skip to content

Commit

Permalink
Merge pull request #7914 from AnalyticalGraphicsInc/image-204
Browse files Browse the repository at this point in the history
Make sure 204 image requests reject when using ImageBitmap
  • Loading branch information
mramato authored Jun 18, 2019
2 parents 00a5ad8 + 86dacec commit 52f7b4c
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 19 deletions.
3 changes: 2 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ Change Log
##### Fixes :wrench:
* Fixed a bug that caused missing segments for ground polylines with coplanar points over large distances and problems with polylines containing duplicate points. [#7885](https://github.com/AnalyticalGraphicsInc/cesium//pull/7885)
* Fixed a bug where billboards were not pickable when zoomed out completely in 2D View. [#7908](https://github.com/AnalyticalGraphicsInc/cesium/pull/7908)
* Fixed a bug where image requests that returned HTTP code 204 would prevent any future request from succeeding on browsers that supported ImageBitmap. [#7914](https://github.com/AnalyticalGraphicsInc/cesium/pull/7914/)
* Fixed polyline colors when `scene.highDynamicRange` is enabled. [#7924](https://github.com/AnalyticalGraphicsInc/cesium/pull/7924)
* Fixed a bug in the inspector where the min/max height values of a picked tile were undefined. [#7904](https://github.com/AnalyticalGraphicsInc/cesium/pull/7904)

### 1.58.1 - 2018-06-03
_This is an npm-only release to fix a publishing issue_
_This is an npm-only release to fix a publishing issue_.

### 1.58 - 2019-06-03

Expand Down
29 changes: 11 additions & 18 deletions Source/Core/Resource.js
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,6 @@ define([
}

var deferred = when.defer();

Resource._Implementations.createImage(url, crossOrigin, deferred, flipY, preferImageBitmap);

return deferred.promise;
Expand Down Expand Up @@ -1869,24 +1868,18 @@ define([

return Resource.fetchBlob({
url: url
});
})
.then(function(blob) {
if (!defined(blob)) {
return;
}

return Resource.createImageBitmapFromBlob(blob, {
flipY: flipY,
premultiplyAlpha: false
});
})
.then(function(imageBitmap) {
if (!defined(imageBitmap)) {
return;
}
})
.then(function(blob) {
if (!defined(blob)) {
deferred.reject(new RuntimeError('Successfully retrieved ' + url + ' but it contained no content.'));
return;
}

deferred.resolve(imageBitmap);
return Resource.createImageBitmapFromBlob(blob, {
flipY: flipY,
premultiplyAlpha: false
});
}).then(deferred.resolve);
})
.otherwise(deferred.reject);
};
Expand Down
31 changes: 31 additions & 0 deletions Specs/Core/ResourceSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1891,6 +1891,37 @@ defineSuite([
expect(rejectedError).toBeInstanceOf(RequestErrorEvent);
});

it('is an image with status code 204 with preferImageBitmap', function() {
if (!supportsImageBitmapOptions) {
return;
}

var promise = Resource.fetchImage({
url: './Data/Images/Green.png',
preferImageBitmap: true
});

expect(promise).toBeDefined();

var resolved = false;
var resolvedValue;
var rejectedError;
promise.then(function(value) {
resolved = true;
resolvedValue = value;
}).otherwise(function (error) {
rejectedError = error;
});

expect(resolvedValue).toBeUndefined();
expect(rejectedError).toBeUndefined();

fakeXHR.simulateHttpResponse(204);
expect(resolved).toBe(false);
expect(resolvedValue).toBeUndefined();
expect(rejectedError).toBeDefined();
});

it('resolves undefined for status code 204', function() {
var promise = loadWithXhr({
url : 'http://example.invalid'
Expand Down

0 comments on commit 52f7b4c

Please sign in to comment.