Created
June 30, 2016 17:05
-
-
Save bobsilverberg/cb1529a0d4cfcb4890eeefe5efe29802 to your computer and use it in GitHub Desktop.
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
// Alias several messaging deprecated APIs to their runtime counterparts. | |
var mayNeedAlias = [ | |
// Types | |
'Port', | |
// Functions | |
'connect', 'sendMessage', 'connectNative', 'sendNativeMessage', | |
// Events | |
'onConnect', 'onConnectExternal', 'onMessage', 'onMessageExternal' | |
]; | |
$Array.forEach(mayNeedAlias, function(alias) { | |
// Checking existence isn't enough since some functions are disabled via | |
// getters that throw exceptions. Assume that any getter is such a function. | |
if (chrome.runtime && | |
$Object.hasOwnProperty(chrome.runtime, alias) && | |
chrome.runtime.__lookupGetter__(alias) === undefined) { | |
extension[alias] = chrome.runtime[alias]; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment