Index: chrome/content/processScript.js |
=================================================================== |
rename from chrome/content/actor.jsm |
rename to chrome/content/processScript.js |
--- a/chrome/content/actor.jsm |
+++ b/chrome/content/processScript.js |
@@ -1,17 +1,14 @@ |
/* |
* This Source Code is subject to the terms of the Mozilla Public License |
* version 2.0 (the "License"). You can obtain a copy of the License at |
* http://mozilla.org/MPL/2.0/. |
*/ |
-let EXPORTED_SYMBOLS = ["shutdown", "getNodeInfo", "togglePreview", |
- "forgetNode"]; |
- |
const Ci = Components.interfaces; |
const Cu = Components.utils; |
let {console} = Cu.import("resource://gre/modules/devtools/Console.jsm", {}); |
let {DebuggerServer} = Cu.import("resource://gre/modules/devtools/dbg-server.jsm", {}); |
let {Services} = Cu.import("resource://gre/modules/Services.jsm", {}); |
let processID = Services.appinfo.processID; |
@@ -20,39 +17,56 @@ let nodes = new Map(); |
let name = "elemhidehelper"; |
let actor = { |
constructorFun: Actor, |
constructorName: name, |
name: name |
}; |
+addMessageListener("ElemHideHelper:Shutdown", onShutdown); |
+addMessageListener("ElemHideHelper:GetNodeInfo", onGetNodeInfo); |
+addMessageListener("ElemHideHelper:Preview", onTogglePreview); |
+ |
DebuggerServer.addTabActor(actor, name); |
-var shutdown = (function() |
+function onShutdown() |
{ |
- let executed = false; |
- return function() |
+ removeMessageListener("ElemHideHelper:Shutdown", onShutdown); |
+ removeMessageListener("ElemHideHelper:GetNodeInfo", onGetNodeInfo); |
+ removeMessageListener("ElemHideHelper:Preview", onTogglePreview); |
+ |
+ try |
{ |
- if (!executed) |
- { |
- executed = true; |
- try |
- { |
- DebuggerServer.removeTabActor(actor); |
- } |
- catch (e) |
- { |
- // The call above will throw in the content process despite succeeding, |
- // see https://bugzilla.mozilla.org/show_bug.cgi?id=1189780. |
- Cu.reportError(e); |
- } |
- } |
+ DebuggerServer.removeTabActor(actor); |
} |
-})(); |
+ catch (e) |
+ { |
+ // The call above will throw in the content process despite succeeding, |
+ // see https://bugzilla.mozilla.org/show_bug.cgi?id=1189780. |
+ Cu.reportError(e); |
+ } |
+} |
+ |
+function onGetNodeInfo(message) |
+{ |
+ if (Cu.isCrossProcessWrapper(message.objects.element)) |
+ return; |
+ |
+ let nodeInfo = getNodeInfo(message.objects.element); |
+ nodeInfo.messageId = message.data; |
+ sendAsyncMessage("ElemHideHelper:GetNodeInfo:Response", nodeInfo); |
+} |
+ |
+function onTogglePreview(message) |
+{ |
+ togglePreview(message.data.nodeID, message.data.stylesheetData); |
+ if (message.data.forgetNode) |
+ forgetNode(message.data.nodeID); |
+} |
function Actor(connection, tabActor) |
{ |
} |
Actor.prototype = { |
requestTypes: { |
nodeinfo: function(request, connection) |