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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
94 resolvePromise = resolve; | 94 resolvePromise = resolve; |
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 let result = Map.prototype.get.apply(browser.tabs, args); | 104 // Extend browser.tabs.get() |
a.giammarchi
2018/03/07 17:11:04
if you can use `Map.prototype.get.apply` with `bro
a.giammarchi
2018/03/07 17:17:49
actually, on a second thought, I don't understand
saroyanm
2018/03/08 15:14:27
This implementation is just use uses prototype.get
a.giammarchi
2018/03/08 17:27:34
it's not so clear from the code. Maybe a comment m
saroyanm
2018/03/08 18:16:47
Noted, I'll add one.
saroyanm
2018/03/12 15:45:21
Done.
| |
105 return new Promise((resolve, reject) => | 105 const result = Map.prototype.get.apply(browser.tabs, args); |
a.giammarchi
2018/03/07 17:11:04
If I understand correctly result is synchronous so
saroyanm
2018/03/08 15:14:27
This is the Mock implmenetation of tabs.get -> htt
a.giammarchi
2018/03/08 17:27:34
when the result is already known, there is no diff
saroyanm
2018/03/08 18:16:47
Sorry I think I misread your initial I though you
saroyanm
2018/03/12 15:45:21
Done.
| |
106 { | 106 return (result ? Promise.resolve(result) : |
107 if (result) | 107 Promise.reject(new Error("Tab cannot be found"))); |
108 resolve(result); | 108 }; |
109 else | |
110 reject(new Error("Tab cannot be found")); | |
111 }); | |
112 } | |
113 }()); | 109 }()); |
LEFT | RIGHT |