OLD | NEW |
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-2017 eyeo GmbH | 3 * Copyright (C) 2006-2017 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 get: () => wrapFrames(frames.slice(1)) | 43 get: () => wrapFrames(frames.slice(1)) |
44 }); | 44 }); |
45 | 45 |
46 return frames; | 46 return frames; |
47 } | 47 } |
48 | 48 |
49 var EventTarget = global.ext._EventTarget = function(port, windowID) | 49 var EventTarget = global.ext._EventTarget = function(port, windowID) |
50 { | 50 { |
51 this._port = port; | 51 this._port = port; |
52 this._windowID = windowID; | 52 this._windowID = windowID; |
| 53 this.addListener((payload, sender, resolve) => |
| 54 { |
| 55 if (payload.type) |
| 56 { |
| 57 let result = this._port._dispatch(payload.type, payload, sender); |
| 58 if (typeof result != "undefined") |
| 59 resolve(result); |
| 60 } |
| 61 }); |
53 }; | 62 }; |
54 EventTarget.prototype = { | 63 EventTarget.prototype = { |
55 addListener: function(listener) | 64 addListener: function(listener) |
56 { | 65 { |
57 var wrapper = (message, sender) => | 66 var wrapper = (message, sender) => |
58 { | 67 { |
59 if (this._windowID && this._windowID != message.targetID) | 68 if (this._windowID && this._windowID != message.targetID) |
60 return undefined; | 69 return undefined; |
61 | 70 |
62 return new Promise((resolve, reject) => | 71 return new Promise((resolve, reject) => |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 if (key[0] != "@") | 115 if (key[0] != "@") |
107 Cu.reportError(e); | 116 Cu.reportError(e); |
108 return ""; | 117 return ""; |
109 } | 118 } |
110 } | 119 } |
111 }; | 120 }; |
112 | 121 |
113 if (typeof exports == "object") | 122 if (typeof exports == "object") |
114 exports = global.ext; | 123 exports = global.ext; |
115 })(this); | 124 })(this); |
OLD | NEW |