1
// Bug 571866 - --browser-chrome test for fennec preferences and text values
4
var gCurrentTest = null;
6
"aboutButton": {"tagName": "button", "element_id": "prefs-about-button"},
7
"homepage": {"element_id": "prefs-homepage",
8
"home_page": "prefs-homepage-default",
9
"blank_page": "prefs-homepage-none",
10
"current_page": "prefs-homepage-currentpage"},
11
"doneButton": {"tagName": "button"},
12
"contentRegion": {"element_id": "prefs-content"},
13
"imageRegion": {"pref": "permissions.default.image", "anonid": "input", "localName": "checkbox"},
14
"jsRegion": {"pref": "javascript.enabled", "anonid": "input", "localName": "checkbox"},
15
"privacyRegion": {"element_id": "prefs-privacy" },
16
"cookiesRegion": {"pref": "network.cookie.cookieBehavior", "anonid": "input", "localName": "checkbox"},
17
"passwordsRegion": {"pref": "signon.rememberSignons", "anonid": "input", "localName": "checkbox"},
18
"clearDataButton": {"element_id": "prefs-clear-data", "tagName": "button"}
21
function getPreferencesElements() {
22
let prefElements = {};
23
prefElements.panelOpen = document.getElementById("tool-panel-open");
24
prefElements.panelClose = document.getElementById("tool-panel-close");
25
prefElements.panelContainer = document.getElementById("panel-container");
26
prefElements.homeButton = document.getElementById("prefs-homepage-options");
27
prefElements.doneButton = document.getElementById("select-buttons-done");
28
prefElements.homePageControl = document.getElementById("prefs-homepage");
29
prefElements.selectContainer = document.getElementById("menulist-container");
34
// The "runNextTest" approach is async, so we need to call "waitForExplicitFinish()"
35
// We call "finish()" when the tests are finished
36
waitForExplicitFinish();
41
//------------------------------------------------------------------------------
42
// Iterating tests by shifting test out one by one as runNextTest is called.
43
function runNextTest() {
44
// Run the next test until all tests completed
45
if (gTests.length > 0) {
46
gCurrentTest = gTests.shift();
47
info(gCurrentTest.desc);
51
// Cleanup. All tests are completed at this point
56
// -----------------------------------------------------------------------------------------
57
// Verify preferences and text
59
desc: "Verify Preferences and Text",
62
var prefs = getPreferencesElements();
63
// 1.Click preferences to view prefs
64
prefs.panelOpen.click();
66
// 2. For each prefs *verify text *the button/option type *verify height of each field to be the same
67
is(prefs.panelContainer.hidden, false, "Preferences should be visible");
69
var prefsList = document.getElementById("prefs-messages");
71
// Check for *About page*
72
let about = expected.aboutButton;
73
var aboutRegion = document.getAnonymousElementByAttribute(prefsList, "title", "About Fennec");
74
var aboutButton = document.getElementById(about.element_id);
75
is(aboutButton.tagName, about.tagName, "The About Fennec input must be a button");
77
// Check for *Startpage*
78
let homepage = expected.homepage;
79
var homepageRegion = document.getElementById(homepage.element_id);
80
prefs.homeButton.click();
82
is(prefs.selectContainer.hidden, false, "Homepage select dialog must be visible");
84
let doneButton = expected.doneButton;
85
is(prefs.doneButton.tagName, doneButton.tagName, "The type of the Done input is button");
86
prefs.doneButton.click();
87
is(prefs.selectContainer.hidden, true, "Homepage select dialog must be closed");
89
let content = expected.contentRegion;
90
var contentRegion = document.getElementById(content.element_id);
92
// Check for *Show images*
93
var images = expected.imageRegion;
94
var imageRegion = document.getAnonymousElementByAttribute(contentRegion, "pref", images.pref);
95
var imageButton = document.getAnonymousElementByAttribute(imageRegion, "anonid", images.anonid);
96
is(imageButton.localName, images.localName, "Show images checkbox check");
97
// Checkbox or radiobutton?
99
// Check for *Enable javascript*
100
let js = expected.jsRegion;
101
var jsRegion = document.getAnonymousElementByAttribute(contentRegion, "pref", js.pref);
102
var jsButton = document.getAnonymousElementByAttribute(jsRegion, "anonid", js.anonid);
103
is(jsButton.localName, js.localName, "Enable JavaScript checkbox check");
104
// Checkbox or radiobutton?
106
let privacyRegion = expected.privacyRegion;
107
var prefsPrivacy = document.getElementById(privacyRegion.element_id);
109
// Check for *Allow cookies*
110
let cookies = expected.cookiesRegion;
111
var cookiesRegion = document.getAnonymousElementByAttribute(prefsPrivacy, "pref", cookies.pref);
112
var cookiesButton = document.getAnonymousElementByAttribute(cookiesRegion, "anonid", cookies.anonid);
113
is(cookiesButton.localName, cookies.localName, "Allow cookies checkbox check");
114
// Checkbox or radiobutton?
116
// Check for *Remember password*
117
let passwords = expected.passwordsRegion;
118
var passwordsRegion = document.getAnonymousElementByAttribute(prefsPrivacy, "pref", passwords.pref);
119
var passwordsButton = document.getAnonymousElementByAttribute(passwordsRegion, "anonid", passwords.anonid);
120
is(passwordsButton.localName, passwords.localName, "Allow cookies checkbox check");
121
// Checkbox or radiobutton?
123
// Check for *Clear Private Data*
124
let clearData = expected.clearDataButton;
125
var clearDataRegion = prefsPrivacy.lastChild;
126
var clearDataButton = document.getElementById(clearData.element_id);
127
is(clearDataButton.tagName, clearData.tagName, "Check for Clear Private Data button type");
129
prefs.panelClose.click()
130
is(document.getElementById("panel-container").hidden, true, "Preferences panel should be closed");