diff --git a/src/ol/has.js b/src/ol/has.js index bfc8aabef3..9bf3e354bf 100644 --- a/src/ol/has.js +++ b/src/ol/has.js @@ -37,7 +37,13 @@ export const MAC = ua.indexOf('macintosh') !== -1; * @type {number} * @api */ -export const DEVICE_PIXEL_RATIO = window.devicePixelRatio || 1; +export const DEVICE_PIXEL_RATIO = (function() { + try { + return self.devicePixelRatio; + } catch (e) { + return window.devicePixelRatio || 1; + } +})(); /** * Image.prototype.decode() is supported.