How do I detect the presence of a high-dpi display?

Hello,
how do i detect a “retina” or similar display on the user’s device?
I tried cc.view.getFrameSize() but it reports bogus on an iphone4 or 5

For iOs Devices directly works
cc.view.isRetinaEnabled().

For browsers you can use such expression:

if(cc.sys.platform == cc.sys.MOBILE_BROWSER || cc.sys.platform == cc.sys.DESKTOP_BROWSER) {
    var isRetinaEnabled = (window.devicePixelRatio > 1 ||
                                (window.matchMedia && window.matchMedia("(-webkit-min-device-pixel-ratio: 1.5),(-moz-min-device-pixel-ratio: 1.5),(min-device-pixel-ratio: 1.5)").matches)
                                );

    cc.view.enableRetina(isRetinaEnabled);
}

and then detect it by cc.view.isRetinaEnabled()