Created
July 11, 2012 18:03
-
-
Save zhannes/3092064 to your computer and use it in GitHub Desktop.
line 76, calling localStorage.getItem on a key that is not defined returns null. Passing null to JSON.parse() throws an Exception, "Uncaught illegal access", in old versions of V8. A bug was filed, some info here: http://code.google.com/p/android/issues/d
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
if (!(window.postMessage && window.localStorage && window.JSON)) return; | |
var a = { | |
setItems: function (event, i) { | |
if (!g({ | |
write: 1 | |
}, event.origin)) return false; | |
var j = i.length, | |
k = []; | |
for (var l = 0; l < j; l++) { | |
var m = i[l]; | |
k[l] = d(m.key, m.value, m.expireIn, m.acl); | |
} | |
return k; | |
}, | |
getItem: function (event, i, j) { | |
var k = e(event, i); | |
if (j) if (i.substring(0, 9) == 'LoginInfo') h(i, k != null); | |
return k; | |
} | |
}; | |
function b(event) { | |
var i = event.data; | |
if (typeof i == 'string') i = JSON.parse(i); | |
if (i && a[i.method]) { | |
var j = i.params || []; | |
j.splice(0, 0, event); | |
c(event, i.returnCb, a[i.method].apply(null, j)); | |
} | |
}function c(event, i, j) { | |
if (i) event.source.postMessage({ | |
cb: i, | |
data: j | |
}, event.origin); | |
}function d(i, j, k, l) { | |
if (!i) return false; | |
var m = { | |
v: j, | |
a: l | |
}; | |
if (k) m.e = (new Date()).getTime() + k * 1000; | |
m = JSON.stringify(m); | |
try { | |
localStorage[i] = m; | |
} catch (n) { | |
return false; | |
} | |
return true; | |
}function e(event, i) { | |
var j = localStorage.getItem(i); | |
if (!j) return null; | |
var k = JSON.parse(j); | |
if (!k || !g({ | |
read: 1 | |
}, event.origin, k.a)) return null; | |
var l = k.e && k.e < (new Date()).getTime(); | |
if (l || (k.a && k.a.readOnce)) localStorage.removeItem(i); | |
return l ? null : k.v; | |
}function f(i) { | |
return (i && i.indexOf('://') != -1) ? i.substr(i.indexOf('://') + 3) : i; | |
}function g(i, j, k) { | |
var l = f(j), | |
m = k ? f(k.domain) : null, | |
n = l.match(/\.facebook\.com$/); | |
if (i.write && !n) return false; | |
if (i.read && !(n || l == m)) return false; | |
return true; | |
}function h(i, j) { | |
var k = { | |
app_id: i.split('_')[1], | |
cached: j, | |
event_type: 'view', | |
time: Math.round((new Date()).getTime()) | |
}, | |
l = JSON.parse(localStorage.getItem('_log')) || { | |
a: { | |
uid: k.user_id, | |
readOnce: true | |
}, | |
v: [] | |
}; | |
l.v.push(k); | |
localStorage.setItem('_log', JSON.stringify(l)); | |
} | |
addEventListener('message', b, false); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment