Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | function check_clear_visible(tab, aVisible) { |
michael@0 | 2 | let doc = gBrowser.getBrowserForTab(tab).contentDocument; |
michael@0 | 3 | let visible = false; |
michael@0 | 4 | let button = doc.getElementById("clear-reports"); |
michael@0 | 5 | if (button) { |
michael@0 | 6 | let style = doc.defaultView.getComputedStyle(button, ""); |
michael@0 | 7 | if (style.display != "none" && |
michael@0 | 8 | style.visibility == "visible") |
michael@0 | 9 | visible = true; |
michael@0 | 10 | } |
michael@0 | 11 | is(visible, aVisible, |
michael@0 | 12 | "clear reports button is " + (aVisible ? "visible" : "hidden")); |
michael@0 | 13 | } |
michael@0 | 14 | |
michael@0 | 15 | // each test here has a setup (run before loading about:crashes) and onload (run after about:crashes loads) |
michael@0 | 16 | let _tests = [{setup: null, onload: function(tab) { check_clear_visible(tab, false); }}, |
michael@0 | 17 | {setup: function(crD) { add_fake_crashes(crD, 1); }, |
michael@0 | 18 | onload: function(tab) { check_clear_visible(tab, true); }} |
michael@0 | 19 | ]; |
michael@0 | 20 | let _current_test = 0; |
michael@0 | 21 | |
michael@0 | 22 | function run_test_setup(crD) { |
michael@0 | 23 | if (_tests[_current_test].setup) { |
michael@0 | 24 | _tests[_current_test].setup(crD); |
michael@0 | 25 | } |
michael@0 | 26 | } |
michael@0 | 27 | |
michael@0 | 28 | function run_test_onload(tab) { |
michael@0 | 29 | if (_tests[_current_test].onload) { |
michael@0 | 30 | _tests[_current_test].onload(tab); |
michael@0 | 31 | } |
michael@0 | 32 | _current_test++; |
michael@0 | 33 | |
michael@0 | 34 | if (_current_test == _tests.length) { |
michael@0 | 35 | cleanup_fake_appdir(); |
michael@0 | 36 | gBrowser.removeTab(tab); |
michael@0 | 37 | finish(); |
michael@0 | 38 | return false; |
michael@0 | 39 | } |
michael@0 | 40 | return true; |
michael@0 | 41 | } |
michael@0 | 42 | |
michael@0 | 43 | function test() { |
michael@0 | 44 | waitForExplicitFinish(); |
michael@0 | 45 | let appD = make_fake_appdir(); |
michael@0 | 46 | let crD = appD.clone(); |
michael@0 | 47 | crD.append("Crash Reports"); |
michael@0 | 48 | |
michael@0 | 49 | let tab = gBrowser.selectedTab = gBrowser.addTab("about:blank"); |
michael@0 | 50 | let browser = gBrowser.getBrowserForTab(tab); |
michael@0 | 51 | let onLoad = function () { |
michael@0 | 52 | executeSoon(function() { |
michael@0 | 53 | if (run_test_onload(tab)) { |
michael@0 | 54 | // prep and run the next test |
michael@0 | 55 | run_test_setup(crD); |
michael@0 | 56 | executeSoon(function() { browser.loadURI("about:crashes", null, null); }); |
michael@0 | 57 | } |
michael@0 | 58 | }); |
michael@0 | 59 | }; |
michael@0 | 60 | browser.addEventListener("load", onLoad, true); |
michael@0 | 61 | registerCleanupFunction(function () { |
michael@0 | 62 | browser.removeEventListener("load", onLoad, true); |
michael@0 | 63 | }); |
michael@0 | 64 | // kick things off |
michael@0 | 65 | run_test_setup(crD); |
michael@0 | 66 | browser.loadURI("about:crashes", null, null); |
michael@0 | 67 | } |