| Index: ext/content.js |
| =================================================================== |
| --- a/ext/content.js |
| +++ b/ext/content.js |
| @@ -67,7 +67,6 @@ |
| browser.runtime.sendMessage = (message, responseCallback) => |
| { |
| let messageId = ++maxMessageId; |
| - |
| ext.backgroundPage._sendRawMessage({ |
| type: "message", |
| messageId, |
| @@ -96,4 +95,19 @@ |
| }); |
| } |
| }; |
| + |
| + if (!("tabs" in browser)) |
| + browser.tabs = new Map([[0, {url: "example.com"}]]); |
| + |
| + browser.tabs.get = (...args) => |
| + { |
| + let result = Map.prototype.get.apply(browser.tabs, args); |
|
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.
|
| + return new Promise((resolve, reject) => |
|
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.
|
| + { |
| + if (result) |
| + resolve(result); |
| + else |
| + reject(new Error("Tab cannot be found")); |
| + }); |
| + } |
| }()); |