From 5221f1d7199276293070e6974253d1ee09afbf2c Mon Sep 17 00:00:00 2001 From: Ted Mielczarek Date: Tue, 9 Jun 2009 08:56:38 -0400 Subject: [PATCH] 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 --- toolkit/crashreporter/test/Makefile.in | 1 + .../test/browser/browser_bug471404.js | 68 +++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 toolkit/crashreporter/test/browser/browser_bug471404.js diff --git a/toolkit/crashreporter/test/Makefile.in b/toolkit/crashreporter/test/Makefile.in index 1523785ff47c..a17084c0549b 100644 --- a/toolkit/crashreporter/test/Makefile.in +++ b/toolkit/crashreporter/test/Makefile.in @@ -119,6 +119,7 @@ endif _BROWSER_FILES = \ browser/aboutcrashes_utils.js \ browser/browser_aboutCrashes.js \ + browser/browser_bug471404.js \ $(NULL) diff --git a/toolkit/crashreporter/test/browser/browser_bug471404.js b/toolkit/crashreporter/test/browser/browser_bug471404.js new file mode 100644 index 000000000000..89616b5c44b5 --- /dev/null +++ b/toolkit/crashreporter/test/browser/browser_bug471404.js @@ -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); +}