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

Unified Diff: ext/common.js

Issue 29570614: Issue 5028 - Use browser namespace (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Patch Set: Fix indentation Created Oct. 9, 2017, 3:50 p.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
« no previous file with comments | « ext/background.js ('k') | ext/content.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ext/common.js
===================================================================
--- a/ext/common.js
+++ b/ext/common.js
@@ -17,18 +17,19 @@
"use strict";
(function()
{
// Both Edge and Mozilla Web Extensions use the namespace
// 'browser' instead of 'chrome'. Edge has chrome namespace defined,
// in some cases, but only with one property: 'app'.
- if (typeof chrome == "undefined" || typeof chrome.extension == "undefined")
- window.chrome = window.browser;
+ if (typeof browser == "undefined" ||
+ typeof chrome != "undefined" && typeof chrome.extension != "undefined")
+ window.browser = chrome;
window.ext = {};
let EventTarget = ext._EventTarget = function()
{
this._listeners = new Set();
};
EventTarget.prototype = {
@@ -67,20 +68,20 @@
/* Message passing */
ext.onMessage = new ext._EventTarget();
/* Background page */
ext.backgroundPage = {
- sendMessage: chrome.runtime.sendMessage,
+ sendMessage: browser.runtime.sendMessage,
getWindow()
{
- return chrome.extension.getBackgroundPage();
+ return browser.extension.getBackgroundPage();
}
};
/* Utils */
- ext.getURL = chrome.extension.getURL;
+ ext.getURL = browser.extension.getURL;
}());
« no previous file with comments | « ext/background.js ('k') | ext/content.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld