mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-24 02:35:41 +00:00
Bug 687854 - Move the Inspector code to browser/devtools, r=gavin,robcee
--HG-- rename : browser/devtools/highlighter/inspector.js => browser/devtools/highlighter/inspector.jsm
This commit is contained in:
parent
0f29518199
commit
3cb9a0ee6b
@ -173,6 +173,12 @@ XPCOMUtils.defineLazyGetter(this, "PopupNotifications", function () {
|
||||
}
|
||||
});
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "InspectorUI", function() {
|
||||
let tmp = {};
|
||||
Cu.import("resource:///modules/inspector.jsm", tmp);
|
||||
return new tmp.InspectorUI(window);
|
||||
});
|
||||
|
||||
let gInitialPages = [
|
||||
"about:blank",
|
||||
"about:privatebrowsing",
|
||||
@ -180,7 +186,6 @@ let gInitialPages = [
|
||||
];
|
||||
|
||||
#include browser-fullZoom.js
|
||||
#include ../../devtools/highlighter/inspector.js
|
||||
#include browser-places.js
|
||||
#include browser-tabPreviews.js
|
||||
#include browser-tabview.js
|
||||
@ -1676,7 +1681,8 @@ function delayedStartup(isLoadingBlank, mustLoadSidebar) {
|
||||
TabView.init();
|
||||
|
||||
// Enable Inspector?
|
||||
if (InspectorUI.enabled) {
|
||||
let enabled = gPrefService.getBoolPref("devtools.inspector.enabled");
|
||||
if (enabled) {
|
||||
document.getElementById("menu_pageinspect").hidden = false;
|
||||
document.getElementById("Tools:Inspect").removeAttribute("disabled");
|
||||
#ifdef MENUBAR_CAN_AUTOHIDE
|
||||
@ -1724,6 +1730,9 @@ function BrowserShutdown() {
|
||||
if (!gStartupRan)
|
||||
return;
|
||||
|
||||
if (!__lookupGetter__("InspectorUI"))
|
||||
InspectorUI.destroy();
|
||||
|
||||
// First clean up services initialized in BrowserStartup (or those whose
|
||||
// uninit methods don't depend on the services having been initialized).
|
||||
allTabs.uninit();
|
||||
|
@ -45,6 +45,7 @@ VPATH = @srcdir@
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
EXTRA_JS_MODULES = \
|
||||
inspector.jsm \
|
||||
domplate.jsm \
|
||||
InsideOutBox.jsm \
|
||||
TreePanel.jsm \
|
||||
|
@ -141,7 +141,7 @@ TreePanel.prototype = {
|
||||
this.treeIFrame.addEventListener("dblclick", this.onTreeDblClick.bind(this), false);
|
||||
delete this.initializingTreePanel;
|
||||
Services.obs.notifyObservers(null,
|
||||
this.window.INSPECTOR_NOTIFICATIONS.TREEPANELREADY, null);
|
||||
this.IUI.INSPECTOR_NOTIFICATIONS.TREEPANELREADY, null);
|
||||
if (this.IUI.selection)
|
||||
this.select(this.IUI.selection, true);
|
||||
},
|
||||
@ -548,7 +548,7 @@ TreePanel.prototype = {
|
||||
this.handleEditorKeypress.bind(this));
|
||||
|
||||
// event notification
|
||||
Services.obs.notifyObservers(null, this.window.INSPECTOR_NOTIFICATIONS.EDITOR_OPENED,
|
||||
Services.obs.notifyObservers(null, this.IUI.INSPECTOR_NOTIFICATIONS.EDITOR_OPENED,
|
||||
null);
|
||||
},
|
||||
|
||||
@ -626,7 +626,7 @@ TreePanel.prototype = {
|
||||
this.editingEvents = {};
|
||||
|
||||
// event notification
|
||||
Services.obs.notifyObservers(null, this.window.INSPECTOR_NOTIFICATIONS.EDITOR_CLOSED,
|
||||
Services.obs.notifyObservers(null, this.IUI.INSPECTOR_NOTIFICATIONS.EDITOR_CLOSED,
|
||||
null);
|
||||
},
|
||||
|
||||
@ -648,7 +648,7 @@ TreePanel.prototype = {
|
||||
this.IUI.isDirty = true;
|
||||
|
||||
// event notification
|
||||
Services.obs.notifyObservers(null, this.window.INSPECTOR_NOTIFICATIONS.EDITOR_SAVED,
|
||||
Services.obs.notifyObservers(null, this.IUI.INSPECTOR_NOTIFICATIONS.EDITOR_SAVED,
|
||||
null);
|
||||
|
||||
this.closeEditor();
|
||||
|
@ -1,6 +1,5 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
#ifdef 0
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
@ -41,7 +40,15 @@
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#endif
|
||||
|
||||
const Cu = Components.utils;
|
||||
const Ci = Components.interfaces;
|
||||
const Cr = Components.results;
|
||||
|
||||
var EXPORTED_SYMBOLS = ["InspectorUI"];
|
||||
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
const INSPECTOR_INVISIBLE_ELEMENTS = {
|
||||
"head": true,
|
||||
@ -91,30 +98,32 @@ const INSPECTOR_NOTIFICATIONS = {
|
||||
* <box id="highlighter-controls>...</vbox>
|
||||
* </stack>
|
||||
*
|
||||
* @param nsIDOMNode aBrowser
|
||||
* The xul:browser object for the content window being highlighted.
|
||||
* @param object aInspector
|
||||
* The InspectorUI instance.
|
||||
*/
|
||||
function Highlighter(aBrowser)
|
||||
function Highlighter(aInspector)
|
||||
{
|
||||
this._init(aBrowser);
|
||||
this.IUI = aInspector;
|
||||
this._init();
|
||||
}
|
||||
|
||||
Highlighter.prototype = {
|
||||
|
||||
_init: function Highlighter__init(aBrowser)
|
||||
_init: function Highlighter__init()
|
||||
{
|
||||
this.browser = aBrowser;
|
||||
this.browser = this.IUI.browser;
|
||||
this.chromeDoc = this.IUI.chromeDoc;
|
||||
|
||||
let stack = this.browser.parentNode;
|
||||
this.win = this.browser.contentWindow;
|
||||
this._highlighting = false;
|
||||
|
||||
this.highlighterContainer = document.createElement("stack");
|
||||
this.highlighterContainer = this.chromeDoc.createElement("stack");
|
||||
this.highlighterContainer.id = "highlighter-container";
|
||||
|
||||
this.veilContainer = document.createElement("vbox");
|
||||
this.veilContainer = this.chromeDoc.createElement("vbox");
|
||||
this.veilContainer.id = "highlighter-veil-container";
|
||||
|
||||
let controlsBox = document.createElement("box");
|
||||
let controlsBox = this.chromeDoc.createElement("box");
|
||||
controlsBox.id = "highlighter-controls";
|
||||
|
||||
// The veil will make the whole page darker except
|
||||
@ -153,32 +162,31 @@ Highlighter.prototype = {
|
||||
*/
|
||||
buildVeil: function Highlighter_buildVeil(aParent)
|
||||
{
|
||||
|
||||
// We will need to resize these boxes to surround a node.
|
||||
// See highlightRectangle().
|
||||
|
||||
this.veilTopBox = document.createElement("box");
|
||||
this.veilTopBox = this.chromeDoc.createElement("box");
|
||||
this.veilTopBox.id = "highlighter-veil-topbox";
|
||||
this.veilTopBox.className = "highlighter-veil";
|
||||
|
||||
this.veilMiddleBox = document.createElement("hbox");
|
||||
this.veilMiddleBox = this.chromeDoc.createElement("hbox");
|
||||
this.veilMiddleBox.id = "highlighter-veil-middlebox";
|
||||
|
||||
this.veilLeftBox = document.createElement("box");
|
||||
this.veilLeftBox = this.chromeDoc.createElement("box");
|
||||
this.veilLeftBox.id = "highlighter-veil-leftbox";
|
||||
this.veilLeftBox.className = "highlighter-veil";
|
||||
|
||||
this.veilTransparentBox = document.createElement("box");
|
||||
this.veilTransparentBox = this.chromeDoc.createElement("box");
|
||||
this.veilTransparentBox.id = "highlighter-veil-transparentbox";
|
||||
|
||||
// We don't need any references to veilRightBox and veilBottomBox.
|
||||
// These boxes are automatically resized (flex=1)
|
||||
|
||||
let veilRightBox = document.createElement("box");
|
||||
let veilRightBox = this.chromeDoc.createElement("box");
|
||||
veilRightBox.id = "highlighter-veil-rightbox";
|
||||
veilRightBox.className = "highlighter-veil";
|
||||
|
||||
let veilBottomBox = document.createElement("box");
|
||||
let veilBottomBox = this.chromeDoc.createElement("box");
|
||||
veilBottomBox.id = "highlighter-veil-bottombox";
|
||||
veilBottomBox.className = "highlighter-veil";
|
||||
|
||||
@ -200,11 +208,12 @@ Highlighter.prototype = {
|
||||
*/
|
||||
buildControls: function Highlighter_buildControls(aParent)
|
||||
{
|
||||
let closeButton = document.createElement("box");
|
||||
let closeButton = this.chromeDoc.createElement("box");
|
||||
closeButton.id = "highlighter-close-button";
|
||||
closeButton.appendChild(document.createElement("image"));
|
||||
closeButton.appendChild(this.chromeDoc.createElement("image"));
|
||||
|
||||
closeButton.setAttribute("onclick", "InspectorUI.closeInspectorUI(false);");
|
||||
closeButton.addEventListener("click",
|
||||
this.IUI.closeInspectorUI.bind(this.IUI), false);
|
||||
|
||||
aParent.appendChild(closeButton);
|
||||
},
|
||||
@ -228,7 +237,8 @@ Highlighter.prototype = {
|
||||
this.highlighterContainer = null;
|
||||
this.win = null
|
||||
this.browser = null;
|
||||
this.toolbar = null;
|
||||
this.chromeDoc = null;
|
||||
this.IUI = null;
|
||||
},
|
||||
|
||||
/**
|
||||
@ -307,7 +317,7 @@ Highlighter.prototype = {
|
||||
let frameRect = frameWin.frameElement.getBoundingClientRect();
|
||||
|
||||
let [offsetTop, offsetLeft] =
|
||||
InspectorUI.getIframeContentOffset(frameWin.frameElement);
|
||||
this.IUI.getIframeContentOffset(frameWin.frameElement);
|
||||
|
||||
rect.top += frameRect.top + offsetTop;
|
||||
rect.left += frameRect.left + offsetLeft;
|
||||
@ -382,7 +392,7 @@ Highlighter.prototype = {
|
||||
this.veilMiddleBox.style.height = 0;
|
||||
this.veilTransparentBox.style.width = 0;
|
||||
Services.obs.notifyObservers(null,
|
||||
INSPECTOR_NOTIFICATIONS.UNHIGHLIGHTING, null);
|
||||
InspectorUI.INSPECTOR_NOTIFICATIONS.UNHIGHLIGHTING, null);
|
||||
},
|
||||
|
||||
/**
|
||||
@ -432,7 +442,7 @@ Highlighter.prototype = {
|
||||
// Get midpoint of diagonal line.
|
||||
let midpoint = this.midPoint(a, b);
|
||||
|
||||
return InspectorUI.elementFromPoint(this.win.document, midpoint.x,
|
||||
return this.IUI.elementFromPoint(this.win.document, midpoint.x,
|
||||
midpoint.y);
|
||||
},
|
||||
|
||||
@ -444,7 +454,7 @@ Highlighter.prototype = {
|
||||
*/
|
||||
isNodeHighlightable: function Highlighter_isNodeHighlightable()
|
||||
{
|
||||
if (!this.node || this.node.nodeType != Node.ELEMENT_NODE) {
|
||||
if (!this.node || this.node.nodeType != this.node.ELEMENT_NODE) {
|
||||
return false;
|
||||
}
|
||||
let nodeName = this.node.nodeName.toLowerCase();
|
||||
@ -514,7 +524,7 @@ Highlighter.prototype = {
|
||||
// Stop inspection when the user clicks on a node.
|
||||
if (aEvent.button == 0) {
|
||||
let win = aEvent.target.ownerDocument.defaultView;
|
||||
InspectorUI.stopInspecting();
|
||||
this.IUI.stopInspecting();
|
||||
win.focus();
|
||||
}
|
||||
aEvent.preventDefault();
|
||||
@ -529,10 +539,10 @@ Highlighter.prototype = {
|
||||
*/
|
||||
handleMouseMove: function Highlighter_handleMouseMove(aEvent)
|
||||
{
|
||||
let element = InspectorUI.elementFromPoint(aEvent.target.ownerDocument,
|
||||
let element = this.IUI.elementFromPoint(aEvent.target.ownerDocument,
|
||||
aEvent.clientX, aEvent.clientY);
|
||||
if (element && element != this.node) {
|
||||
InspectorUI.inspectNode(element);
|
||||
this.IUI.inspectNode(element);
|
||||
}
|
||||
},
|
||||
|
||||
@ -550,18 +560,30 @@ Highlighter.prototype = {
|
||||
|
||||
/**
|
||||
* Main controller class for the Inspector.
|
||||
*
|
||||
* @constructor
|
||||
* @param nsIDOMWindow aWindow
|
||||
* The chrome window for which the Inspector instance is created.
|
||||
*/
|
||||
var InspectorUI = {
|
||||
function InspectorUI(aWindow)
|
||||
{
|
||||
this.chromeWin = aWindow;
|
||||
this.chromeDoc = aWindow.document;
|
||||
this.tabbrowser = aWindow.gBrowser;
|
||||
this.tools = {};
|
||||
this.toolEvents = {};
|
||||
this.store = new InspectorStore();
|
||||
this.INSPECTOR_NOTIFICATIONS = INSPECTOR_NOTIFICATIONS;
|
||||
}
|
||||
|
||||
InspectorUI.prototype = {
|
||||
browser: null,
|
||||
tools: {},
|
||||
toolEvents: {},
|
||||
tools: null,
|
||||
toolEvents: null,
|
||||
inspecting: false,
|
||||
treePanelEnabled: true,
|
||||
get enabled()
|
||||
{
|
||||
return gPrefService.getBoolPref("devtools.inspector.enabled");
|
||||
},
|
||||
isDirty: false,
|
||||
store: null,
|
||||
|
||||
/**
|
||||
* Toggle the inspector interface elements on or off.
|
||||
@ -644,16 +666,19 @@ var InspectorUI = {
|
||||
false);
|
||||
}
|
||||
// Start initialization.
|
||||
this.browser = gBrowser.selectedBrowser;
|
||||
this.browser = this.tabbrowser.selectedBrowser;
|
||||
this.win = this.browser.contentWindow;
|
||||
this.winID = this.getWindowID(this.win);
|
||||
this.toolbar = document.getElementById("inspector-toolbar");
|
||||
this.toolbar = this.chromeDoc.getElementById("inspector-toolbar");
|
||||
this.inspectMenuitem = this.chromeDoc.getElementById("Tools:Inspect");
|
||||
this.inspectToolbutton =
|
||||
this.chromeDoc.getElementById("inspector-inspect-toolbutton");
|
||||
|
||||
this.initTools();
|
||||
|
||||
if (!this.TreePanel && this.treePanelEnabled) {
|
||||
Cu.import("resource:///modules/TreePanel.jsm", this);
|
||||
this.treePanel = new this.TreePanel(window, this);
|
||||
this.treePanel = new this.TreePanel(this.chromeWin, this);
|
||||
}
|
||||
|
||||
this.toolbar.hidden = false;
|
||||
@ -661,7 +686,7 @@ var InspectorUI = {
|
||||
|
||||
this.isDirty = false;
|
||||
|
||||
gBrowser.addProgressListener(InspectorProgressListener);
|
||||
this.progressListener = new InspectorProgressListener(this);
|
||||
|
||||
// initialize the highlighter
|
||||
this.initializeHighlighter();
|
||||
@ -675,12 +700,12 @@ var InspectorUI = {
|
||||
// Style inspector
|
||||
if (Services.prefs.getBoolPref("devtools.styleinspector.enabled") &&
|
||||
!this.toolRegistered("styleinspector")) {
|
||||
let stylePanel = this.StyleInspector.createPanel(true);
|
||||
let stylePanel = StyleInspector.createPanel(true);
|
||||
this.registerTool({
|
||||
id: "styleinspector",
|
||||
label: InspectorUI.StyleInspector.l10n("style.highlighter.button.label"),
|
||||
tooltiptext: InspectorUI.StyleInspector.l10n("style.highlighter.button.tooltip"),
|
||||
accesskey: InspectorUI.StyleInspector.l10n("style.highlighter.accesskey"),
|
||||
label: StyleInspector.l10n("style.highlighter.button.label"),
|
||||
tooltiptext: StyleInspector.l10n("style.highlighter.button.tooltip"),
|
||||
accesskey: StyleInspector.l10n("style.highlighter.accesskey"),
|
||||
context: stylePanel,
|
||||
get isOpen() stylePanel.isOpen(),
|
||||
onSelect: stylePanel.selectNode,
|
||||
@ -699,7 +724,7 @@ var InspectorUI = {
|
||||
*/
|
||||
initializeHighlighter: function IUI_initializeHighlighter()
|
||||
{
|
||||
this.highlighter = new Highlighter(this.browser);
|
||||
this.highlighter = new Highlighter(this);
|
||||
this.highlighterReady();
|
||||
},
|
||||
|
||||
@ -709,22 +734,23 @@ var InspectorUI = {
|
||||
initializeStore: function IUI_initializeStore()
|
||||
{
|
||||
// First time opened, add the TabSelect listener
|
||||
if (InspectorStore.isEmpty())
|
||||
gBrowser.tabContainer.addEventListener("TabSelect", this, false);
|
||||
if (this.store.isEmpty()) {
|
||||
this.tabbrowser.tabContainer.addEventListener("TabSelect", this, false);
|
||||
}
|
||||
|
||||
// Has this windowID been inspected before?
|
||||
if (InspectorStore.hasID(this.winID)) {
|
||||
let selectedNode = InspectorStore.getValue(this.winID, "selectedNode");
|
||||
if (this.store.hasID(this.winID)) {
|
||||
let selectedNode = this.store.getValue(this.winID, "selectedNode");
|
||||
if (selectedNode) {
|
||||
this.inspectNode(selectedNode);
|
||||
}
|
||||
this.isDirty = InspectorStore.getValue(this.winID, "isDirty");
|
||||
this.isDirty = this.store.getValue(this.winID, "isDirty");
|
||||
} else {
|
||||
// First time inspecting, set state to no selection + live inspection.
|
||||
InspectorStore.addStore(this.winID);
|
||||
InspectorStore.setValue(this.winID, "selectedNode", null);
|
||||
InspectorStore.setValue(this.winID, "inspecting", true);
|
||||
InspectorStore.setValue(this.winID, "isDirty", this.isDirty);
|
||||
this.store.addStore(this.winID);
|
||||
this.store.setValue(this.winID, "selectedNode", null);
|
||||
this.store.setValue(this.winID, "inspecting", true);
|
||||
this.store.setValue(this.winID, "isDirty", this.isDirty);
|
||||
this.win.addEventListener("pagehide", this, true);
|
||||
}
|
||||
},
|
||||
@ -753,23 +779,24 @@ var InspectorUI = {
|
||||
this.closing = true;
|
||||
this.toolbar.hidden = true;
|
||||
|
||||
gBrowser.removeProgressListener(InspectorProgressListener);
|
||||
this.progressListener.destroy();
|
||||
delete this.progressListener;
|
||||
|
||||
if (!aKeepStore) {
|
||||
InspectorStore.deleteStore(this.winID);
|
||||
this.store.deleteStore(this.winID);
|
||||
this.win.removeEventListener("pagehide", this, true);
|
||||
} else {
|
||||
// Update the store before closing.
|
||||
if (this.selection) {
|
||||
InspectorStore.setValue(this.winID, "selectedNode",
|
||||
this.store.setValue(this.winID, "selectedNode",
|
||||
this.selection);
|
||||
}
|
||||
InspectorStore.setValue(this.winID, "inspecting", this.inspecting);
|
||||
InspectorStore.setValue(this.winID, "isDirty", this.isDirty);
|
||||
this.store.setValue(this.winID, "inspecting", this.inspecting);
|
||||
this.store.setValue(this.winID, "isDirty", this.isDirty);
|
||||
}
|
||||
|
||||
if (InspectorStore.isEmpty()) {
|
||||
gBrowser.tabContainer.removeEventListener("TabSelect", this, false);
|
||||
if (this.store.isEmpty()) {
|
||||
this.tabbrowser.tabContainer.removeEventListener("TabSelect", this, false);
|
||||
}
|
||||
|
||||
this.stopInspecting();
|
||||
@ -877,7 +904,7 @@ var InspectorUI = {
|
||||
// Setup the InspectorStore or restore state
|
||||
this.initializeStore();
|
||||
|
||||
if (InspectorStore.getValue(this.winID, "inspecting")) {
|
||||
if (this.store.getValue(this.winID, "inspecting")) {
|
||||
this.startInspecting();
|
||||
}
|
||||
|
||||
@ -901,27 +928,28 @@ var InspectorUI = {
|
||||
|
||||
switch (event.type) {
|
||||
case "TabSelect":
|
||||
winID = this.getWindowID(gBrowser.selectedBrowser.contentWindow);
|
||||
winID = this.getWindowID(this.tabbrowser.selectedBrowser.contentWindow);
|
||||
if (this.isInspectorOpen && winID != this.winID) {
|
||||
this.closeInspectorUI(true);
|
||||
inspectorClosed = true;
|
||||
}
|
||||
|
||||
if (winID && InspectorStore.hasID(winID)) {
|
||||
if (winID && this.store.hasID(winID)) {
|
||||
if (inspectorClosed && this.closing) {
|
||||
Services.obs.addObserver(function reopenInspectorForTab() {
|
||||
Services.obs.removeObserver(reopenInspectorForTab,
|
||||
INSPECTOR_NOTIFICATIONS.CLOSED, false);
|
||||
|
||||
InspectorUI.openInspectorUI();
|
||||
}, INSPECTOR_NOTIFICATIONS.CLOSED, false);
|
||||
this.openInspectorUI();
|
||||
}.bind(this), INSPECTOR_NOTIFICATIONS.CLOSED, false);
|
||||
} else {
|
||||
this.openInspectorUI();
|
||||
}
|
||||
}
|
||||
|
||||
if (InspectorStore.isEmpty()) {
|
||||
gBrowser.tabContainer.removeEventListener("TabSelect", this, false);
|
||||
if (this.store.isEmpty()) {
|
||||
this.tabbrowser.tabContainer.removeEventListener("TabSelect", this,
|
||||
false);
|
||||
}
|
||||
break;
|
||||
case "pagehide":
|
||||
@ -935,17 +963,18 @@ var InspectorUI = {
|
||||
|
||||
winID = this.getWindowID(win);
|
||||
if (winID && winID != this.winID) {
|
||||
InspectorStore.deleteStore(winID);
|
||||
this.store.deleteStore(winID);
|
||||
}
|
||||
|
||||
if (InspectorStore.isEmpty()) {
|
||||
gBrowser.tabContainer.removeEventListener("TabSelect", this, false);
|
||||
if (this.store.isEmpty()) {
|
||||
this.tabbrowser.tabContainer.removeEventListener("TabSelect", this,
|
||||
false);
|
||||
}
|
||||
break;
|
||||
case "keypress":
|
||||
switch (event.keyCode) {
|
||||
case KeyEvent.DOM_VK_RETURN:
|
||||
case KeyEvent.DOM_VK_ESCAPE:
|
||||
case this.chromeWin.KeyEvent.DOM_VK_RETURN:
|
||||
case this.chromeWin.KeyEvent.DOM_VK_ESCAPE:
|
||||
if (this.inspecting) {
|
||||
this.stopInspecting();
|
||||
event.preventDefault();
|
||||
@ -1006,7 +1035,7 @@ var InspectorUI = {
|
||||
{
|
||||
let node = aDocument.elementFromPoint(aX, aY);
|
||||
if (node && node.contentDocument) {
|
||||
if (node instanceof HTMLIFrameElement) {
|
||||
if (node instanceof Ci.nsIDOMHTMLIFrameElement) {
|
||||
let rect = node.getBoundingClientRect();
|
||||
|
||||
// Gap between the iframe and its content window.
|
||||
@ -1020,8 +1049,8 @@ var InspectorUI = {
|
||||
return node;
|
||||
}
|
||||
}
|
||||
if (node instanceof HTMLIFrameElement ||
|
||||
node instanceof HTMLFrameElement) {
|
||||
if (node instanceof Ci.nsIDOMHTMLIFrameElement ||
|
||||
node instanceof Ci.nsIDOMHTMLFrameElement) {
|
||||
let subnode = this.elementFromPoint(node.contentDocument, aX, aY);
|
||||
if (subnode) {
|
||||
node = subnode;
|
||||
@ -1155,8 +1184,8 @@ var InspectorUI = {
|
||||
|
||||
this.tools[aRegObj.id] = aRegObj;
|
||||
|
||||
let buttonContainer = document.getElementById("inspector-tools");
|
||||
let btn = document.createElement("toolbarbutton");
|
||||
let buttonContainer = this.chromeDoc.getElementById("inspector-tools");
|
||||
let btn = this.chromeDoc.createElement("toolbarbutton");
|
||||
let buttonId = this.getToolbarButtonId(aRegObj.id);
|
||||
btn.setAttribute("id", buttonId);
|
||||
btn.setAttribute("label", aRegObj.label);
|
||||
@ -1166,15 +1195,14 @@ var InspectorUI = {
|
||||
buttonContainer.appendChild(btn);
|
||||
|
||||
/**
|
||||
* Save the registered tool's toolbar button's click handler so we can remove
|
||||
* it at deregistration time.
|
||||
* @param aButton XUL:toolbarbutton
|
||||
* Save a registered tool's callback for a specified event.
|
||||
* @param aWidget xul:widget
|
||||
* @param aEvent a DOM event name
|
||||
* @param aCallback Function the click event handler for the button
|
||||
*/
|
||||
function bindToolEvent(aWidget, aEvent, aCallback)
|
||||
{
|
||||
let toolEvent = aWidget.id + "_" + aEvent;
|
||||
InspectorUI.toolEvents[toolEvent] = aCallback;
|
||||
let toolEvents = this.toolEvents;
|
||||
function bindToolEvent(aWidget, aEvent, aCallback) {
|
||||
toolEvents[aWidget.id + "_" + aEvent] = aCallback;
|
||||
aWidget.addEventListener(aEvent, aCallback, false);
|
||||
}
|
||||
|
||||
@ -1202,7 +1230,7 @@ var InspectorUI = {
|
||||
toolShow: function IUI_toolShow(aTool)
|
||||
{
|
||||
aTool.show.call(aTool.context, this.selection);
|
||||
document.getElementById(this.getToolbarButtonId(aTool.id)).checked = true;
|
||||
this.chromeDoc.getElementById(this.getToolbarButtonId(aTool.id)).checked = true;
|
||||
},
|
||||
|
||||
/**
|
||||
@ -1212,7 +1240,7 @@ var InspectorUI = {
|
||||
toolHide: function IUI_toolHide(aTool)
|
||||
{
|
||||
aTool.hide.call(aTool.context);
|
||||
document.getElementById(this.getToolbarButtonId(aTool.id)).checked = false;
|
||||
this.chromeDoc.getElementById(this.getToolbarButtonId(aTool.id)).checked = false;
|
||||
},
|
||||
|
||||
/**
|
||||
@ -1223,24 +1251,21 @@ var InspectorUI = {
|
||||
*/
|
||||
unregisterTool: function IUI_unregisterTool(aRegObj)
|
||||
{
|
||||
let button = document.getElementById(this.getToolbarButtonId(aRegObj.id));
|
||||
let button = this.chromeDoc.getElementById(this.getToolbarButtonId(aRegObj.id));
|
||||
|
||||
/**
|
||||
* Unregister the click handler for the registered tool's button.
|
||||
* @param aButton XUL:toolbarbutton
|
||||
* Unregister the events associated with the registered tool's widget.
|
||||
* @param aWidget XUL:widget (toolbarbutton|panel).
|
||||
* @param aEvent a DOM event.
|
||||
*/
|
||||
function unbindToolEvent(aWidget, aEvent)
|
||||
{
|
||||
let toolEvents = this.toolEvents;
|
||||
function unbindToolEvent(aWidget, aEvent) {
|
||||
let toolEvent = aWidget.id + "_" + aEvent;
|
||||
if (!InspectorUI.toolEvents[toolEvent]) {
|
||||
return;
|
||||
}
|
||||
aWidget.removeEventListener(aEvent, toolEvents[toolEvent], false);
|
||||
delete toolEvents[toolEvent]
|
||||
};
|
||||
|
||||
aWidget.removeEventListener(aEvent, InspectorUI.toolEvents[toolEvent], false);
|
||||
delete InspectorUI.toolEvents[toolEvent]
|
||||
}
|
||||
|
||||
let buttonContainer = document.getElementById("inspector-tools");
|
||||
let buttonContainer = this.chromeDoc.getElementById("inspector-tools");
|
||||
unbindToolEvent(button, "click");
|
||||
|
||||
if (aRegObj.panel)
|
||||
@ -1267,7 +1292,7 @@ var InspectorUI = {
|
||||
openTools[aTool.id] = true;
|
||||
}
|
||||
});
|
||||
InspectorStore.setValue(aWinID, "openTools", openTools);
|
||||
this.store.setValue(aWinID, "openTools", openTools);
|
||||
},
|
||||
|
||||
/**
|
||||
@ -1278,7 +1303,7 @@ var InspectorUI = {
|
||||
*/
|
||||
restoreToolState: function IUI_restoreToolState(aWinID)
|
||||
{
|
||||
let openTools = InspectorStore.getValue(aWinID, "openTools");
|
||||
let openTools = this.store.getValue(aWinID, "openTools");
|
||||
if (openTools) {
|
||||
this.toolsDo(function IUI_toolsOnShow(aTool) {
|
||||
if (aTool.id in openTools) {
|
||||
@ -1296,9 +1321,10 @@ var InspectorUI = {
|
||||
*/
|
||||
toolsSelect: function IUI_toolsSelect(aScroll)
|
||||
{
|
||||
let selection = this.selection;
|
||||
this.toolsDo(function IUI_toolsOnSelect(aTool) {
|
||||
if (aTool.isOpen) {
|
||||
aTool.onSelect.call(aTool.context, InspectorUI.selection, aScroll);
|
||||
aTool.onSelect.call(aTool.context, selection, aScroll);
|
||||
}
|
||||
});
|
||||
},
|
||||
@ -1335,13 +1361,33 @@ var InspectorUI = {
|
||||
{
|
||||
return aId in this.tools;
|
||||
},
|
||||
|
||||
/**
|
||||
* Destroy the InspectorUI instance. This is called by the InspectorUI API
|
||||
* "user", see BrowserShutdown() in browser.js.
|
||||
*/
|
||||
destroy: function IUI_destroy()
|
||||
{
|
||||
if (this.isInspectorOpen) {
|
||||
this.closeInspectorUI();
|
||||
}
|
||||
|
||||
delete this.store;
|
||||
delete this.chromeDoc;
|
||||
delete this.chromeWin;
|
||||
delete this.tabbrowser;
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* The Inspector store is used for storing data specific to each tab window.
|
||||
* @constructor
|
||||
*/
|
||||
var InspectorStore = {
|
||||
store: {},
|
||||
function InspectorStore()
|
||||
{
|
||||
this.store = {};
|
||||
}
|
||||
InspectorStore.prototype = {
|
||||
length: 0,
|
||||
|
||||
/**
|
||||
@ -1470,14 +1516,24 @@ var InspectorStore = {
|
||||
* changes to the web page and he tries to navigate away, he is prompted to
|
||||
* confirm page navigation, such that he's given the chance to prevent the loss
|
||||
* of edits.
|
||||
*
|
||||
* @constructor
|
||||
* @param object aInspector
|
||||
* InspectorUI instance object.
|
||||
*/
|
||||
var InspectorProgressListener = {
|
||||
function InspectorProgressListener(aInspector)
|
||||
{
|
||||
this.IUI = aInspector;
|
||||
this.IUI.tabbrowser.addProgressListener(this);
|
||||
}
|
||||
|
||||
InspectorProgressListener.prototype = {
|
||||
onStateChange:
|
||||
function IPL_onStateChange(aProgress, aRequest, aFlag, aStatus)
|
||||
{
|
||||
// Remove myself if the Inspector is no longer open.
|
||||
if (!InspectorUI.isInspectorOpen) {
|
||||
gBrowser.removeProgressListener(InspectorProgressListener);
|
||||
if (!this.IUI.isInspectorOpen) {
|
||||
this.destroy();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1488,14 +1544,14 @@ var InspectorProgressListener = {
|
||||
|
||||
// If the request is about to happen in a new window, we are not concerned
|
||||
// about the request.
|
||||
if (aProgress.DOMWindow != InspectorUI.win) {
|
||||
if (aProgress.DOMWindow != this.IUI.win) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (InspectorUI.isDirty) {
|
||||
if (this.IUI.isDirty) {
|
||||
this.showNotification(aRequest);
|
||||
} else {
|
||||
InspectorUI.closeInspectorUI();
|
||||
this.IUI.closeInspectorUI();
|
||||
}
|
||||
},
|
||||
|
||||
@ -1511,7 +1567,7 @@ var InspectorProgressListener = {
|
||||
{
|
||||
aRequest.suspend();
|
||||
|
||||
let notificationBox = gBrowser.getNotificationBox(InspectorUI.browser);
|
||||
let notificationBox = this.IUI.tabbrowser.getNotificationBox(this.IUI.browser);
|
||||
let notification = notificationBox.
|
||||
getNotificationWithValue("inspector-page-navigation");
|
||||
|
||||
@ -1536,29 +1592,29 @@ var InspectorProgressListener = {
|
||||
let buttons = [
|
||||
{
|
||||
id: "inspector.confirmNavigationAway.buttonLeave",
|
||||
label: InspectorUI.strings.
|
||||
label: this.IUI.strings.
|
||||
GetStringFromName("confirmNavigationAway.buttonLeave"),
|
||||
accessKey: InspectorUI.strings.
|
||||
accessKey: this.IUI.strings.
|
||||
GetStringFromName("confirmNavigationAway.buttonLeaveAccesskey"),
|
||||
callback: function onButtonLeave() {
|
||||
if (aRequest) {
|
||||
aRequest.resume();
|
||||
aRequest = null;
|
||||
InspectorUI.closeInspectorUI();
|
||||
this.IUI.closeInspectorUI();
|
||||
}
|
||||
},
|
||||
}.bind(this),
|
||||
},
|
||||
{
|
||||
id: "inspector.confirmNavigationAway.buttonStay",
|
||||
label: InspectorUI.strings.
|
||||
label: this.IUI.strings.
|
||||
GetStringFromName("confirmNavigationAway.buttonStay"),
|
||||
accessKey: InspectorUI.strings.
|
||||
accessKey: this.IUI.strings.
|
||||
GetStringFromName("confirmNavigationAway.buttonStayAccesskey"),
|
||||
callback: cancelRequest
|
||||
},
|
||||
];
|
||||
|
||||
let message = InspectorUI.strings.
|
||||
let message = this.IUI.strings.
|
||||
GetStringFromName("confirmNavigationAway.message");
|
||||
|
||||
notification = notificationBox.appendNotification(message,
|
||||
@ -1569,25 +1625,36 @@ var InspectorProgressListener = {
|
||||
// transient notification removal.
|
||||
notification.persistence = -1;
|
||||
},
|
||||
|
||||
/**
|
||||
* Destroy the progress listener instance.
|
||||
*/
|
||||
destroy: function IPL_destroy()
|
||||
{
|
||||
this.IUI.tabbrowser.removeProgressListener(this);
|
||||
|
||||
let notificationBox = this.IUI.tabbrowser.getNotificationBox(this.IUI.browser);
|
||||
let notification = notificationBox.
|
||||
getNotificationWithValue("inspector-page-navigation");
|
||||
|
||||
if (notification) {
|
||||
notificationBox.removeNotification(notification, true);
|
||||
}
|
||||
|
||||
delete this.IUI;
|
||||
},
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//// Initializers
|
||||
|
||||
XPCOMUtils.defineLazyGetter(InspectorUI, "inspectMenuitem", function () {
|
||||
return document.getElementById("Tools:Inspect");
|
||||
});
|
||||
XPCOMUtils.defineLazyGetter(InspectorUI.prototype, "strings",
|
||||
function () {
|
||||
return Services.strings.
|
||||
createBundle("chrome://browser/locale/inspector.properties");
|
||||
});
|
||||
|
||||
XPCOMUtils.defineLazyGetter(InspectorUI, "inspectToolbutton", function () {
|
||||
return document.getElementById("inspector-inspect-toolbutton");
|
||||
});
|
||||
|
||||
XPCOMUtils.defineLazyGetter(InspectorUI, "strings", function () {
|
||||
return Services.strings.
|
||||
createBundle("chrome://browser/locale/inspector.properties");
|
||||
});
|
||||
|
||||
XPCOMUtils.defineLazyGetter(InspectorUI, "StyleInspector", function () {
|
||||
XPCOMUtils.defineLazyGetter(this, "StyleInspector", function () {
|
||||
var obj = {};
|
||||
Cu.import("resource:///modules/devtools/StyleInspector.jsm", obj);
|
||||
return obj.StyleInspector;
|
@ -61,6 +61,7 @@ _BROWSER_FILES = \
|
||||
browser_inspector_bug_566084_location_changed.js \
|
||||
$(NULL)
|
||||
|
||||
# Disabled due to constant failures
|
||||
# browser_inspector_treePanel_click.js \
|
||||
|
||||
libs:: $(_BROWSER_FILES)
|
||||
|
@ -5,12 +5,12 @@ let notificationBox = null;
|
||||
|
||||
function startLocationTests() {
|
||||
ok(window.InspectorUI, "InspectorUI variable exists");
|
||||
Services.obs.addObserver(runInspectorTests, INSPECTOR_NOTIFICATIONS.OPENED, null);
|
||||
Services.obs.addObserver(runInspectorTests, InspectorUI.INSPECTOR_NOTIFICATIONS.OPENED, null);
|
||||
InspectorUI.toggleInspectorUI();
|
||||
}
|
||||
|
||||
function runInspectorTests() {
|
||||
Services.obs.removeObserver(runInspectorTests, INSPECTOR_NOTIFICATIONS.OPENED, null);
|
||||
Services.obs.removeObserver(runInspectorTests, InspectorUI.INSPECTOR_NOTIFICATIONS.OPENED, null);
|
||||
|
||||
let para = content.document.querySelector("p");
|
||||
ok(para, "found the paragraph element");
|
||||
|
@ -23,18 +23,18 @@ function test()
|
||||
objectNode = doc.querySelector("object");
|
||||
ok(objectNode, "we have the object node");
|
||||
Services.obs.addObserver(runObjectInspectionTest,
|
||||
INSPECTOR_NOTIFICATIONS.OPENED, false);
|
||||
InspectorUI.INSPECTOR_NOTIFICATIONS.OPENED, false);
|
||||
InspectorUI.toggleInspectorUI();
|
||||
}
|
||||
|
||||
function runObjectInspectionTest()
|
||||
{
|
||||
Services.obs.removeObserver(runObjectInspectionTest,
|
||||
INSPECTOR_NOTIFICATIONS.OPENED);
|
||||
InspectorUI.INSPECTOR_NOTIFICATIONS.OPENED);
|
||||
|
||||
executeSoon(function() {
|
||||
Services.obs.addObserver(performTestComparison,
|
||||
INSPECTOR_NOTIFICATIONS.HIGHLIGHTING, false);
|
||||
InspectorUI.INSPECTOR_NOTIFICATIONS.HIGHLIGHTING, false);
|
||||
|
||||
InspectorUI.inspectNode(objectNode);
|
||||
});
|
||||
@ -43,18 +43,18 @@ function test()
|
||||
function performTestComparison()
|
||||
{
|
||||
Services.obs.removeObserver(performTestComparison,
|
||||
INSPECTOR_NOTIFICATIONS.HIGHLIGHTING);
|
||||
InspectorUI.INSPECTOR_NOTIFICATIONS.HIGHLIGHTING);
|
||||
|
||||
is(InspectorUI.selection, objectNode, "selection matches node");
|
||||
|
||||
Services.obs.addObserver(finishUp,
|
||||
INSPECTOR_NOTIFICATIONS.CLOSED, false);
|
||||
InspectorUI.INSPECTOR_NOTIFICATIONS.CLOSED, false);
|
||||
InspectorUI.closeInspectorUI();
|
||||
}
|
||||
|
||||
|
||||
function finishUp() {
|
||||
Services.obs.removeObserver(finishUp, INSPECTOR_NOTIFICATIONS.CLOSED);
|
||||
Services.obs.removeObserver(finishUp, InspectorUI.INSPECTOR_NOTIFICATIONS.CLOSED);
|
||||
doc = objectNode = null;
|
||||
gBrowser.removeCurrentTab();
|
||||
finish();
|
||||
|
@ -47,18 +47,18 @@ function test()
|
||||
ok(iframeNode, "we have the iframe node");
|
||||
ok(iframeBodyNode, "we have the body node");
|
||||
Services.obs.addObserver(runTests,
|
||||
INSPECTOR_NOTIFICATIONS.OPENED, false);
|
||||
InspectorUI.INSPECTOR_NOTIFICATIONS.OPENED, false);
|
||||
InspectorUI.toggleInspectorUI();
|
||||
}
|
||||
|
||||
function runTests()
|
||||
{
|
||||
Services.obs.removeObserver(runTests,
|
||||
INSPECTOR_NOTIFICATIONS.OPENED);
|
||||
InspectorUI.INSPECTOR_NOTIFICATIONS.OPENED);
|
||||
|
||||
executeSoon(function() {
|
||||
Services.obs.addObserver(isTheIframeSelected,
|
||||
INSPECTOR_NOTIFICATIONS.HIGHLIGHTING, false);
|
||||
InspectorUI.INSPECTOR_NOTIFICATIONS.HIGHLIGHTING, false);
|
||||
|
||||
moveMouseOver(iframeNode, 1, 1);
|
||||
});
|
||||
@ -67,7 +67,7 @@ function test()
|
||||
function isTheIframeSelected()
|
||||
{
|
||||
Services.obs.removeObserver(isTheIframeSelected,
|
||||
INSPECTOR_NOTIFICATIONS.HIGHLIGHTING);
|
||||
InspectorUI.INSPECTOR_NOTIFICATIONS.HIGHLIGHTING);
|
||||
|
||||
is(InspectorUI.selection, iframeNode, "selection matches node");
|
||||
iframeNode.style.marginBottom = doc.defaultView.innerHeight + "px";
|
||||
@ -75,7 +75,7 @@ function test()
|
||||
|
||||
executeSoon(function() {
|
||||
Services.obs.addObserver(isTheIframeContentSelected,
|
||||
INSPECTOR_NOTIFICATIONS.HIGHLIGHTING, false);
|
||||
InspectorUI.INSPECTOR_NOTIFICATIONS.HIGHLIGHTING, false);
|
||||
|
||||
moveMouseOver(iframeNode, 40, 40);
|
||||
});
|
||||
@ -84,7 +84,7 @@ function test()
|
||||
function isTheIframeContentSelected()
|
||||
{
|
||||
Services.obs.removeObserver(isTheIframeContentSelected,
|
||||
INSPECTOR_NOTIFICATIONS.HIGHLIGHTING);
|
||||
InspectorUI.INSPECTOR_NOTIFICATIONS.HIGHLIGHTING);
|
||||
|
||||
is(InspectorUI.selection, iframeBodyNode, "selection matches node");
|
||||
// 184 == 200 + 11(border) + 13(padding) - 40(scroll)
|
||||
@ -92,12 +92,12 @@ function test()
|
||||
"highlighter height");
|
||||
|
||||
Services.obs.addObserver(finishUp,
|
||||
INSPECTOR_NOTIFICATIONS.CLOSED, false);
|
||||
InspectorUI.INSPECTOR_NOTIFICATIONS.CLOSED, false);
|
||||
InspectorUI.closeInspectorUI();
|
||||
}
|
||||
|
||||
function finishUp() {
|
||||
Services.obs.removeObserver(finishUp, INSPECTOR_NOTIFICATIONS.CLOSED);
|
||||
Services.obs.removeObserver(finishUp, InspectorUI.INSPECTOR_NOTIFICATIONS.CLOSED);
|
||||
doc = iframeNode = iframeBodyNode = null;
|
||||
gBrowser.removeCurrentTab();
|
||||
finish();
|
||||
|
@ -26,29 +26,29 @@ function setupEditorTests()
|
||||
div.setAttribute("class", "barbaz");
|
||||
doc.body.appendChild(div);
|
||||
|
||||
Services.obs.addObserver(setupHTMLPanel, INSPECTOR_NOTIFICATIONS.OPENED, false);
|
||||
Services.obs.addObserver(setupHTMLPanel, InspectorUI.INSPECTOR_NOTIFICATIONS.OPENED, false);
|
||||
InspectorUI.toggleInspectorUI();
|
||||
}
|
||||
|
||||
function setupHTMLPanel()
|
||||
{
|
||||
Services.obs.removeObserver(setupHTMLPanel, INSPECTOR_NOTIFICATIONS.OPENED);
|
||||
Services.obs.addObserver(runEditorTests, INSPECTOR_NOTIFICATIONS.TREEPANELREADY, false);
|
||||
Services.obs.removeObserver(setupHTMLPanel, InspectorUI.INSPECTOR_NOTIFICATIONS.OPENED);
|
||||
Services.obs.addObserver(runEditorTests, InspectorUI.INSPECTOR_NOTIFICATIONS.TREEPANELREADY, false);
|
||||
InspectorUI.treePanel.open();
|
||||
}
|
||||
|
||||
function runEditorTests()
|
||||
{
|
||||
Services.obs.removeObserver(runEditorTests, INSPECTOR_NOTIFICATIONS.TREEPANELREADY);
|
||||
Services.obs.removeObserver(runEditorTests, InspectorUI.INSPECTOR_NOTIFICATIONS.TREEPANELREADY);
|
||||
InspectorUI.stopInspecting();
|
||||
|
||||
// setup generator for async test steps
|
||||
editorTestSteps = doEditorTestSteps();
|
||||
|
||||
// add step listeners
|
||||
Services.obs.addObserver(doNextStep, INSPECTOR_NOTIFICATIONS.EDITOR_OPENED, false);
|
||||
Services.obs.addObserver(doNextStep, INSPECTOR_NOTIFICATIONS.EDITOR_CLOSED, false);
|
||||
Services.obs.addObserver(doNextStep, INSPECTOR_NOTIFICATIONS.EDITOR_SAVED, false);
|
||||
Services.obs.addObserver(doNextStep, InspectorUI.INSPECTOR_NOTIFICATIONS.EDITOR_OPENED, false);
|
||||
Services.obs.addObserver(doNextStep, InspectorUI.INSPECTOR_NOTIFICATIONS.EDITOR_CLOSED, false);
|
||||
Services.obs.addObserver(doNextStep, InspectorUI.INSPECTOR_NOTIFICATIONS.EDITOR_SAVED, false);
|
||||
|
||||
// start the tests
|
||||
doNextStep();
|
||||
@ -212,9 +212,9 @@ function doEditorTestSteps()
|
||||
// End of Step 8
|
||||
|
||||
// end of all steps, so clean up
|
||||
Services.obs.removeObserver(doNextStep, INSPECTOR_NOTIFICATIONS.EDITOR_OPENED, false);
|
||||
Services.obs.removeObserver(doNextStep, INSPECTOR_NOTIFICATIONS.EDITOR_CLOSED, false);
|
||||
Services.obs.removeObserver(doNextStep, INSPECTOR_NOTIFICATIONS.EDITOR_SAVED, false);
|
||||
Services.obs.removeObserver(doNextStep, InspectorUI.INSPECTOR_NOTIFICATIONS.EDITOR_OPENED, false);
|
||||
Services.obs.removeObserver(doNextStep, InspectorUI.INSPECTOR_NOTIFICATIONS.EDITOR_CLOSED, false);
|
||||
Services.obs.removeObserver(doNextStep, InspectorUI.INSPECTOR_NOTIFICATIONS.EDITOR_SAVED, false);
|
||||
|
||||
executeSoon(finishUp);
|
||||
}
|
||||
|
@ -80,18 +80,18 @@ function setupHighlighterTests()
|
||||
h1 = doc.querySelectorAll("h1")[0];
|
||||
ok(h1, "we have the header node");
|
||||
Services.obs.addObserver(runSelectionTests,
|
||||
INSPECTOR_NOTIFICATIONS.OPENED, false);
|
||||
InspectorUI.INSPECTOR_NOTIFICATIONS.OPENED, false);
|
||||
InspectorUI.toggleInspectorUI();
|
||||
}
|
||||
|
||||
function runSelectionTests()
|
||||
{
|
||||
Services.obs.removeObserver(runSelectionTests,
|
||||
INSPECTOR_NOTIFICATIONS.OPENED, false);
|
||||
InspectorUI.INSPECTOR_NOTIFICATIONS.OPENED, false);
|
||||
|
||||
executeSoon(function() {
|
||||
Services.obs.addObserver(performTestComparisons,
|
||||
INSPECTOR_NOTIFICATIONS.HIGHLIGHTING, false);
|
||||
InspectorUI.INSPECTOR_NOTIFICATIONS.HIGHLIGHTING, false);
|
||||
EventUtils.synthesizeMouse(h1, 2, 2, {type: "mousemove"}, content);
|
||||
});
|
||||
}
|
||||
@ -99,7 +99,7 @@ function runSelectionTests()
|
||||
function performTestComparisons(evt)
|
||||
{
|
||||
Services.obs.removeObserver(performTestComparisons,
|
||||
INSPECTOR_NOTIFICATIONS.HIGHLIGHTING, false);
|
||||
InspectorUI.INSPECTOR_NOTIFICATIONS.HIGHLIGHTING, false);
|
||||
|
||||
InspectorUI.stopInspecting();
|
||||
ok(InspectorUI.highlighter.isHighlighting, "highlighter is highlighting");
|
||||
|
@ -86,17 +86,17 @@ function moveMouseOver(aElement)
|
||||
function setupIframeTests()
|
||||
{
|
||||
Services.obs.addObserver(runIframeTests,
|
||||
INSPECTOR_NOTIFICATIONS.OPENED, false);
|
||||
InspectorUI.INSPECTOR_NOTIFICATIONS.OPENED, false);
|
||||
InspectorUI.openInspectorUI();
|
||||
}
|
||||
|
||||
function runIframeTests()
|
||||
{
|
||||
Services.obs.removeObserver(runIframeTests,
|
||||
INSPECTOR_NOTIFICATIONS.OPENED, false);
|
||||
InspectorUI.INSPECTOR_NOTIFICATIONS.OPENED, false);
|
||||
|
||||
Services.obs.addObserver(performTestComparisons1,
|
||||
INSPECTOR_NOTIFICATIONS.HIGHLIGHTING, false);
|
||||
InspectorUI.INSPECTOR_NOTIFICATIONS.HIGHLIGHTING, false);
|
||||
|
||||
executeSoon(moveMouseOver.bind(this, div1));
|
||||
}
|
||||
@ -104,9 +104,9 @@ function runIframeTests()
|
||||
function performTestComparisons1()
|
||||
{
|
||||
Services.obs.removeObserver(performTestComparisons1,
|
||||
INSPECTOR_NOTIFICATIONS.HIGHLIGHTING, false);
|
||||
InspectorUI.INSPECTOR_NOTIFICATIONS.HIGHLIGHTING, false);
|
||||
Services.obs.addObserver(performTestComparisons2,
|
||||
INSPECTOR_NOTIFICATIONS.HIGHLIGHTING, false);
|
||||
InspectorUI.INSPECTOR_NOTIFICATIONS.HIGHLIGHTING, false);
|
||||
|
||||
is(InspectorUI.selection, div1, "selection matches div1 node");
|
||||
is(InspectorUI.highlighter.highlitNode, div1, "highlighter matches selection");
|
||||
@ -117,7 +117,7 @@ function performTestComparisons1()
|
||||
function performTestComparisons2()
|
||||
{
|
||||
Services.obs.removeObserver(performTestComparisons2,
|
||||
INSPECTOR_NOTIFICATIONS.HIGHLIGHTING, false);
|
||||
InspectorUI.INSPECTOR_NOTIFICATIONS.HIGHLIGHTING, false);
|
||||
|
||||
is(InspectorUI.selection, div2, "selection matches div2 node");
|
||||
is(InspectorUI.highlighter.highlitNode, div2, "highlighter matches selection");
|
||||
|
@ -61,16 +61,16 @@ function startInspectorTests()
|
||||
{
|
||||
ok(InspectorUI, "InspectorUI variable exists");
|
||||
Services.obs.addObserver(runInspectorTests,
|
||||
INSPECTOR_NOTIFICATIONS.OPENED, false);
|
||||
InspectorUI.INSPECTOR_NOTIFICATIONS.OPENED, false);
|
||||
InspectorUI.toggleInspectorUI();
|
||||
}
|
||||
|
||||
function runInspectorTests()
|
||||
{
|
||||
Services.obs.removeObserver(runInspectorTests,
|
||||
INSPECTOR_NOTIFICATIONS.OPENED);
|
||||
InspectorUI.INSPECTOR_NOTIFICATIONS.OPENED);
|
||||
Services.obs.addObserver(treePanelTests,
|
||||
INSPECTOR_NOTIFICATIONS.TREEPANELREADY, false);
|
||||
InspectorUI.INSPECTOR_NOTIFICATIONS.TREEPANELREADY, false);
|
||||
|
||||
ok(InspectorUI.toolbar, "we have the toolbar.");
|
||||
ok(!InspectorUI.toolbar.hidden, "toolbar is visible");
|
||||
@ -84,9 +84,9 @@ function runInspectorTests()
|
||||
function treePanelTests()
|
||||
{
|
||||
Services.obs.removeObserver(treePanelTests,
|
||||
INSPECTOR_NOTIFICATIONS.TREEPANELREADY);
|
||||
InspectorUI.INSPECTOR_NOTIFICATIONS.TREEPANELREADY);
|
||||
Services.obs.addObserver(runContextMenuTest,
|
||||
INSPECTOR_NOTIFICATIONS.CLOSED, false);
|
||||
InspectorUI.INSPECTOR_NOTIFICATIONS.CLOSED, false);
|
||||
|
||||
ok(InspectorUI.treePanel.isOpen(), "Inspector Tree Panel is open");
|
||||
|
||||
@ -97,8 +97,8 @@ function treePanelTests()
|
||||
|
||||
function runContextMenuTest()
|
||||
{
|
||||
Services.obs.removeObserver(runContextMenuTest, INSPECTOR_NOTIFICATIONS.CLOSED, false);
|
||||
Services.obs.addObserver(inspectNodesFromContextTest, INSPECTOR_NOTIFICATIONS.OPENED, false);
|
||||
Services.obs.removeObserver(runContextMenuTest, InspectorUI.INSPECTOR_NOTIFICATIONS.CLOSED, false);
|
||||
Services.obs.addObserver(inspectNodesFromContextTest, InspectorUI.INSPECTOR_NOTIFICATIONS.OPENED, false);
|
||||
salutation = doc.getElementById("salutation");
|
||||
ok(salutation, "hello, context menu test!");
|
||||
let eventDeets = { type : "contextmenu", button : 2 };
|
||||
@ -108,7 +108,7 @@ function runContextMenuTest()
|
||||
ok(contextInspectMenuItem, "we have the inspect context menu item");
|
||||
EventUtils.synthesizeMouse(salutation, 2, 2, eventDeets);
|
||||
is(contextMenu.state, "showing", "context menu is open");
|
||||
is(contextInspectMenuItem.hidden, !InspectorUI.enabled, "is context menu item enabled?");
|
||||
is(!contextInspectMenuItem.hidden, gPrefService.getBoolPref("devtools.inspector.enabled"), "is context menu item enabled?");
|
||||
contextMenu.hidePopup();
|
||||
executeSoon(function() {
|
||||
InspectorUI.openInspectorUI(salutation);
|
||||
@ -117,8 +117,8 @@ function runContextMenuTest()
|
||||
|
||||
function inspectNodesFromContextTest()
|
||||
{
|
||||
Services.obs.removeObserver(inspectNodesFromContextTest, INSPECTOR_NOTIFICATIONS.OPENED, false);
|
||||
Services.obs.addObserver(openInspectorForContextTest, INSPECTOR_NOTIFICATIONS.CLOSED, false);
|
||||
Services.obs.removeObserver(inspectNodesFromContextTest, InspectorUI.INSPECTOR_NOTIFICATIONS.OPENED, false);
|
||||
Services.obs.addObserver(openInspectorForContextTest, InspectorUI.INSPECTOR_NOTIFICATIONS.CLOSED, false);
|
||||
ok(!InspectorUI.inspecting, "Inspector is not actively highlighting");
|
||||
is(InspectorUI.selection, salutation, "Inspector is highlighting salutation");
|
||||
ok(!InspectorUI.isTreePanelOpen, "Inspector Tree Panel is closed");
|
||||
@ -131,8 +131,8 @@ function inspectNodesFromContextTest()
|
||||
|
||||
function openInspectorForContextTest()
|
||||
{
|
||||
Services.obs.removeObserver(openInspectorForContextTest, INSPECTOR_NOTIFICATIONS.CLOSED);
|
||||
Services.obs.addObserver(inspectNodesFromContextTestWhileOpen, INSPECTOR_NOTIFICATIONS.OPENED, false);
|
||||
Services.obs.removeObserver(openInspectorForContextTest, InspectorUI.INSPECTOR_NOTIFICATIONS.CLOSED);
|
||||
Services.obs.addObserver(inspectNodesFromContextTestWhileOpen, InspectorUI.INSPECTOR_NOTIFICATIONS.OPENED, false);
|
||||
executeSoon(function() {
|
||||
InspectorUI.openInspectorUI(salutation);
|
||||
});
|
||||
@ -140,9 +140,9 @@ function openInspectorForContextTest()
|
||||
|
||||
function inspectNodesFromContextTestWhileOpen()
|
||||
{
|
||||
Services.obs.removeObserver(inspectNodesFromContextTestWhileOpen, INSPECTOR_NOTIFICATIONS.OPENED);
|
||||
Services.obs.addObserver(inspectNodesFromContextTestTrap, INSPECTOR_NOTIFICATIONS.OPENED, false);
|
||||
Services.obs.addObserver(inspectNodesFromContextTestHighlight, INSPECTOR_NOTIFICATIONS.HIGHLIGHTING, false);
|
||||
Services.obs.removeObserver(inspectNodesFromContextTestWhileOpen, InspectorUI.INSPECTOR_NOTIFICATIONS.OPENED);
|
||||
Services.obs.addObserver(inspectNodesFromContextTestTrap, InspectorUI.INSPECTOR_NOTIFICATIONS.OPENED, false);
|
||||
Services.obs.addObserver(inspectNodesFromContextTestHighlight, InspectorUI.INSPECTOR_NOTIFICATIONS.HIGHLIGHTING, false);
|
||||
is(InspectorUI.selection, salutation, "Inspector is highlighting salutation");
|
||||
closing = doc.getElementById("closing");
|
||||
ok(closing, "we have the closing statement");
|
||||
@ -153,8 +153,8 @@ function inspectNodesFromContextTestWhileOpen()
|
||||
|
||||
function inspectNodesFromContextTestHighlight()
|
||||
{
|
||||
Services.obs.removeObserver(inspectNodesFromContextTestHighlight, INSPECTOR_NOTIFICATIONS.HIGHLIGHTING);
|
||||
Services.obs.addObserver(finishInspectorTests, INSPECTOR_NOTIFICATIONS.CLOSED, false);
|
||||
Services.obs.removeObserver(inspectNodesFromContextTestHighlight, InspectorUI.INSPECTOR_NOTIFICATIONS.HIGHLIGHTING);
|
||||
Services.obs.addObserver(finishInspectorTests, InspectorUI.INSPECTOR_NOTIFICATIONS.CLOSED, false);
|
||||
is(InspectorUI.selection, closing, "InspectorUI.selection is header");
|
||||
executeSoon(function() {
|
||||
InspectorUI.closeInspectorUI(true);
|
||||
@ -163,14 +163,14 @@ function inspectNodesFromContextTestHighlight()
|
||||
|
||||
function inspectNodesFromContextTestTrap()
|
||||
{
|
||||
Services.obs.removeObserver(inspectNodesFromContextTestTrap, INSPECTOR_NOTIFICATIONS.OPENED);
|
||||
Services.obs.removeObserver(inspectNodesFromContextTestTrap, InspectorUI.INSPECTOR_NOTIFICATIONS.OPENED);
|
||||
ok(false, "Inspector UI has been opened again. We Should Not Be Here!");
|
||||
}
|
||||
|
||||
function finishInspectorTests()
|
||||
{
|
||||
Services.obs.removeObserver(finishInspectorTests,
|
||||
INSPECTOR_NOTIFICATIONS.CLOSED);
|
||||
InspectorUI.INSPECTOR_NOTIFICATIONS.CLOSED);
|
||||
|
||||
ok(!InspectorUI.highlighter, "Highlighter is gone");
|
||||
ok(!InspectorUI.treePanel, "Inspector Tree Panel is closed");
|
||||
|
@ -84,7 +84,7 @@ function createDocument()
|
||||
function setupHighlighterTests()
|
||||
{
|
||||
ok(h1, "we have the header node");
|
||||
Services.obs.addObserver(inspectorOpen, INSPECTOR_NOTIFICATIONS.OPENED, false);
|
||||
Services.obs.addObserver(inspectorOpen, InspectorUI.INSPECTOR_NOTIFICATIONS.OPENED, false);
|
||||
registerTools();
|
||||
InspectorUI.toggleInspectorUI();
|
||||
}
|
||||
@ -92,17 +92,17 @@ function setupHighlighterTests()
|
||||
function inspectorOpen()
|
||||
{
|
||||
info("we received the inspector-opened notification");
|
||||
Services.obs.removeObserver(inspectorOpen, INSPECTOR_NOTIFICATIONS.OPENED);
|
||||
Services.obs.removeObserver(inspectorOpen, InspectorUI.INSPECTOR_NOTIFICATIONS.OPENED);
|
||||
toolsLength = InspectorUI.tools.length;
|
||||
toolEvents = InspectorUI.toolEvents.length;
|
||||
info("tools registered");
|
||||
Services.obs.addObserver(startToolTests, INSPECTOR_NOTIFICATIONS.HIGHLIGHTING, false);
|
||||
Services.obs.addObserver(startToolTests, InspectorUI.INSPECTOR_NOTIFICATIONS.HIGHLIGHTING, false);
|
||||
InspectorUI.inspectNode(h1);
|
||||
}
|
||||
|
||||
function startToolTests(evt)
|
||||
{
|
||||
Services.obs.removeObserver(startToolTests, INSPECTOR_NOTIFICATIONS.HIGHLIGHTING);
|
||||
Services.obs.removeObserver(startToolTests, InspectorUI.INSPECTOR_NOTIFICATIONS.HIGHLIGHTING);
|
||||
InspectorUI.stopInspecting();
|
||||
info("Getting InspectorUI.tools");
|
||||
let tools = InspectorUI.tools;
|
||||
@ -168,13 +168,13 @@ function testSecondTab()
|
||||
ok(!(tool3 in tools), "Panel 3 not in tools");
|
||||
|
||||
info("Closing current tab");
|
||||
Services.obs.addObserver(testOriginalTab, INSPECTOR_NOTIFICATIONS.OPENED, false);
|
||||
Services.obs.addObserver(testOriginalTab, InspectorUI.INSPECTOR_NOTIFICATIONS.OPENED, false);
|
||||
gBrowser.removeCurrentTab();
|
||||
}
|
||||
|
||||
function testOriginalTab()
|
||||
{
|
||||
Services.obs.removeObserver(testOriginalTab, INSPECTOR_NOTIFICATIONS.OPENED);
|
||||
Services.obs.removeObserver(testOriginalTab, InspectorUI.INSPECTOR_NOTIFICATIONS.OPENED);
|
||||
info("Checking panel states 6");
|
||||
|
||||
info("Tools: " + InspectorUI.tools);
|
||||
@ -187,13 +187,13 @@ function testOriginalTab()
|
||||
ok(!tool2.isOpen, "Panel 2 is closed after reactivation");
|
||||
ok(tool3.isOpen, "Panel 3 is open after reactivation");
|
||||
|
||||
Services.obs.addObserver(unregisterTools, INSPECTOR_NOTIFICATIONS.CLOSED, false);
|
||||
Services.obs.addObserver(unregisterTools, InspectorUI.INSPECTOR_NOTIFICATIONS.CLOSED, false);
|
||||
InspectorUI.closeInspectorUI(true);
|
||||
}
|
||||
|
||||
function unregisterTools()
|
||||
{
|
||||
Services.obs.removeObserver(unregisterTools, INSPECTOR_NOTIFICATIONS.CLOSED);
|
||||
Services.obs.removeObserver(unregisterTools, InspectorUI.INSPECTOR_NOTIFICATIONS.CLOSED);
|
||||
let tools = InspectorUI.tools;
|
||||
|
||||
ok(!(tool1 in tools), "Tool 1 removed");
|
||||
|
@ -65,16 +65,16 @@ function createDocument()
|
||||
|
||||
function toggleInspector()
|
||||
{
|
||||
Services.obs.addObserver(inspectNode, INSPECTOR_NOTIFICATIONS.OPENED, false);
|
||||
Services.obs.addObserver(inspectNode, InspectorUI.INSPECTOR_NOTIFICATIONS.OPENED, false);
|
||||
InspectorUI.toggleInspectorUI();
|
||||
}
|
||||
|
||||
function inspectNode()
|
||||
{
|
||||
Services.obs.removeObserver(inspectNode,
|
||||
INSPECTOR_NOTIFICATIONS.OPENED, false);
|
||||
InspectorUI.INSPECTOR_NOTIFICATIONS.OPENED, false);
|
||||
Services.obs.addObserver(performScrollingTest,
|
||||
INSPECTOR_NOTIFICATIONS.HIGHLIGHTING, false);
|
||||
InspectorUI.INSPECTOR_NOTIFICATIONS.HIGHLIGHTING, false);
|
||||
|
||||
executeSoon(function() {
|
||||
InspectorUI.inspectNode(div);
|
||||
@ -84,7 +84,7 @@ function inspectNode()
|
||||
function performScrollingTest()
|
||||
{
|
||||
Services.obs.removeObserver(performScrollingTest,
|
||||
INSPECTOR_NOTIFICATIONS.HIGHLIGHTING, false);
|
||||
InspectorUI.INSPECTOR_NOTIFICATIONS.HIGHLIGHTING, false);
|
||||
|
||||
EventUtils.synthesizeMouseScroll(div, 10, 10,
|
||||
{axis:"vertical", delta:50, type:"MozMousePixelScroll"},
|
||||
|
@ -39,8 +39,8 @@
|
||||
|
||||
function test()
|
||||
{
|
||||
ok(window.InspectorUI, "InspectorUI variable exists");
|
||||
ok(!InspectorUI.inspecting, "Inspector is not highlighting");
|
||||
let InspectorStore = InspectorUI.store;
|
||||
|
||||
is(InspectorStore.length, 0, "InspectorStore is empty");
|
||||
ok(InspectorStore.isEmpty(), "InspectorStore is empty (confirmed)");
|
||||
is(typeof InspectorStore.store, "object",
|
||||
|
@ -47,23 +47,23 @@ function inspectorTabOpen1()
|
||||
{
|
||||
ok(window.InspectorUI, "InspectorUI variable exists");
|
||||
ok(!InspectorUI.inspecting, "Inspector is not highlighting");
|
||||
ok(InspectorStore.isEmpty(), "InspectorStore is empty");
|
||||
ok(InspectorUI.store.isEmpty(), "Inspector.store is empty");
|
||||
|
||||
Services.obs.addObserver(inspectorUIOpen1,
|
||||
INSPECTOR_NOTIFICATIONS.OPENED, false);
|
||||
InspectorUI.INSPECTOR_NOTIFICATIONS.OPENED, false);
|
||||
InspectorUI.openInspectorUI();
|
||||
}
|
||||
|
||||
function inspectorUIOpen1()
|
||||
{
|
||||
Services.obs.removeObserver(inspectorUIOpen1,
|
||||
INSPECTOR_NOTIFICATIONS.OPENED, false);
|
||||
InspectorUI.INSPECTOR_NOTIFICATIONS.OPENED, false);
|
||||
|
||||
// Make sure the inspector is open.
|
||||
ok(InspectorUI.inspecting, "Inspector is highlighting");
|
||||
ok(!InspectorUI.treePanel.isOpen(), "Inspector Tree Panel is not open");
|
||||
ok(!InspectorStore.isEmpty(), "InspectorStore is not empty");
|
||||
is(InspectorStore.length, 1, "InspectorStore.length = 1");
|
||||
ok(!InspectorUI.store.isEmpty(), "InspectorUI.store is not empty");
|
||||
is(InspectorUI.store.length, 1, "Inspector.store.length = 1");
|
||||
|
||||
// Highlight a node.
|
||||
div = content.document.getElementsByTagName("div")[0];
|
||||
@ -88,12 +88,12 @@ function inspectorTabOpen2()
|
||||
// Make sure the inspector is closed.
|
||||
ok(!InspectorUI.inspecting, "Inspector is not highlighting");
|
||||
ok(!InspectorUI.treePanel, "Inspector Tree Panel is closed");
|
||||
is(InspectorStore.length, 1, "InspectorStore.length = 1");
|
||||
is(InspectorUI.store.length, 1, "Inspector.store.length = 1");
|
||||
|
||||
// Activate the inspector again.
|
||||
executeSoon(function() {
|
||||
Services.obs.addObserver(inspectorUIOpen2,
|
||||
INSPECTOR_NOTIFICATIONS.OPENED, false);
|
||||
InspectorUI.INSPECTOR_NOTIFICATIONS.OPENED, false);
|
||||
InspectorUI.openInspectorUI();
|
||||
});
|
||||
}
|
||||
@ -101,12 +101,12 @@ function inspectorTabOpen2()
|
||||
function inspectorUIOpen2()
|
||||
{
|
||||
Services.obs.removeObserver(inspectorUIOpen2,
|
||||
INSPECTOR_NOTIFICATIONS.OPENED, false);
|
||||
InspectorUI.INSPECTOR_NOTIFICATIONS.OPENED, false);
|
||||
|
||||
// Make sure the inspector is open.
|
||||
ok(InspectorUI.inspecting, "Inspector is highlighting");
|
||||
ok(!InspectorUI.treePanel.isOpen(), "Inspector Tree Panel is not open");
|
||||
is(InspectorStore.length, 2, "InspectorStore.length = 2");
|
||||
is(InspectorUI.store.length, 2, "Inspector.store.length = 2");
|
||||
|
||||
// Disable highlighting.
|
||||
InspectorUI.toggleInspection();
|
||||
@ -115,7 +115,7 @@ function inspectorUIOpen2()
|
||||
// Switch back to tab 1.
|
||||
executeSoon(function() {
|
||||
Services.obs.addObserver(inspectorFocusTab1,
|
||||
INSPECTOR_NOTIFICATIONS.OPENED, false);
|
||||
InspectorUI.INSPECTOR_NOTIFICATIONS.OPENED, false);
|
||||
gBrowser.selectedTab = tab1;
|
||||
});
|
||||
}
|
||||
@ -123,16 +123,16 @@ function inspectorUIOpen2()
|
||||
function inspectorFocusTab1()
|
||||
{
|
||||
Services.obs.removeObserver(inspectorFocusTab1,
|
||||
INSPECTOR_NOTIFICATIONS.OPENED, false);
|
||||
InspectorUI.INSPECTOR_NOTIFICATIONS.OPENED, false);
|
||||
|
||||
// Make sure the inspector is still open.
|
||||
ok(InspectorUI.inspecting, "Inspector is highlighting");
|
||||
ok(!InspectorUI.treePanel.isOpen(), "Inspector Tree Panel is not open");
|
||||
is(InspectorStore.length, 2, "InspectorStore.length = 2");
|
||||
is(InspectorUI.store.length, 2, "Inspector.store.length = 2");
|
||||
is(InspectorUI.selection, div, "selection matches the div element");
|
||||
|
||||
Services.obs.addObserver(inspectorOpenTreePanelTab1,
|
||||
INSPECTOR_NOTIFICATIONS.TREEPANELREADY, false);
|
||||
InspectorUI.INSPECTOR_NOTIFICATIONS.TREEPANELREADY, false);
|
||||
|
||||
InspectorUI.treePanel.open();
|
||||
}
|
||||
@ -140,61 +140,61 @@ function inspectorFocusTab1()
|
||||
function inspectorOpenTreePanelTab1()
|
||||
{
|
||||
Services.obs.removeObserver(inspectorOpenTreePanelTab1,
|
||||
INSPECTOR_NOTIFICATIONS.TREEPANELREADY);
|
||||
InspectorUI.INSPECTOR_NOTIFICATIONS.TREEPANELREADY);
|
||||
|
||||
ok(InspectorUI.inspecting, "Inspector is highlighting");
|
||||
ok(InspectorUI.treePanel.isOpen(), "Inspector Tree Panel is open");
|
||||
is(InspectorStore.length, 2, "InspectorStore.length = 2");
|
||||
is(InspectorUI.store.length, 2, "Inspector.store.length = 2");
|
||||
is(InspectorUI.selection, div, "selection matches the div element");
|
||||
|
||||
// Switch back to tab 2.
|
||||
Services.obs.addObserver(inspectorFocusTab2,
|
||||
INSPECTOR_NOTIFICATIONS.OPENED, false);
|
||||
InspectorUI.INSPECTOR_NOTIFICATIONS.OPENED, false);
|
||||
gBrowser.selectedTab = tab2;
|
||||
}
|
||||
|
||||
function inspectorFocusTab2()
|
||||
{
|
||||
Services.obs.removeObserver(inspectorFocusTab2,
|
||||
INSPECTOR_NOTIFICATIONS.OPENED, false);
|
||||
InspectorUI.INSPECTOR_NOTIFICATIONS.OPENED, false);
|
||||
|
||||
// Make sure the inspector is still open.
|
||||
ok(!InspectorUI.inspecting, "Inspector is not highlighting");
|
||||
ok(!InspectorUI.treePanel.isOpen(), "Inspector Tree Panel is not open");
|
||||
is(InspectorStore.length, 2, "InspectorStore.length = 2");
|
||||
is(InspectorUI.store.length, 2, "Inspector.store.length is 2");
|
||||
isnot(InspectorUI.selection, div, "selection does not match the div element");
|
||||
|
||||
// Switch back to tab 1.
|
||||
Services.obs.addObserver(inspectorSecondFocusTab1,
|
||||
INSPECTOR_NOTIFICATIONS.TREEPANELREADY, false);
|
||||
InspectorUI.INSPECTOR_NOTIFICATIONS.TREEPANELREADY, false);
|
||||
gBrowser.selectedTab = tab1;
|
||||
}
|
||||
|
||||
function inspectorSecondFocusTab1()
|
||||
{
|
||||
Services.obs.removeObserver(inspectorSecondFocusTab1,
|
||||
INSPECTOR_NOTIFICATIONS.TREEPANELREADY);
|
||||
InspectorUI.INSPECTOR_NOTIFICATIONS.TREEPANELREADY);
|
||||
|
||||
ok(InspectorUI.inspecting, "Inspector is highlighting");
|
||||
ok(InspectorUI.treePanel.isOpen(), "Inspector Tree Panel is open");
|
||||
is(InspectorStore.length, 2, "InspectorStore.length = 2");
|
||||
is(InspectorUI.store.length, 2, "Inspector.store.length = 2");
|
||||
is(InspectorUI.selection, div, "selection matches the div element");
|
||||
|
||||
// Switch back to tab 2.
|
||||
Services.obs.addObserver(inspectorSecondFocusTab2,
|
||||
INSPECTOR_NOTIFICATIONS.OPENED, false);
|
||||
InspectorUI.INSPECTOR_NOTIFICATIONS.OPENED, false);
|
||||
gBrowser.selectedTab = tab2;
|
||||
}
|
||||
|
||||
function inspectorSecondFocusTab2()
|
||||
{
|
||||
Services.obs.removeObserver(inspectorSecondFocusTab2,
|
||||
INSPECTOR_NOTIFICATIONS.OPENED);
|
||||
InspectorUI.INSPECTOR_NOTIFICATIONS.OPENED);
|
||||
|
||||
// Make sure the inspector is still open.
|
||||
ok(!InspectorUI.inspecting, "Inspector is not highlighting");
|
||||
ok(!InspectorUI.treePanel.isOpen(), "Inspector Tree Panel is not open");
|
||||
is(InspectorStore.length, 2, "InspectorStore.length = 2");
|
||||
is(InspectorUI.store.length, 2, "Inspector.store.length is 2");
|
||||
isnot(InspectorUI.selection, div, "selection does not match the div element");
|
||||
|
||||
// Remove tab 1.
|
||||
@ -211,7 +211,7 @@ function inspectorTabUnload1(evt)
|
||||
// Make sure the Inspector is still open and that the state is correct.
|
||||
ok(!InspectorUI.inspecting, "Inspector is not highlighting");
|
||||
ok(!InspectorUI.treePanel.isOpen(), "Inspector Tree Panel is not open");
|
||||
is(InspectorStore.length, 1, "InspectorStore.length = 1");
|
||||
is(InspectorUI.store.length, 1, "Inspector.store.length = 1");
|
||||
|
||||
InspectorUI.closeInspectorUI();
|
||||
gBrowser.removeCurrentTab();
|
||||
|
@ -22,20 +22,20 @@ function test() {
|
||||
function setupTest() {
|
||||
node1 = doc.querySelector("div");
|
||||
node2 = doc.querySelector("p");
|
||||
Services.obs.addObserver(runTests, INSPECTOR_NOTIFICATIONS.OPENED, false);
|
||||
Services.obs.addObserver(runTests, InspectorUI.INSPECTOR_NOTIFICATIONS.OPENED, false);
|
||||
InspectorUI.toggleInspectorUI();
|
||||
}
|
||||
|
||||
function runTests() {
|
||||
Services.obs.removeObserver(runTests, INSPECTOR_NOTIFICATIONS.OPENED);
|
||||
Services.obs.addObserver(testNode1, INSPECTOR_NOTIFICATIONS.TREEPANELREADY, false);
|
||||
Services.obs.removeObserver(runTests, InspectorUI.INSPECTOR_NOTIFICATIONS.OPENED);
|
||||
Services.obs.addObserver(testNode1, InspectorUI.INSPECTOR_NOTIFICATIONS.TREEPANELREADY, false);
|
||||
InspectorUI.select(node1, true, true, true);
|
||||
InspectorUI.openTreePanel();
|
||||
}
|
||||
|
||||
function testNode1() {
|
||||
dump("testNode1\n");
|
||||
Services.obs.removeObserver(testNode1, INSPECTOR_NOTIFICATIONS.TREEPANELREADY);
|
||||
Services.obs.removeObserver(testNode1, InspectorUI.INSPECTOR_NOTIFICATIONS.TREEPANELREADY);
|
||||
is(InspectorUI.selection, node1, "selection matches node");
|
||||
is(InspectorUI.highlighter.node, node1, "selection matches node");
|
||||
testNode2();
|
||||
@ -43,21 +43,21 @@ function test() {
|
||||
|
||||
function testNode2() {
|
||||
dump("testNode2\n")
|
||||
Services.obs.addObserver(testHighlightingNode2, INSPECTOR_NOTIFICATIONS.HIGHLIGHTING, false);
|
||||
Services.obs.addObserver(testHighlightingNode2, InspectorUI.INSPECTOR_NOTIFICATIONS.HIGHLIGHTING, false);
|
||||
InspectorUI.treePanelSelect("node2");
|
||||
}
|
||||
|
||||
function testHighlightingNode2() {
|
||||
dump("testHighlightingNode2\n")
|
||||
Services.obs.removeObserver(testHighlightingNode2, INSPECTOR_NOTIFICATIONS.HIGHLIGHTING);
|
||||
Services.obs.removeObserver(testHighlightingNode2, InspectorUI.INSPECTOR_NOTIFICATIONS.HIGHLIGHTING);
|
||||
is(InspectorUI.selection, node2, "selection matches node");
|
||||
is(InspectorUI.highlighter.node, node2, "selection matches node");
|
||||
Services.obs.addObserver(finishUp, INSPECTOR_NOTIFICATIONS.CLOSED, false);
|
||||
Services.obs.addObserver(finishUp, InspectorUI.INSPECTOR_NOTIFICATIONS.CLOSED, false);
|
||||
InspectorUI.closeInspectorUI();
|
||||
}
|
||||
|
||||
function finishUp() {
|
||||
Services.obs.removeObserver(finishUp, INSPECTOR_NOTIFICATIONS.CLOSED);
|
||||
Services.obs.removeObserver(finishUp, InspectorUI.INSPECTOR_NOTIFICATIONS.CLOSED);
|
||||
doc = node1 = node2 = null;
|
||||
gBrowser.removeCurrentTab();
|
||||
finish();
|
||||
|
@ -64,23 +64,23 @@ function xhr_onReadyStateChange() {
|
||||
xhr = null;
|
||||
|
||||
Services.obs.addObserver(inspectorOpened,
|
||||
INSPECTOR_NOTIFICATIONS.OPENED, false);
|
||||
InspectorUI.INSPECTOR_NOTIFICATIONS.OPENED, false);
|
||||
InspectorUI.openInspectorUI();
|
||||
}
|
||||
|
||||
function inspectorOpened()
|
||||
{
|
||||
Services.obs.removeObserver(inspectorOpened,
|
||||
INSPECTOR_NOTIFICATIONS.OPENED);
|
||||
InspectorUI.INSPECTOR_NOTIFICATIONS.OPENED);
|
||||
|
||||
Services.obs.addObserver(treePanelOpened, INSPECTOR_NOTIFICATIONS.TREEPANELREADY, false);
|
||||
Services.obs.addObserver(treePanelOpened, InspectorUI.INSPECTOR_NOTIFICATIONS.TREEPANELREADY, false);
|
||||
InspectorUI.treePanel.open();
|
||||
}
|
||||
|
||||
function treePanelOpened()
|
||||
{
|
||||
Services.obs.removeObserver(treePanelOpened,
|
||||
INSPECTOR_NOTIFICATIONS.TREEPANELREADY);
|
||||
InspectorUI.INSPECTOR_NOTIFICATIONS.TREEPANELREADY);
|
||||
|
||||
ok(InspectorUI.inspecting, "Inspector is highlighting");
|
||||
ok(InspectorUI.treePanel.isOpen(), "Inspector Tree Panel is open");
|
||||
@ -106,14 +106,14 @@ function treePanelOpened()
|
||||
expectedResult = null;
|
||||
|
||||
Services.obs.addObserver(inspectorClosed,
|
||||
INSPECTOR_NOTIFICATIONS.CLOSED, false);
|
||||
InspectorUI.INSPECTOR_NOTIFICATIONS.CLOSED, false);
|
||||
InspectorUI.closeInspectorUI();
|
||||
}
|
||||
|
||||
function inspectorClosed()
|
||||
{
|
||||
Services.obs.removeObserver(inspectorClosed,
|
||||
INSPECTOR_NOTIFICATIONS.CLOSED, false);
|
||||
InspectorUI.INSPECTOR_NOTIFICATIONS.CLOSED, false);
|
||||
|
||||
ok(!InspectorUI.inspecting, "Inspector is not highlighting");
|
||||
ok(!InspectorUI.treePanel, "Inspector Tree Panel is not open");
|
||||
|
@ -68,16 +68,16 @@ function setupSelectionTests()
|
||||
h1 = doc.querySelectorAll("h1")[0];
|
||||
ok(h1, "we have the header node");
|
||||
Services.obs.addObserver(runSelectionTests,
|
||||
INSPECTOR_NOTIFICATIONS.OPENED, false);
|
||||
InspectorUI.INSPECTOR_NOTIFICATIONS.OPENED, false);
|
||||
InspectorUI.openInspectorUI();
|
||||
}
|
||||
|
||||
function runSelectionTests()
|
||||
{
|
||||
Services.obs.removeObserver(runSelectionTests,
|
||||
INSPECTOR_NOTIFICATIONS.OPENED, false);
|
||||
InspectorUI.INSPECTOR_NOTIFICATIONS.OPENED, false);
|
||||
Services.obs.addObserver(performTestComparisons,
|
||||
INSPECTOR_NOTIFICATIONS.HIGHLIGHTING, false);
|
||||
InspectorUI.INSPECTOR_NOTIFICATIONS.HIGHLIGHTING, false);
|
||||
executeSoon(function() {
|
||||
InspectorUI.inspectNode(h1);
|
||||
});
|
||||
@ -86,7 +86,7 @@ function runSelectionTests()
|
||||
function performTestComparisons(evt)
|
||||
{
|
||||
Services.obs.removeObserver(performTestComparisons,
|
||||
INSPECTOR_NOTIFICATIONS.HIGHLIGHTING, false);
|
||||
InspectorUI.INSPECTOR_NOTIFICATIONS.HIGHLIGHTING, false);
|
||||
|
||||
is(h1, InspectorUI.selection, "selection matches node");
|
||||
ok(InspectorUI.highlighter.isHighlighting, "highlighter is highlighting");
|
||||
|
@ -82,18 +82,18 @@ function setupHighlighterTests()
|
||||
h1 = doc.querySelectorAll("h1")[0];
|
||||
ok(h1, "we have the header node");
|
||||
Services.obs.addObserver(runSelectionTests,
|
||||
INSPECTOR_NOTIFICATIONS.OPENED, false);
|
||||
InspectorUI.INSPECTOR_NOTIFICATIONS.OPENED, false);
|
||||
InspectorUI.toggleInspectorUI();
|
||||
}
|
||||
|
||||
function runSelectionTests()
|
||||
{
|
||||
Services.obs.removeObserver(runSelectionTests,
|
||||
INSPECTOR_NOTIFICATIONS.OPENED, false);
|
||||
InspectorUI.INSPECTOR_NOTIFICATIONS.OPENED, false);
|
||||
|
||||
executeSoon(function() {
|
||||
Services.obs.addObserver(performTestComparisons,
|
||||
INSPECTOR_NOTIFICATIONS.HIGHLIGHTING, false);
|
||||
InspectorUI.INSPECTOR_NOTIFICATIONS.HIGHLIGHTING, false);
|
||||
EventUtils.synthesizeMouse(h1, 2, 2, {type: "mousemove"}, content);
|
||||
});
|
||||
}
|
||||
@ -101,7 +101,7 @@ function runSelectionTests()
|
||||
function performTestComparisons(evt)
|
||||
{
|
||||
Services.obs.removeObserver(performTestComparisons,
|
||||
INSPECTOR_NOTIFICATIONS.HIGHLIGHTING, false);
|
||||
InspectorUI.INSPECTOR_NOTIFICATIONS.HIGHLIGHTING, false);
|
||||
|
||||
InspectorUI.stopInspecting();
|
||||
ok(InspectorUI.highlighter.isHighlighting, "highlighter is highlighting");
|
||||
|
@ -10,8 +10,8 @@ confirmNavigationAway.buttonStayAccesskey=S
|
||||
# LOCALIZATION NOTE (htmlPanel): Used in the Inspector tool's openInspectorUI
|
||||
# method when registering the HTML panel.
|
||||
|
||||
# LOCALIZATION NOTE (htmlPanel.label): A button label that appears on the
|
||||
# InspectorUI's toolbar.
|
||||
# LOCALIZATION NOTE (htmlPanel.label): This is a lable for a button that
|
||||
# activates the Web Developer->Inspect UI's HTML Tree Panel.
|
||||
htmlPanel.label=HTML
|
||||
|
||||
# LOCALIZATION NOTE (htmlPanel.tooltiptext): The text that appears when a user
|
||||
|
Loading…
Reference in New Issue
Block a user