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

Unified Diff: lib/aardvark.js

Issue 29323439: Issue 2877 - Element Hiding Helper causes tab to crash when selecting some elements (Closed)
Patch Set: Removed extra newline Created Aug. 11, 2015, 1:56 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') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/aardvark.js
===================================================================
--- a/lib/aardvark.js
+++ b/lib/aardvark.js
@@ -7,16 +7,18 @@
let {Prefs} = require("prefs");
// Make sure to stop selection when we are uninstalled
onShutdown.add(() => Aardvark.quit());
// To be replaced when selection starts
function E(id) {return null;}
+let messageCounter = 0;
+
/*********************************
* Minimal element creation code *
*********************************/
function createElement(doc, tagName, attrs, children)
{
let el = doc.createElement(tagName);
if (attrs)
@@ -585,31 +587,45 @@ let Aardvark = exports.Aardvark =
return false;
},
select: function(elem)
{
if (!elem)
return false;
+ let messageId = ++messageCounter;
+ let callback = (message) =>
+ {
+ let response = message.data;
+ if (response.messageId != messageId)
+ return;
+
+ this.browser.selectedBrowser.messageManager.removeMessageListener(
+ "ElemHideHelper:GetNodeInfo:Response",
+ callback
+ );
+
+ if (!response.nodeData)
+ return;
+
+ this.window.openDialog("chrome://elemhidehelper/content/composer.xul",
+ "_blank", "chrome,centerscreen,resizable,dialog=no", response);
+ this.quit();
+ };
+
+ this.browser.selectedBrowser.messageManager.addMessageListener(
+ "ElemHideHelper:GetNodeInfo:Response",
+ callback
+ );
this.browser.selectedBrowser.messageManager.sendAsyncMessage(
"ElemHideHelper:GetNodeInfo",
- null,
+ messageId,
{
- element: elem,
- callback: (response) =>
- {
- response = JSON.parse(response);
- if (!response.nodeData)
- return;
-
- this.window.openDialog("chrome://elemhidehelper/content/composer.xul",
- "_blank", "chrome,centerscreen,resizable,dialog=no", response);
- this.quit();
- }
+ element: elem
}
);
return false;
},
blinkElement: function(elem)
{
if (!elem)
« no previous file with comments | « chrome/content/frameScript.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld