Fix unsafeWindow for the newer versions of Chrome. #968

This commit is contained in:
Nicolas Stepien 2013-03-26 02:58:53 +01:00
parent 7cfd5e9d5d
commit ffea1676fd

View File

@ -193,9 +193,15 @@ $.extend $,
unsafeWindow
else # Chrome
do ->
p = d.createElement 'p'
p.setAttribute 'onclick', 'return window'
p.onclick()
uw = null
captureUW = (e) -> uw = e.detail
window.addEventListener 'unsafe', captureUW, false
s = d.createElement 'script'
s.textContent = 'window.dispatchEvent(new CustomEvent("unsafe", {detail: window}))'
(d.head or doc).appendChild s
s.parentNode.removeChild s
window.removeEventListener 'unsafe', captureUW, false
uw
bytesToString: (size) ->
unit = 0 # Bytes
while size >= 1024