Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: ext/common.js

Issue 29573905: Issue 4580 - Replace ext.devtools with devtools Base URL: https://hg.adblockplus.org/adblockplusui/
Patch Set: Use runtime.onConnect Created Oct. 12, 2017, 1:22 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ext/common.js
===================================================================
--- a/ext/common.js
+++ b/ext/common.js
@@ -156,16 +156,56 @@
let rawCatalog = JSON.parse(xhr.responseText);
for (let msgId in rawCatalog)
{
if (!(msgId in catalog))
catalog[msgId] = parseMessage(rawCatalog[msgId]);
}
};
+ /* Polyfills */
+
+ if (!("runtime" in chrome))
+ chrome.runtime = {};
+
+ chrome.runtime.onConnect = {
+ addListener(callback)
+ {
+ window.addEventListener("message", event =>
+ {
+ if (event.data.type == "connect")
+ {
+ callback({
Manish Jethani 2017/10/12 01:30:03 Call the onConnect handler with a port object [1]
+ postMessage(message)
+ {
+ event.source.postMessage({
+ type: "message",
+ messageId: -1,
+ payload: message
+ }, "*");
+ }
+ });
+ }
+ });
+ }
+ };
+
+ if (/\/devtools-panel\.html\b/.test(top.location.href))
Sebastian Noack 2017/10/17 21:40:25 I suppose we could just check for: top.location
Manish Jethani 2017/10/18 00:26:53 Done.
+ {
+ chrome.devtools = {
+ panels: {
+ openResource() {}
+ },
+
+ inspectedWindow: {
+ reload() {}
+ }
+ };
+ }
+
chrome.i18n = {
getUILanguage()
{
return locales[0].replace(/_/g, "-");
},
getMessage(msgId, substitutions)
{
while (true)

Powered by Google App Engine
This is Rietveld