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

Unified Diff: lib/compat.js

Issue 29374674: Issue 4864 - Start using ESLint for adblockpluschrome (Closed)
Patch Set: Fixed typo with shadowRoot getter Created March 14, 2017, 10:28 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: lib/compat.js
diff --git a/lib/compat.js b/lib/compat.js
index c2b09dd500f241a8dc1ace2c7bbae6259d15b42a..7fe803ce124b5db1d196951e851f261de9a76d95 100644
--- a/lib/compat.js
+++ b/lib/compat.js
@@ -53,8 +53,7 @@ let onShutdown = {
function nsIFileURL() {}
function nsIHttpChannel() {}
-let Components =
-{
+let Components = {
interfaces:
{
nsIFile: {DIRECTORY_TYPE: 0},
@@ -77,8 +76,12 @@ let Components =
},
results: {},
utils: {
- import()
+ import(resource)
{
+ let match = /^resource:\/\/gre\/modules\/(.+)\.jsm$/.exec(resource);
+ let resourceName = match && match[1];
+ if (resourceName && Cu.import.resources.has(resourceName))
+ return {[resourceName]: Cu.import.resources.get(resourceName)};
Wladimir Palant 2017/03/14 13:03:25 As with the implementation in adblockplusui, this
kzar 2017/03/15 04:57:47 Done.
},
reportError(e)
{
@@ -94,10 +97,11 @@ const Ci = Components.interfaces;
const Cr = Components.results;
const Cu = Components.utils;
-let XPCOMUtils =
-{
+Cu.import.resources = new Map();
+
+Cu.import.resources.set("XPCOMUtils", {
generateQI() {}
-};
+});
//
// Fake nsIFile implementation for our I/O
@@ -136,8 +140,7 @@ FakeFile.prototype =
// Services.jsm module emulation
//
-let Services =
-{
+Cu.import.resources.set("Services", {
obs: {
addObserver() {},
removeObserver() {}
@@ -210,22 +213,20 @@ let Services =
return 0;
}
}
-}
+});
//
// FileUtils.jsm module emulation
//
-let FileUtils =
-{
+Cu.import.resources.set("FileUtils", {
PERMS_DIRECTORY: 0
-};
+});
function FakeTimer()
{
}
-FakeTimer.prototype =
-{
+FakeTimer.prototype = {
delay: 0,
callback: null,
initWithCallback(callback, delay)
@@ -242,7 +243,7 @@ FakeTimer.prototype =
{
this.callback();
}
- catch(e)
+ catch (e)
{
Cu.reportError(e);
}
@@ -255,8 +256,7 @@ FakeTimer.prototype =
// Add a channel property to XMLHttpRequest, Synchronizer needs it
//
-XMLHttpRequest.prototype.channel =
-{
+XMLHttpRequest.prototype.channel = {
status: -1,
notificationCallbacks: {},
loadFlags: 0,

Powered by Google App Engine
This is Rietveld