Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: chrome/content/processScript.js

Issue 29332902: Issue 3443 - Use process script instead of a frame script in Element Hiding Helper (Closed)
Patch Set: Addressed comments Created Dec. 21, 2015, 7:13 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/content/frameScript.js ('k') | lib/aardvark.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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)
« no previous file with comments | « chrome/content/frameScript.js ('k') | lib/aardvark.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld