Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure 204 image requests reject when using ImageBitmap #7914

Merged
merged 6 commits into from
Jun 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,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