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

Unified Diff: lib/compat.js

Issue 29398651: Issue 5061 - Update adblockpluscore dependency to 3bdddf0e8343 (Closed)
Patch Set: Update dependency further Created March 30, 2017, 1:55 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 | « dependencies ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compat.js
diff --git a/lib/compat.js b/lib/compat.js
index 0e6682dede12aa72cfc0236d096388ccd130a7ef..f919671bda88047214e8382fc4bac65710c1e76e 100644
--- a/lib/compat.js
+++ b/lib/compat.js
@@ -69,8 +69,16 @@ 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)};
+
+ throw new Error(
+ "Attempt to import unknown JavaScript module " + resource
+ );
},
reportError(e)
{
@@ -86,9 +94,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
@@ -127,7 +137,7 @@ FakeFile.prototype =
// Services.jsm module emulation
//
-let Services = {
+Cu.import.resources.set("Services", {
obs: {
addObserver() {},
removeObserver() {}
@@ -200,15 +210,15 @@ let Services = {
return 0;
}
}
-};
+});
//
// FileUtils.jsm module emulation
//
-let FileUtils = {
+Cu.import.resources.set("FileUtils", {
PERMS_DIRECTORY: 0
-};
+});
function FakeTimer()
{
« no previous file with comments | « dependencies ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld