Skip to content

Commit 52f7b4c

Browse files
authored
Merge pull request #7914 from AnalyticalGraphicsInc/image-204
Make sure 204 image requests reject when using ImageBitmap
2 parents 00a5ad8 + 86dacec commit 52f7b4c

File tree

3 files changed

+44
-19
lines changed

3 files changed

+44
-19
lines changed

CHANGES.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@ Change Log
1111
##### Fixes :wrench:
1212
* 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)
1313
* Fixed a bug where billboards were not pickable when zoomed out completely in 2D View. [#7908](https://github.com/AnalyticalGraphicsInc/cesium/pull/7908)
14+
* 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/)
1415
* Fixed polyline colors when `scene.highDynamicRange` is enabled. [#7924](https://github.com/AnalyticalGraphicsInc/cesium/pull/7924)
1516
* 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)
1617

1718
### 1.58.1 - 2018-06-03
18-
_This is an npm-only release to fix a publishing issue_
19+
_This is an npm-only release to fix a publishing issue_.
1920

2021
### 1.58 - 2019-06-03
2122

Source/Core/Resource.js

+11-18
Original file line numberDiff line numberDiff line change
@@ -981,7 +981,6 @@ define([
981981
}
982982

983983
var deferred = when.defer();
984-
985984
Resource._Implementations.createImage(url, crossOrigin, deferred, flipY, preferImageBitmap);
986985

987986
return deferred.promise;
@@ -1869,24 +1868,18 @@ define([
18691868

18701869
return Resource.fetchBlob({
18711870
url: url
1872-
});
1873-
})
1874-
.then(function(blob) {
1875-
if (!defined(blob)) {
1876-
return;
1877-
}
1878-
1879-
return Resource.createImageBitmapFromBlob(blob, {
1880-
flipY: flipY,
1881-
premultiplyAlpha: false
1882-
});
1883-
})
1884-
.then(function(imageBitmap) {
1885-
if (!defined(imageBitmap)) {
1886-
return;
1887-
}
1871+
})
1872+
.then(function(blob) {
1873+
if (!defined(blob)) {
1874+
deferred.reject(new RuntimeError('Successfully retrieved ' + url + ' but it contained no content.'));
1875+
return;
1876+
}
18881877

1889-
deferred.resolve(imageBitmap);
1878+
return Resource.createImageBitmapFromBlob(blob, {
1879+
flipY: flipY,
1880+
premultiplyAlpha: false
1881+
});
1882+
}).then(deferred.resolve);
18901883
})
18911884
.otherwise(deferred.reject);
18921885
};

Specs/Core/ResourceSpec.js

+31
Original file line numberDiff line numberDiff line change
@@ -1891,6 +1891,37 @@ defineSuite([
18911891
expect(rejectedError).toBeInstanceOf(RequestErrorEvent);
18921892
});
18931893

1894+
it('is an image with status code 204 with preferImageBitmap', function() {
1895+
if (!supportsImageBitmapOptions) {
1896+
return;
1897+
}
1898+
1899+
var promise = Resource.fetchImage({
1900+
url: './Data/Images/Green.png',
1901+
preferImageBitmap: true
1902+
});
1903+
1904+
expect(promise).toBeDefined();
1905+
1906+
var resolved = false;
1907+
var resolvedValue;
1908+
var rejectedError;
1909+
promise.then(function(value) {
1910+
resolved = true;
1911+
resolvedValue = value;
1912+
}).otherwise(function (error) {
1913+
rejectedError = error;
1914+
});
1915+
1916+
expect(resolvedValue).toBeUndefined();
1917+
expect(rejectedError).toBeUndefined();
1918+
1919+
fakeXHR.simulateHttpResponse(204);
1920+
expect(resolved).toBe(false);
1921+
expect(resolvedValue).toBeUndefined();
1922+
expect(rejectedError).toBeDefined();
1923+
});
1924+
18941925
it('resolves undefined for status code 204', function() {
18951926
var promise = loadWithXhr({
18961927
url : 'http://example.invalid'

0 commit comments

Comments
 (0)