Left: | ||
Right: |
OLD | NEW |
---|---|
1 /* | 1 /* |
2 * This Source Code is subject to the terms of the Mozilla Public License | 2 * This Source Code is subject to the terms of the Mozilla Public License |
3 * version 2.0 (the "License"). You can obtain a copy of the License at | 3 * version 2.0 (the "License"). You can obtain a copy of the License at |
4 * http://mozilla.org/MPL/2.0/. | 4 * http://mozilla.org/MPL/2.0/. |
5 */ | 5 */ |
6 | 6 |
7 (function() | 7 (function() |
8 { | 8 { |
9 const Cu = Components.utils; | 9 const Cu = Components.utils; |
10 | 10 |
11 let rand = Components.stack.filename.replace(/.*\?/, ""); | 11 let rand = Components.stack.filename.replace(/.*\?/, ""); |
12 let module = "chrome://elemhidehelper/content/actor.jsm?" + rand; | 12 let module = "chrome://elemhidehelper/content/actor.jsm?" + rand; |
13 let {shutdown, getNodeInfo, togglePreview, forgetNode} = Cu.import(module, {}) ; | 13 let {shutdown, getNodeInfo, togglePreview, forgetNode} = Cu.import(module, {}) ; |
14 | 14 |
15 addMessageListener("ElemHideHelper:Shutdown", onShutdown); | 15 addMessageListener("ElemHideHelper:Shutdown", onShutdown); |
16 addMessageListener("ElemHideHelper:GetNodeInfo", onGetNodeInfo); | 16 addMessageListener("ElemHideHelper:GetNodeInfo", onGetNodeInfo); |
17 addMessageListener("ElemHideHelper:Preview", onTogglePreview); | 17 addMessageListener("ElemHideHelper:Preview", onTogglePreview); |
18 | 18 |
19 function onShutdown() | 19 function onShutdown() |
20 { | 20 { |
21 shutdown(); | 21 shutdown(); |
22 Cu.unload(module); | 22 try { |
23 Cu.unload(module); | |
24 } catch (e) { | |
saroyanm
2015/12/21 13:45:18
Nit: please move catch to it's own line to make it
Wladimir Palant
2015/12/21 19:01:59
Done.
| |
25 Cu.reportError(e); | |
26 } | |
27 | |
23 removeMessageListener("ElemHideHelper:Shutdown", onShutdown); | 28 removeMessageListener("ElemHideHelper:Shutdown", onShutdown); |
24 removeMessageListener("ElemHideHelper:GetNodeInfo", onGetNodeInfo); | 29 removeMessageListener("ElemHideHelper:GetNodeInfo", onGetNodeInfo); |
25 removeMessageListener("ElemHideHelper:Preview", onTogglePreview); | 30 removeMessageListener("ElemHideHelper:Preview", onTogglePreview); |
26 } | 31 } |
27 | 32 |
28 function onGetNodeInfo(message) | 33 function onGetNodeInfo(message) |
29 { | 34 { |
30 let nodeInfo = getNodeInfo(message.objects.element); | 35 let nodeInfo = getNodeInfo(message.objects.element); |
31 nodeInfo.messageId = message.data; | 36 nodeInfo.messageId = message.data; |
32 sendAsyncMessage("ElemHideHelper:GetNodeInfo:Response", nodeInfo); | 37 sendAsyncMessage("ElemHideHelper:GetNodeInfo:Response", nodeInfo); |
33 } | 38 } |
34 | 39 |
35 function onTogglePreview(message) | 40 function onTogglePreview(message) |
36 { | 41 { |
37 togglePreview(message.data.nodeID, message.data.stylesheetData); | 42 togglePreview(message.data.nodeID, message.data.stylesheetData); |
38 if (message.data.forgetNode) | 43 if (message.data.forgetNode) |
39 forgetNode(message.data.nodeID); | 44 forgetNode(message.data.nodeID); |
40 } | 45 } |
41 })(); | 46 })(); |
OLD | NEW |