bug 471404 - 'Remove All Reports' shouldn't be available if there aren't any reports. add a browser chrome test. r=dao

--HG--
extra : rebase_source : 54804feeeccb07477fc6114f05a1101465f20a7f
This commit is contained in:
Ted Mielczarek 2009-06-09 08:56:38 -04:00
parent e89d86a452
commit 5221f1d719
2 changed files with 69 additions and 0 deletions

View File

@ -119,6 +119,7 @@ endif
_BROWSER_FILES = \
browser/aboutcrashes_utils.js \
browser/browser_aboutCrashes.js \
browser/browser_bug471404.js \
$(NULL)

View File

@ -0,0 +1,68 @@
// load our utility script
var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"]
.getService(Components.interfaces.mozIJSSubScriptLoader);
scriptLoader.loadSubScript("chrome://mochikit/content/browser/toolkit/crashreporter/test/browser/aboutcrashes_utils.js", this);
function check_clear_visible(tab, aVisible) {
let doc = gBrowser.getBrowserForTab(tab).contentDocument;
let visible = false;
let button = doc.getElementById("clear-reports");
if (button) {
let style = doc.defaultView.getComputedStyle(button, "");
if (style.display != "none" &&
style.visibility == "visible")
visible = true;
}
is(visible, aVisible,
"clear reports button is " + (aVisible ? "visible" : "hidden"));
}
// each test here has a setup (run before loading about:crashes) and onload (run after about:crashes loads)
let _tests = [{setup: null, onload: function(tab) { check_clear_visible(tab, false); }},
{setup: function(crD) { add_fake_crashes(crD, 1); },
onload: function(tab) { check_clear_visible(tab, true); }}
];
let _current_test = 0;
function run_test_setup(crD) {
if (_tests[_current_test].setup) {
_tests[_current_test].setup(crD);
}
}
function run_test_onload(tab) {
if (_tests[_current_test].onload) {
_tests[_current_test].onload(tab);
}
_current_test++;
if (_current_test == _tests.length) {
cleanup_fake_appdir();
gBrowser.removeTab(tab);
finish();
return false;
}
return true;
}
function test() {
waitForExplicitFinish();
let appD = make_fake_appdir();
let crD = appD.clone();
crD.append("Crash Reports");
let tab = gBrowser.selectedTab = gBrowser.addTab("about:blank");
let browser = gBrowser.getBrowserForTab(tab);
browser.addEventListener("load", function() {
executeSoon(function() {
if (run_test_onload(tab)) {
// prep and run the next test
run_test_setup(crD);
executeSoon(function() { browser.loadURI("about:crashes", null, null); });
}
});
}, true);
// kick things off
run_test_setup(crD);
browser.loadURI("about:crashes", null, null);
}