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