Left: | ||
Right: |
LEFT | RIGHT |
---|---|
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-present eyeo GmbH | 3 * Copyright (C) 2006-present 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
95 }); | 95 }); |
96 } | 96 } |
97 }; | 97 }; |
98 | 98 |
99 if (!("tabs" in browser)) | 99 if (!("tabs" in browser)) |
100 browser.tabs = new Map([[0, {url: "example.com"}]]); | 100 browser.tabs = new Map([[0, {url: "example.com"}]]); |
101 | 101 |
102 browser.tabs.get = (...args) => | 102 browser.tabs.get = (...args) => |
103 { | 103 { |
104 // Extend browser.tabs.get() | 104 // Extend browser.tabs.get() |
105 let result = Map.prototype.get.apply(browser.tabs, args); | 105 const result = Map.prototype.get.apply(browser.tabs, args); |
106 const error = new Error("Tab cannot be found"); | 106 return (result ? Promise.resolve(result) : |
a.giammarchi
2018/03/12 15:53:08
Nit: when there is a result, there's no actually n
saroyanm
2018/03/12 16:09:52
Done. I'm using one ternary operator to make this
| |
107 return result ? Promise.resolve(result) : Promise.reject(error); | 107 Promise.reject(new Error("Tab cannot be found"))); |
108 }; | 108 }; |
109 }()); | 109 }()); |
LEFT | RIGHT |