From 99c67bc17e14d1e1a0c9311bed2cff7e1f3c21bb Mon Sep 17 00:00:00 2001 From: yagni Date: Fri, 1 Feb 2019 20:45:54 -0600 Subject: [PATCH] Switch from deprecated sendRequest/onRequest to sendMessage/onMessage and return true from onMessage to keep the message channel open so the callback can be called asynchronously. --- rails_panel/assets/javascripts/background.js | 7 ++++--- rails_panel/assets/javascripts/requests.js | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) mode change 100644 => 100755 rails_panel/assets/javascripts/background.js mode change 100644 => 100755 rails_panel/assets/javascripts/requests.js diff --git a/rails_panel/assets/javascripts/background.js b/rails_panel/assets/javascripts/background.js old mode 100644 new mode 100755 index b578863..f903de4 --- a/rails_panel/assets/javascripts/background.js +++ b/rails_panel/assets/javascripts/background.js @@ -1,6 +1,7 @@ -chrome.extension.onRequest.addListener(function(request, sender, callback) { - if (request.action == 'getJSON') { - $.getJSON(request.url, callback); +chrome.runtime.onMessage.addListener(function(message, sender, callback) { + if (message.action == 'getJSON') { + $.getJSON(message.url, callback); + return true; } }); diff --git a/rails_panel/assets/javascripts/requests.js b/rails_panel/assets/javascripts/requests.js old mode 100644 new mode 100755 index b9e5d96..58c98ba --- a/rails_panel/assets/javascripts/requests.js +++ b/rails_panel/assets/javascripts/requests.js @@ -1,6 +1,6 @@ getJSON = function(url, callback) { console.log("sending RPC:" + url); - chrome.extension.sendRequest({action:'getJSON',url:url}, callback); + chrome.runtime.sendMessage({action:'getJSON',url:url}, callback); } var requests = {