michael@0: function check_clear_visible(tab, aVisible) { michael@0: let doc = gBrowser.getBrowserForTab(tab).contentDocument; michael@0: let visible = false; michael@0: let button = doc.getElementById("clear-reports"); michael@0: if (button) { michael@0: let style = doc.defaultView.getComputedStyle(button, ""); michael@0: if (style.display != "none" && michael@0: style.visibility == "visible") michael@0: visible = true; michael@0: } michael@0: is(visible, aVisible, michael@0: "clear reports button is " + (aVisible ? "visible" : "hidden")); michael@0: } michael@0: michael@0: // each test here has a setup (run before loading about:crashes) and onload (run after about:crashes loads) michael@0: let _tests = [{setup: null, onload: function(tab) { check_clear_visible(tab, false); }}, michael@0: {setup: function(crD) { add_fake_crashes(crD, 1); }, michael@0: onload: function(tab) { check_clear_visible(tab, true); }} michael@0: ]; michael@0: let _current_test = 0; michael@0: michael@0: function run_test_setup(crD) { michael@0: if (_tests[_current_test].setup) { michael@0: _tests[_current_test].setup(crD); michael@0: } michael@0: } michael@0: michael@0: function run_test_onload(tab) { michael@0: if (_tests[_current_test].onload) { michael@0: _tests[_current_test].onload(tab); michael@0: } michael@0: _current_test++; michael@0: michael@0: if (_current_test == _tests.length) { michael@0: cleanup_fake_appdir(); michael@0: gBrowser.removeTab(tab); michael@0: finish(); michael@0: return false; michael@0: } michael@0: return true; michael@0: } michael@0: michael@0: function test() { michael@0: waitForExplicitFinish(); michael@0: let appD = make_fake_appdir(); michael@0: let crD = appD.clone(); michael@0: crD.append("Crash Reports"); michael@0: michael@0: let tab = gBrowser.selectedTab = gBrowser.addTab("about:blank"); michael@0: let browser = gBrowser.getBrowserForTab(tab); michael@0: let onLoad = function () { michael@0: executeSoon(function() { michael@0: if (run_test_onload(tab)) { michael@0: // prep and run the next test michael@0: run_test_setup(crD); michael@0: executeSoon(function() { browser.loadURI("about:crashes", null, null); }); michael@0: } michael@0: }); michael@0: }; michael@0: browser.addEventListener("load", onLoad, true); michael@0: registerCleanupFunction(function () { michael@0: browser.removeEventListener("load", onLoad, true); michael@0: }); michael@0: // kick things off michael@0: run_test_setup(crD); michael@0: browser.loadURI("about:crashes", null, null); michael@0: }