Skip to content

Commit

Permalink
Experimental: add Ctrl[+Shift]+W hotkey to inspect "window" object
Browse files Browse the repository at this point in the history
  • Loading branch information
Infocatcher committed Oct 21, 2013
1 parent b35f60b commit afa2b7c
Showing 1 changed file with 69 additions and 0 deletions.
69 changes: 69 additions & 0 deletions Attributes_Inspector/attrsInspector.js
Expand Up @@ -1112,6 +1112,26 @@ function init() {
var nodes = this._nodes;
nodes.length && this.inspect(nodes[0], top, e.shiftKey);
}
else if( // Ctrl+W, Ctrl+Shift+W
ctrlOrCtrlShift && (
e.keyCode == e.DOM_VK_W // keydown || keyup
|| e.keyCode == 0 && String.fromCharCode(e.charCode).toUpperCase() == "W" // keypress
)
) {
this._checkPreventDefault(e);
this.stopEvent(e);
if(onlyStop)
return;
this.stopSingleEvent(top, "keyup");
this.stop();
this.hideUnclosedPopups();
var nodes = this._nodes;
var node = nodes.length && nodes[0];
if(node) {
this.closeMenus(node);
this.inspectWindow(top, node);
}
}
},
navigateUp: function(top) {
var nodes = this._nodes;
Expand Down Expand Up @@ -1263,6 +1283,55 @@ function init() {
}
return childNodes;
},
inspectWindow: function(top, node) {
if(!("@mozilla.org/commandlinehandler/general-startup;1?type=inspector" in Components.classes)) {
_log("DOM Inspector not installed!");
return null;
}
var inspWin = top.openDialog(
"chrome://inspector/content/",
"_blank",
"chrome,all,dialog=no",
//node.ownerDocument || node
node
);
inspWin.addEventListener("load", function load(e) {
inspWin.removeEventListener(e.type, load, false);
var doc = inspWin.document;
var stopTime = Date.now() + 3e3;
inspWin.setTimeout(function selectJsPanel() {
var panel = doc.getElementById("bxDocPanel");
var js = doc.getAnonymousElementByAttribute(panel, "viewerListEntry", "8");
if(!js && Date.now() < stopTime) {
inspWin.setTimeout(selectJsPanel, 50);
return;
}
js.doCommand();
var browser = doc.getAnonymousElementByAttribute(panel, "anonid", "viewer-iframe");
stopTime = Date.now() + 3e3;
inspWin.setTimeout(function selectWindow() {
var brDoc = browser.contentDocument;
var tree = brDoc.getElementById("treeJSObject");
if(tree && tree.columns && tree.view) {
var keyCol = tree.columns.getKeyColumn();
var view = tree.view;
for(var i = 0, rowCount = view.rowCount; i < rowCount; ++i) {
var cellText = view.getCellText(i, keyCol);
if(cellText == "defaultView") {
tree.changeOpenState(i, true);
view.selection.select(i);
tree.treeBoxObject.scrollByLines(i);
tree.treeBoxObject.ensureRowIsVisible(i);
return;
}
}
}
if(Date.now() < stopTime)
inspWin.setTimeout(selectWindow, 50);
}, 0);
}, 0);
}, false);
},
copyTootipContent: function() {
var node = this._node;
var sourceWindow = node && (node.ownerDocument || node).defaultView;
Expand Down

0 comments on commit afa2b7c

Please sign in to comment.