Make test for using Pale Moon workaround stricter.

This commit is contained in:
ccd0 2015-08-20 01:25:22 -07:00
parent 50bbb9010f
commit 2a8f6e8cc4

View File

@ -226,23 +226,24 @@ $.event = (event, detail, root=d) ->
<% if (type === 'userscript') { %> <% if (type === 'userscript') { %>
# XXX Make $.event work in Pale Moon with GM 3.x (no cloneInto function). # XXX Make $.event work in Pale Moon with GM 3.x (no cloneInto function).
unless typeof cloneInto is 'function' or /^[01]\./.test(GM_info.version) or GM_info.scriptHandler # not FF30+, GM1-, or Tampermonkey do ->
do -> return unless /PaleMoon\//.test(navigator.userAgent) and +GM_info?.version?.split('.')[0] >= 2 and typeof cloneInto is 'undefined'
try
new CustomEvent 'x', detail: {} try
catch err new CustomEvent 'x', detail: {}
unsafeConstructors = catch err
Object: unsafeWindow.Object unsafeConstructors =
Array: unsafeWindow.Array Object: unsafeWindow.Object
clone = (obj) -> Array: unsafeWindow.Array
if obj? and typeof obj is 'object' and (constructor = unsafeConstructors[obj.constructor.name]) clone = (obj) ->
obj2 = new constructor() if obj? and typeof obj is 'object' and (constructor = unsafeConstructors[obj.constructor.name])
obj2[key] = clone val for key, val of obj obj2 = new constructor()
obj2 obj2[key] = clone val for key, val of obj
else obj2
obj else
$.event = (event, detail, root=d) -> obj
root.dispatchEvent new CustomEvent event, {bubbles: true, detail: clone detail} $.event = (event, detail, root=d) ->
root.dispatchEvent new CustomEvent event, {bubbles: true, detail: clone detail}
<% } %> <% } %>
$.open = $.open =