2012-05-10 10:33:54 -07:00
|
|
|
/* Any copyright is dedicated to the Public Domain.
|
|
|
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
|
|
|
|
|
|
// Tests that the developer toolbar works properly
|
|
|
|
|
2012-05-15 03:27:19 -07:00
|
|
|
let imported = {};
|
|
|
|
Components.utils.import("resource:///modules/HUDService.jsm", imported);
|
|
|
|
registerCleanupFunction(function() {
|
|
|
|
imported = {};
|
|
|
|
});
|
|
|
|
|
2012-05-22 00:50:02 -07:00
|
|
|
const TEST_URI = "http://example.com/browser/browser/devtools/shared/test/browser_toolbar_basic.html";
|
2012-05-10 10:33:54 -07:00
|
|
|
|
|
|
|
function test() {
|
2012-05-22 00:50:02 -07:00
|
|
|
addTab(TEST_URI, function(browser, tab) {
|
2012-05-10 10:33:54 -07:00
|
|
|
info("Starting browser_toolbar_basic.js");
|
|
|
|
runTest();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function runTest() {
|
2012-05-15 03:27:19 -07:00
|
|
|
ok(!DeveloperToolbar.visible, "DeveloperToolbar is not visible in runTest");
|
|
|
|
|
|
|
|
oneTimeObserve(DeveloperToolbar.NOTIFICATIONS.SHOW, catchFail(checkOpen));
|
|
|
|
document.getElementById("Tools:DevToolbar").doCommand();
|
2012-05-10 10:33:54 -07:00
|
|
|
}
|
|
|
|
|
2012-05-02 23:09:37 -07:00
|
|
|
function isChecked(b) {
|
|
|
|
return b.getAttribute("checked") == "true";
|
|
|
|
}
|
|
|
|
|
2012-05-10 10:33:54 -07:00
|
|
|
function checkOpen() {
|
2012-05-15 03:27:19 -07:00
|
|
|
ok(DeveloperToolbar.visible, "DeveloperToolbar is visible in checkOpen");
|
|
|
|
|
|
|
|
let close = document.getElementById("developer-toolbar-closebutton");
|
|
|
|
let webconsole = document.getElementById("developer-toolbar-webconsole");
|
|
|
|
let inspector = document.getElementById("developer-toolbar-inspector");
|
2012-06-25 02:37:16 -07:00
|
|
|
let styleeditor = document.getElementById("developer-toolbar-styleeditor");
|
2012-05-15 03:27:19 -07:00
|
|
|
let debuggr = document.getElementById("developer-toolbar-debugger");
|
|
|
|
|
|
|
|
ok(close, "Close button exists");
|
|
|
|
|
2012-05-02 23:09:37 -07:00
|
|
|
ok(!isChecked(webconsole), "web console button state 1");
|
|
|
|
ok(!isChecked(inspector), "inspector button state 1");
|
|
|
|
ok(!isChecked(debuggr), "debugger button state 1");
|
2012-06-25 02:37:16 -07:00
|
|
|
ok(!isChecked(styleeditor), "styleeditor button state 1");
|
2012-05-15 03:27:19 -07:00
|
|
|
|
|
|
|
document.getElementById("Tools:WebConsole").doCommand();
|
|
|
|
|
2012-05-02 23:09:37 -07:00
|
|
|
ok(isChecked(webconsole), "web console button state 2");
|
|
|
|
ok(!isChecked(inspector), "inspector button state 2");
|
|
|
|
ok(!isChecked(debuggr), "debugger button state 2");
|
2012-06-25 02:37:16 -07:00
|
|
|
ok(!isChecked(styleeditor), "styleeditor button state 2");
|
2012-05-15 03:27:19 -07:00
|
|
|
|
|
|
|
document.getElementById("Tools:Inspect").doCommand();
|
|
|
|
|
2012-05-02 23:09:37 -07:00
|
|
|
ok(isChecked(webconsole), "web console button state 3");
|
|
|
|
ok(isChecked(inspector), "inspector button state 3");
|
|
|
|
ok(!isChecked(debuggr), "debugger button state 3");
|
2012-06-25 02:37:16 -07:00
|
|
|
ok(!isChecked(styleeditor), "styleeditor button state 3");
|
2012-05-15 03:27:19 -07:00
|
|
|
|
|
|
|
// Christmas tree!
|
|
|
|
|
|
|
|
// The web console opens synchronously, but closes asynchronously.
|
|
|
|
let hud = imported.HUDService.getHudByWindow(content);
|
|
|
|
imported.HUDService.disableAnimation(hud.hudId);
|
|
|
|
|
|
|
|
document.getElementById("Tools:WebConsole").doCommand();
|
|
|
|
|
2012-05-02 23:09:37 -07:00
|
|
|
ok(!isChecked(webconsole), "web console button state 6");
|
|
|
|
ok(isChecked(inspector), "inspector button state 6");
|
|
|
|
ok(!isChecked(debuggr), "debugger button state 6");
|
2012-06-25 02:37:16 -07:00
|
|
|
ok(!isChecked(styleeditor), "styleeditor button state 6");
|
2012-05-15 03:27:19 -07:00
|
|
|
|
|
|
|
document.getElementById("Tools:Inspect").doCommand();
|
|
|
|
|
2012-05-02 23:09:37 -07:00
|
|
|
ok(!isChecked(webconsole), "web console button state 7");
|
|
|
|
ok(!isChecked(inspector), "inspector button state 7");
|
|
|
|
ok(!isChecked(debuggr), "debugger button state 7");
|
2012-06-25 02:37:16 -07:00
|
|
|
ok(!isChecked(styleeditor), "styleeditor button state 7");
|
2012-05-10 10:33:54 -07:00
|
|
|
|
2012-05-15 03:27:19 -07:00
|
|
|
// All closed
|
|
|
|
|
|
|
|
// Check we can open and close and retain button state
|
|
|
|
document.getElementById("Tools:Inspect").doCommand();
|
|
|
|
|
2012-05-02 23:09:37 -07:00
|
|
|
ok(!isChecked(webconsole), "web console button state 8");
|
|
|
|
ok(isChecked(inspector), "inspector button state 8");
|
|
|
|
ok(!isChecked(debuggr), "debugger button state 8");
|
2012-06-25 02:37:16 -07:00
|
|
|
ok(!isChecked(styleeditor), "styleeditor button state 8");
|
2012-05-15 03:27:19 -07:00
|
|
|
|
2012-06-25 02:37:16 -07:00
|
|
|
|
|
|
|
// Test Style Editor
|
|
|
|
document.getElementById("Tools:StyleEditor").doCommand();
|
|
|
|
|
|
|
|
ok(!isChecked(webconsole), "web console button state 9");
|
|
|
|
ok(isChecked(inspector), "inspector button state 9");
|
|
|
|
ok(!isChecked(debuggr), "debugger button state 9");
|
|
|
|
ok(isChecked(styleeditor), "styleeditor button state 9");
|
|
|
|
|
|
|
|
// Test Debugger
|
|
|
|
document.getElementById("Tools:Debugger").doCommand();
|
|
|
|
|
|
|
|
ok(!isChecked(webconsole), "web console button state 9");
|
|
|
|
ok(isChecked(inspector), "inspector button state 9");
|
|
|
|
ok(isChecked(debuggr), "debugger button state 9");
|
|
|
|
ok(isChecked(styleeditor), "styleeditor button state 9");
|
|
|
|
|
|
|
|
addTab("about:blank", function(browser, tab) {
|
|
|
|
info("Opening a new tab");
|
|
|
|
|
|
|
|
ok(!isChecked(webconsole), "web console button state 10");
|
|
|
|
ok(!isChecked(inspector), "inspector button state 10");
|
|
|
|
ok(!isChecked(debuggr), "debugger button state 10");
|
|
|
|
ok(!isChecked(styleeditor), "styleeditor button state 10");
|
|
|
|
|
|
|
|
gBrowser.removeCurrentTab();
|
|
|
|
|
|
|
|
oneTimeObserve(DeveloperToolbar.NOTIFICATIONS.HIDE, catchFail(checkClosed));
|
|
|
|
document.getElementById("Tools:DevToolbar").doCommand();
|
|
|
|
});
|
2012-05-10 10:33:54 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function checkClosed() {
|
2012-05-15 03:27:19 -07:00
|
|
|
ok(!DeveloperToolbar.visible, "DeveloperToolbar is not visible in checkClosed");
|
|
|
|
|
|
|
|
// Check we grok state even when closed
|
|
|
|
document.getElementById("Tools:WebConsole").doCommand();
|
|
|
|
|
|
|
|
oneTimeObserve(DeveloperToolbar.NOTIFICATIONS.SHOW, catchFail(checkReOpen));
|
|
|
|
document.getElementById("Tools:DevToolbar").doCommand();
|
|
|
|
}
|
|
|
|
|
|
|
|
function checkReOpen() {
|
|
|
|
ok(DeveloperToolbar.visible, "DeveloperToolbar is visible in checkReOpen");
|
|
|
|
|
|
|
|
let webconsole = document.getElementById("developer-toolbar-webconsole");
|
|
|
|
let inspector = document.getElementById("developer-toolbar-inspector");
|
|
|
|
let debuggr = document.getElementById("developer-toolbar-debugger");
|
2012-06-25 02:37:16 -07:00
|
|
|
let styleeditor = document.getElementById("developer-toolbar-styleeditor");
|
2012-05-15 03:27:19 -07:00
|
|
|
|
2012-06-25 02:37:16 -07:00
|
|
|
ok(isChecked(webconsole), "web console button state 99");
|
|
|
|
ok(isChecked(inspector), "inspector button state 99");
|
|
|
|
ok(isChecked(debuggr), "debugger button state 99");
|
|
|
|
ok(isChecked(styleeditor), "styleeditor button state 99");
|
|
|
|
|
|
|
|
// We close the style editor (not automatically closed)
|
|
|
|
document.getElementById("Tools:StyleEditor").doCommand();
|
2012-05-15 03:27:19 -07:00
|
|
|
|
|
|
|
oneTimeObserve(DeveloperToolbar.NOTIFICATIONS.HIDE, catchFail(checkReClosed));
|
|
|
|
document.getElementById("developer-toolbar-closebutton").doCommand();
|
|
|
|
}
|
|
|
|
|
|
|
|
function checkReClosed() {
|
|
|
|
ok(!DeveloperToolbar.visible, "DeveloperToolbar is not visible in checkReClosed");
|
2012-05-10 10:33:54 -07:00
|
|
|
|
|
|
|
finish();
|
|
|
|
}
|
2012-05-15 03:27:19 -07:00
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
function oneTimeObserve(name, callback) {
|
|
|
|
var func = function() {
|
|
|
|
Services.obs.removeObserver(func, name);
|
|
|
|
callback();
|
|
|
|
};
|
|
|
|
Services.obs.addObserver(func, name, false);
|
|
|
|
}
|