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

Delta Between Two Patch Sets: test/_common.js

Issue 29375915: Issue 4878 - Start using ESLint for adblockpluscore (Closed)
Left Patch Set: Remove shared-node-browser env and Buffer global Created Feb. 23, 2017, 10:51 a.m.
Right Patch Set: Removed unused imports Created March 15, 2017, 3:11 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « test/.eslintrc.json ('k') | test/domainRestrictions.js » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 18 matching lines...) Expand all
29 29
30 const MILLIS_IN_SECOND = exports.MILLIS_IN_SECOND = 1000; 30 const MILLIS_IN_SECOND = exports.MILLIS_IN_SECOND = 1000;
31 const MILLIS_IN_MINUTE = exports.MILLIS_IN_MINUTE = 60 * MILLIS_IN_SECOND; 31 const MILLIS_IN_MINUTE = exports.MILLIS_IN_MINUTE = 60 * MILLIS_IN_SECOND;
32 const MILLIS_IN_HOUR = exports.MILLIS_IN_HOUR = 60 * MILLIS_IN_MINUTE; 32 const MILLIS_IN_HOUR = exports.MILLIS_IN_HOUR = 60 * MILLIS_IN_MINUTE;
33 33
34 function URL(urlString) 34 function URL(urlString)
35 { 35 {
36 return require("url").parse(urlString); 36 return require("url").parse(urlString);
37 } 37 }
38 38
39 let Services = {
40 obs: {
41 addObserver() {}
42 },
43 vc: {
44 compare(v1, v2)
45 {
46 function comparePart(p1, p2)
47 {
48 if (p1 != "*" && p2 == "*")
49 return -1;
50 else if (p1 == "*" && p2 != "*")
51 return 1;
52 else if (p1 == p2)
53 return 0;
54 return parseInt(p1, 10) - parseInt(p2, 10);
55 }
56
57 let parts1 = v1.split(".");
58 let parts2 = v2.split(".");
59 for (let i = 0; i < Math.max(parts1.length, parts2.length); i++)
60 {
61 let result = comparePart(parts1[i] || "0", parts2[i] || "0");
62 if (result != 0)
63 return result;
64 }
65 return 0;
66 }
67 }
68 };
69 let XPCOMUtils = {
70 generateQI() {}
71 };
72 let FileUtils = {};
73 let resources = {Services, XPCOMUtils, FileUtils};
74
39 let globals = { 75 let globals = {
40 atob: data => new Buffer(data, "base64").toString("binary"), 76 atob: data => new Buffer(data, "base64").toString("binary"),
41 btoa: data => new Buffer(data, "binary").toString("base64"), 77 btoa: data => new Buffer(data, "binary").toString("base64"),
42 Ci: { 78 Ci: {
43 }, 79 },
44 Cu: { 80 Cu: {
45 import() {}, 81 import(resource)
82 {
83 let match = /^resource:\/\/gre\/modules\/(.+)\.jsm$/.exec(resource);
84 let resourceName = match && match[1];
85 if (resourceName && resources.hasOwnProperty(resourceName))
86 return {[resourceName]: resources[resourceName]};
87
88 throw new Error(
89 "Attempt to import unknown JavaScript module " + resource
90 );
91 },
46 reportError(e) {} 92 reportError(e) {}
47 }, 93 },
48 console: { 94 console: {
49 log() {}, 95 log() {},
50 error() {} 96 error() {}
51 }, 97 },
52 navigator: { 98 navigator: {
53 }, 99 },
54 onShutdown: { 100 onShutdown: {
55 add() {} 101 add() {}
56 },
57 Services: {
58 obs: {
59 addObserver() {}
60 },
61 vc: {
62 compare(v1, v2)
63 {
64 function comparePart(p1, p2)
65 {
66 if (p1 != "*" && p2 == "*")
67 return -1;
68 else if (p1 == "*" && p2 != "*")
69 return 1;
70 else if (p1 == p2)
71 return 0;
72 return parseInt(p1, 10) - parseInt(p2, 10);
73 }
74
75 let parts1 = v1.split(".");
76 let parts2 = v2.split(".");
77 for (let i = 0; i < Math.max(parts1.length, parts2.length); i++)
78 {
79 let result = comparePart(parts1[i] || "0", parts2[i] || "0");
80 if (result != 0)
81 return result;
82 }
83 return 0;
84 }
85 }
86 },
87 XPCOMUtils: {
88 generateQI() {}
89 }, 102 },
90 URL 103 URL
91 }; 104 };
92 105
93 let knownModules = new Map(); 106 let knownModules = new Map();
94 for (let dir of [path.join(__dirname, "stub-modules"), 107 for (let dir of [path.join(__dirname, "stub-modules"),
95 path.join(__dirname, "..", "lib")]) 108 path.join(__dirname, "..", "lib")])
96 { 109 {
97 for (let file of fs.readdirSync(path.resolve(dir))) 110 for (let file of fs.readdirSync(path.resolve(dir)))
98 { 111 {
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 round: Math.round 435 round: Math.round
423 } 436 }
424 }; 437 };
425 }; 438 };
426 439
427 exports.unexpectedError = function(error) 440 exports.unexpectedError = function(error)
428 { 441 {
429 console.error(error); 442 console.error(error);
430 this.ok(false, "Unexpected error: " + error); 443 this.ok(false, "Unexpected error: " + error);
431 }; 444 };
LEFTRIGHT

Powered by Google App Engine
This is Rietveld