*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
@@ -78,35 +79,40 @@ function setupHighlighterTests()
{
h1 = doc.querySelectorAll("h1")[0];
ok(h1, "we have the header node");
- Services.obs.addObserver(runSelectionTests, "inspector-opened", false);
+ Services.obs.addObserver(runSelectionTests,
+ INSPECTOR_NOTIFICATIONS.OPENED, false);
InspectorUI.toggleInspectorUI();
}
function runSelectionTests()
{
- Services.obs.removeObserver(runSelectionTests, "inspector-opened", false);
- document.addEventListener("popupshown", performTestComparisons, false);
- EventUtils.synthesizeMouse(h1, 2, 2, {type: "mousemove"}, content);
+ Services.obs.removeObserver(runSelectionTests,
+ INSPECTOR_NOTIFICATIONS.OPENED, false);
+
+ executeSoon(function() {
+ Services.obs.addObserver(performTestComparisons,
+ INSPECTOR_NOTIFICATIONS.HIGHLIGHTING, false);
+ EventUtils.synthesizeMouse(h1, 2, 2, {type: "mousemove"}, content);
+ });
}
function performTestComparisons(evt)
{
- if (evt.target.id != "highlighter-panel")
- return true;
- document.removeEventListener("popupshown", performTestComparisons, false);
- is(h1, InspectorUI.selection, "selection matches node");
- ok(InspectorUI.highlighter.isHighlighting, "panel is highlighting");
- is(InspectorUI.highlighter.highlitNode, h1, "highlighter matches selection");
+ Services.obs.removeObserver(performTestComparisons,
+ INSPECTOR_NOTIFICATIONS.HIGHLIGHTING, false);
- Services.obs.addObserver(finishUp, "inspector-closed", false);
- InspectorUI.closeInspectorUI();
+ InspectorUI.stopInspecting();
+ ok(InspectorUI.highlighter.isHighlighting, "highlighter is highlighting");
+ is(InspectorUI.highlighter.highlitNode, h1, "highlighter matches selection")
+ is(InspectorUI.selection, h1, "selection matches node");
+ is(InspectorUI.selection, InspectorUI.highlighter.highlitNode, "selection matches highlighter");
+
+ doc = h1 = null;
+ executeSoon(finishUp);
}
function finishUp() {
- Services.obs.removeObserver(finishUp, "inspector-closed", false);
-
- ok(!InspectorUI.highlighter, "panel is not highlighting");
- doc = h1 = null;
+ InspectorUI.closeInspectorUI();
gBrowser.removeCurrentTab();
finish();
}
@@ -120,7 +126,7 @@ function test()
doc = content.document;
waitForFocus(createDocument, content);
}, true);
-
+
content.location = "data:text/html,basic tests for inspector";
}
diff --git a/browser/base/content/test/browser_inspector_iframeTest.js b/browser/base/content/test/inspector/browser_inspector_iframeTest.js
similarity index 77%
rename from browser/base/content/test/browser_inspector_iframeTest.js
rename to browser/base/content/test/inspector/browser_inspector_iframeTest.js
index 3ff84f853c5d..01df7fedeeda 100644
--- a/browser/base/content/test/browser_inspector_iframeTest.js
+++ b/browser/base/content/test/inspector/browser_inspector_iframeTest.js
@@ -43,6 +43,7 @@ let div1;
let div2;
let iframe1;
let iframe2;
+let highlighterFrame;
function createDocument()
{
@@ -77,53 +78,59 @@ function createDocument()
doc.body.appendChild(iframe1);
}
+function moveMouseOver(aElement)
+{
+ EventUtils.synthesizeMouse(aElement, 2, 2, {type: "mousemove"},
+ aElement.ownerDocument.defaultView);
+}
+
function setupIframeTests()
{
- Services.obs.addObserver(runIframeTests, "inspector-opened", false);
+ Services.obs.addObserver(runIframeTests,
+ INSPECTOR_NOTIFICATIONS.OPENED, false);
InspectorUI.openInspectorUI();
}
function runIframeTests()
{
- Services.obs.removeObserver(runIframeTests, "inspector-opened", false);
- document.addEventListener("popupshown", performTestComparisons1, false);
- EventUtils.synthesizeMouse(div1, 2, 2, {type: "mousemove"},
- iframe1.contentWindow);
+ Services.obs.removeObserver(runIframeTests,
+ INSPECTOR_NOTIFICATIONS.OPENED, false);
+
+ Services.obs.addObserver(performTestComparisons1,
+ INSPECTOR_NOTIFICATIONS.HIGHLIGHTING, false);
+
+ highlighterFrame = InspectorUI.highlighter.iframe;
+ executeSoon(moveMouseOver.bind(this, div1));
}
-function performTestComparisons1(evt)
+function performTestComparisons1()
{
- if (evt.target.id != "highlighter-panel") {
- return true;
- }
-
- document.removeEventListener(evt.type, arguments.callee, false);
+ Services.obs.removeObserver(performTestComparisons1,
+ INSPECTOR_NOTIFICATIONS.HIGHLIGHTING, false);
+ Services.obs.addObserver(performTestComparisons2,
+ INSPECTOR_NOTIFICATIONS.HIGHLIGHTING, false);
is(InspectorUI.selection, div1, "selection matches div1 node");
is(InspectorUI.highlighter.highlitNode, div1, "highlighter matches selection");
- document.addEventListener("popupshown", performTestComparisons2, false);
-
- EventUtils.synthesizeMouse(div2, 2, 2, {type: "mousemove"},
- iframe2.contentWindow);
+ executeSoon(moveMouseOver.bind(this, div2));
}
-function performTestComparisons2(evt)
+function performTestComparisons2()
{
- if (evt.target.id != "highlighter-panel") {
- return true;
- }
-
- document.removeEventListener(evt.type, arguments.callee, false);
+ Services.obs.removeObserver(performTestComparisons2,
+ INSPECTOR_NOTIFICATIONS.HIGHLIGHTING, false);
is(InspectorUI.selection, div2, "selection matches div2 node");
is(InspectorUI.highlighter.highlitNode, div2, "highlighter matches selection");
- executeSoon(finishUp);
+ finishUp();
}
function finishUp() {
- InspectorUI.closeInspectorUI();
+ InspectorUI.closeInspectorUI(true);
+
+ doc = div1 = div2 = iframe1 = iframe2 = highlighterFrame = null;
gBrowser.removeCurrentTab();
finish();
}
diff --git a/browser/base/content/test/browser_inspector_initialization.js b/browser/base/content/test/inspector/browser_inspector_initialization.js
similarity index 80%
rename from browser/base/content/test/browser_inspector_initialization.js
rename to browser/base/content/test/inspector/browser_inspector_initialization.js
index b439c71ccb5a..ad490c5dd12d 100644
--- a/browser/base/content/test/browser_inspector_initialization.js
+++ b/browser/base/content/test/inspector/browser_inspector_initialization.js
@@ -37,31 +37,41 @@
*
* ***** END LICENSE BLOCK ***** */
-let doc;
-
function startInspectorTests()
{
ok(InspectorUI, "InspectorUI variable exists");
- Services.obs.addObserver(runInspectorTests, "inspector-opened", false);
+ Services.obs.addObserver(runInspectorTests,
+ INSPECTOR_NOTIFICATIONS.OPENED, false);
InspectorUI.toggleInspectorUI();
}
function runInspectorTests()
{
- Services.obs.removeObserver(runInspectorTests, "inspector-opened", false);
- Services.obs.addObserver(finishInspectorTests, "inspector-closed", false);
+ Services.obs.removeObserver(runInspectorTests,
+ INSPECTOR_NOTIFICATIONS.OPENED, false);
+ Services.obs.addObserver(finishInspectorTests,
+ INSPECTOR_NOTIFICATIONS.CLOSED, false);
+
let iframe = document.getElementById("inspector-tree-iframe");
is(InspectorUI.treeIFrame, iframe, "Inspector IFrame matches");
- ok(InspectorUI.inspecting, "Inspector is highlighting");
+ ok(InspectorUI.inspecting, "Inspector is inspecting");
ok(InspectorUI.isTreePanelOpen, "Inspector Tree Panel is open");
- InspectorUI.closeInspectorUI();
+ ok(InspectorUI.highlighter, "Highlighter is up");
+
+ executeSoon(function() {
+ InspectorUI.closeInspectorUI();
+ });
}
function finishInspectorTests()
{
- Services.obs.removeObserver(finishInspectorTests, "inspector-closed", false);
+ Services.obs.removeObserver(finishInspectorTests,
+ INSPECTOR_NOTIFICATIONS.CLOSED, false);
+
+ ok(!InspectorUI.highlighter, "Highlighter is gone");
ok(!InspectorUI.isTreePanelOpen, "Inspector Tree Panel is closed");
- ok(!InspectorUI.inspecting, "Inspector is not highlighting");
+ ok(!InspectorUI.inspecting, "Inspector is not inspecting");
+
gBrowser.removeCurrentTab();
finish();
}
@@ -72,10 +82,9 @@ function test()
gBrowser.selectedTab = gBrowser.addTab();
gBrowser.selectedBrowser.addEventListener("load", function() {
gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
- doc = content.document;
waitForFocus(startInspectorTests, content);
}, true);
-
+
content.location = "data:text/html,basic tests for inspector";
}
diff --git a/browser/base/content/test/browser_inspector_scrolling.js b/browser/base/content/test/inspector/browser_inspector_scrolling.js
similarity index 75%
rename from browser/base/content/test/browser_inspector_scrolling.js
rename to browser/base/content/test/inspector/browser_inspector_scrolling.js
index 8bcc60ead766..5f7e67ce8f2c 100644
--- a/browser/base/content/test/browser_inspector_scrolling.js
+++ b/browser/base/content/test/inspector/browser_inspector_scrolling.js
@@ -65,34 +65,42 @@ function createDocument()
function toggleInspector()
{
- Services.obs.addObserver(inspectNode, "inspector-opened", false);
+ Services.obs.addObserver(inspectNode, INSPECTOR_NOTIFICATIONS.OPENED, false);
InspectorUI.toggleInspectorUI();
}
function inspectNode()
{
- Services.obs.removeObserver(inspectNode, "inspector-opened", false);
- document.addEventListener("popupshown", performScrollingTest, false);
+ Services.obs.removeObserver(inspectNode,
+ INSPECTOR_NOTIFICATIONS.OPENED, false);
+ Services.obs.addObserver(performScrollingTest,
+ INSPECTOR_NOTIFICATIONS.HIGHLIGHTING, false);
- InspectorUI.inspectNode(div)
+ executeSoon(function() {
+ InspectorUI.inspectNode(div);
+ });
}
-function performScrollingTest(aEvent)
+function performScrollingTest()
{
- if (aEvent.target.id != "highlighter-panel") {
- return true;
- }
+ Services.obs.removeObserver(performScrollingTest,
+ INSPECTOR_NOTIFICATIONS.HIGHLIGHTING, false);
- document.removeEventListener("popupshown", performScrollingTest, false);
+ EventUtils.synthesizeMouseScroll(div, 10, 10,
+ {axis:"vertical", delta:50, type:"MozMousePixelScroll"},
+ iframe.contentWindow);
- EventUtils.synthesizeMouseScroll(aEvent.target, 10, 10,
- {axis:"vertical", delta:50, type:"MozMousePixelScroll"}, window);
+ gBrowser.selectedBrowser.addEventListener("scroll", function() {
+ gBrowser.selectedBrowser.removeEventListener("scroll", arguments.callee,
+ false);
- is(iframe.contentDocument.body.scrollTop, 50, "inspected iframe scrolled");
+ is(iframe.contentDocument.body.scrollTop, 50, "inspected iframe scrolled");
- InspectorUI.closeInspectorUI();
- gBrowser.removeCurrentTab();
- finish();
+ div = iframe = doc = null;
+ InspectorUI.closeInspectorUI();
+ gBrowser.removeCurrentTab();
+ finish();
+ }, false);
}
function test()
diff --git a/browser/base/content/test/browser_inspector_store.js b/browser/base/content/test/inspector/browser_inspector_store.js
similarity index 98%
rename from browser/base/content/test/browser_inspector_store.js
rename to browser/base/content/test/inspector/browser_inspector_store.js
index 3176280ac479..249962ede716 100644
--- a/browser/base/content/test/browser_inspector_store.js
+++ b/browser/base/content/test/inspector/browser_inspector_store.js
@@ -39,7 +39,7 @@
function test()
{
- ok(InspectorUI, "InspectorUI variable exists");
+ ok(window.InspectorUI, "InspectorUI variable exists");
ok(!InspectorUI.inspecting, "Inspector is not highlighting");
is(InspectorStore.length, 0, "InspectorStore is empty");
ok(InspectorStore.isEmpty(), "InspectorStore is empty (confirmed)");
diff --git a/browser/base/content/test/browser_inspector_tab_switch.js b/browser/base/content/test/inspector/browser_inspector_tab_switch.js
similarity index 87%
rename from browser/base/content/test/browser_inspector_tab_switch.js
rename to browser/base/content/test/inspector/browser_inspector_tab_switch.js
index d9793a9ae8e8..f40d430e5b33 100644
--- a/browser/base/content/test/browser_inspector_tab_switch.js
+++ b/browser/base/content/test/inspector/browser_inspector_tab_switch.js
@@ -45,17 +45,19 @@ let tab1window;
function inspectorTabOpen1()
{
- ok(InspectorUI, "InspectorUI variable exists");
+ ok(window.InspectorUI, "InspectorUI variable exists");
ok(!InspectorUI.inspecting, "Inspector is not highlighting");
ok(InspectorStore.isEmpty(), "InspectorStore is empty");
- Services.obs.addObserver(inspectorUIOpen1, "inspector-opened", false);
+ Services.obs.addObserver(inspectorUIOpen1,
+ INSPECTOR_NOTIFICATIONS.OPENED, false);
InspectorUI.openInspectorUI();
}
function inspectorUIOpen1()
{
- Services.obs.removeObserver(inspectorUIOpen1, "inspector-opened", false);
+ Services.obs.removeObserver(inspectorUIOpen1,
+ INSPECTOR_NOTIFICATIONS.OPENED, false);
// Make sure the inspector is open.
ok(InspectorUI.inspecting, "Inspector is highlighting");
@@ -90,14 +92,16 @@ function inspectorTabOpen2()
// Activate the inspector again.
executeSoon(function() {
- Services.obs.addObserver(inspectorUIOpen2, "inspector-opened", false);
+ Services.obs.addObserver(inspectorUIOpen2,
+ INSPECTOR_NOTIFICATIONS.OPENED, false);
InspectorUI.openInspectorUI();
});
}
function inspectorUIOpen2()
{
- Services.obs.removeObserver(inspectorUIOpen2, "inspector-opened", false);
+ Services.obs.removeObserver(inspectorUIOpen2,
+ INSPECTOR_NOTIFICATIONS.OPENED, false);
// Make sure the inspector is open.
ok(InspectorUI.inspecting, "Inspector is highlighting");
@@ -110,14 +114,16 @@ function inspectorUIOpen2()
// Switch back to tab 1.
executeSoon(function() {
- Services.obs.addObserver(inspectorFocusTab1, "inspector-opened", false);
+ Services.obs.addObserver(inspectorFocusTab1,
+ INSPECTOR_NOTIFICATIONS.OPENED, false);
gBrowser.selectedTab = tab1;
});
}
function inspectorFocusTab1()
{
- Services.obs.removeObserver(inspectorFocusTab1, "inspector-opened", false);
+ Services.obs.removeObserver(inspectorFocusTab1,
+ INSPECTOR_NOTIFICATIONS.OPENED, false);
// Make sure the inspector is still open.
ok(InspectorUI.inspecting, "Inspector is highlighting");
@@ -126,13 +132,15 @@ function inspectorFocusTab1()
is(InspectorUI.selection, div, "selection matches the div element");
// Switch back to tab 2.
- Services.obs.addObserver(inspectorFocusTab2, "inspector-opened", false);
+ Services.obs.addObserver(inspectorFocusTab2,
+ INSPECTOR_NOTIFICATIONS.OPENED, false);
gBrowser.selectedTab = tab2;
}
function inspectorFocusTab2()
{
- Services.obs.removeObserver(inspectorFocusTab2, "inspector-opened", false);
+ Services.obs.removeObserver(inspectorFocusTab2,
+ INSPECTOR_NOTIFICATIONS.OPENED, false);
// Make sure the inspector is still open.
ok(!InspectorUI.inspecting, "Inspector is not highlighting");
diff --git a/browser/base/content/test/browser_inspector_treePanel_input.html b/browser/base/content/test/inspector/browser_inspector_treePanel_input.html
similarity index 96%
rename from browser/base/content/test/browser_inspector_treePanel_input.html
rename to browser/base/content/test/inspector/browser_inspector_treePanel_input.html
index 64b3d367bb39..8724d2030100 100644
--- a/browser/base/content/test/browser_inspector_treePanel_input.html
+++ b/browser/base/content/test/inspector/browser_inspector_treePanel_input.html
@@ -15,17 +15,17 @@
Inspector tree panel test.
-
- test
-