Bug 1335905 - Fixed all the mistakes mentioned form Mozreview (Spelling, functions, text cases) r?jaws, r?mconley
MozReview-Commit-ID: EDyJ6dMAMNm
--- a/browser/components/preferences/in-content/SearchEach.js
+++ b/browser/components/preferences/in-content/SearchEach.js
@@ -1,388 +1,372 @@
// Search Object to load the 6th pin properly
var gSearchResults = {
- init(){}
+ init() {}
}
// Obtaining the search field
let mainSearchElement = document.getElementById("searchTextIMF");
// Boolean flag to init JavaScript bindings
let firstTimeSearch = true;
document.getElementById("searchTextIMF").addEventListener("command", searchFunc);
// Obtaining the Search Results tag
const searchResultsCategory = document.getElementById("categories").firstElementChild;
/**
* Toggling Seachbar on and off according to browser.preference.search
- *
- * @returns null
*/
function hideShowSearch() {
- let mainSearchEnable = Services.prefs.getBoolPref("browser.preference.search");
- // Change this implementation is not put in each of the tabs. No loop
- if (mainSearchEnable) {
- mainSearchElement.setAttribute("hidden","false");
- } else {
- mainSearchElement.setAttribute("hidden","true");
- }
+ let mainSearchEnable = Services.prefs.getBoolPref("browser.preference.search");
+ if (mainSearchEnable) {
+ mainSearchElement.hidden = false;
+ // setAttribute("hidden", "false");
+ } else {
+ mainSearchElement.hidden = true;
+ // setAttribute("hidden", "true");
+ }
}
-// Clearning the search filed when before enable or disable
+// Clearing the search filed before enabling
mainSearchElement.innerHTML = "";
mainSearchElement.value = "";
hideShowSearch();
/**
* Check that the passed string matches the filter arguments.
*
* @param String str
- * to search for filter words in.
+ * to search for filter words in.
* @param String filter
- * is a string containing all of the words to filter on.
+ * is a string containing all of the words to filter on.
* @returns boolean
+ * true when match in string else false
*/
function stringMatchesFilters(str, filter) {
- if (!filter || !str) {
- return true;
- }
+ if (!filter || !str) {
+ return true;
+ }
- let searchStr = str.toLowerCase();
- let filterStrings = filter.toLowerCase().split(/\s+/);
- return !filterStrings.some(function(f) {
- return searchStr.indexOf(f) == -1;
- });
+ let searchStr = str.toLowerCase();
+ let filterStrings = filter.toLowerCase().split(/\s+/);
+ return !filterStrings.some(function(f) {
+ return searchStr.indexOf(f) == -1;
+ });
}
/**
* When search bar is clicked initializes all the JS bindings
- *
+ *
* @returns null
*/
-function searchOnClick(){
- // Initializing all the JS for all the tabs
- if (firstTimeSearch) {
- firstTimeSearch = false;
- gCategoryInits.forEach( function(eachTab) {
- if (!eachTab.inited) {
- eachTab.init();
- }
- });
- }
+function searchOnClick() {
+ // Initializing all the JS for all the tabs
+ if (firstTimeSearch) {
+ firstTimeSearch = false;
+ gCategoryInits.forEach( function(eachTab) {
+ if (!eachTab.inited) {
+ eachTab.init();
+ }
+ });
+ }
}
/**
* Finding text nodes from the nodes
* Source - http:// stackoverflow.com/questions/10730309/find-all-text-nodes-in-html-page
- *
+ *
* @param Node nodeObject
- * Html element
+ * Html element
* @returns array of text nodes
*/
function textNodesUnder(node) {
- let all = [];
- for (node = node.firstChild; node; node = node.nextSibling) {
- if (node.nodeType === node.TEXT_NODE) all.push(node);
- else all = all.concat(textNodesUnder(node));
- }
- return all;
+ let all = [];
+ for (node = node.firstChild; node; node = node.nextSibling) {
+ if (node.nodeType === node.TEXT_NODE) all.push(node);
+ else all = all.concat(textNodesUnder(node));
+ }
+ return all;
}
/**
* Finding words in the text node
*
* @param Node textNode
- * Html element
- * @param String textSearch
- * textNodes's text content
+ * Html element
* @param String word
- * work to search for
+ * work to search for
* @param Object findSelection
- * Selection tool
+ * SelectionController
* @returns boolean
+ * Returns true when atleast one instance of word is found, false otherwise
*/
-function searchWord(textNode, textSearch, word, findSelection) {
- let regExp = new RegExp(word, "gi");
- let result, indices = [];
+function searchWord(textNode, word, findSelection) {
+ let textSearch = textNode.textContent;
+ let regExp = new RegExp(word, "gi");
+ let result, indices = [];
- while ((result = regExp.exec(textSearch))) {
- indices.push(result.index);
- }
+ while ((result = regExp.exec(textSearch))) {
+ indices.push(result.index);
+ }
- // Add each found word to range
- for (let i = 0; i < indices.length; i++) {
- let range = document.createRange();
- range.setStart(textNode, indices[i]);
- range.setEnd(textNode, (indices[i] + word.length) );
- findSelection.addRange(range); // Add each range to be highlighted
- }
- return indices.length > 0;
+ // Add each found word to range
+ for (let i = 0; i < indices.length; i++) {
+ let range = document.createRange();
+ range.setStart(textNode, indices[i]);
+ range.setEnd(textNode, (indices[i] + word.length) );
+ findSelection.addRange(range); // Add each range to be highlighted
+ }
+ return indices.length > 0;
}
/**
* Finding words in the text nodes
* Cases where the word is split up due to access keys
* @param Array textNodes
- * List of Html elements
+ * List of Html elements
* @param Array nodeSizes
- * Running size of text nodes
+ * Running size of text nodes
* @param String textSearch
- * Concatination of textNodes's text content
+ * Concatination of textNodes's text content
* @param String word
- * Word to search for
+ * Word to search for
* @param Object findSelection
- * Selection tool
+ * SelectionController
* @returns boolean
+ * Returns true when atleast one instance of word is found, otherwise false
*/
function multiSearch(textNodes, nodeSizes, textSearch, word, findSelection) {
- let regExp = new RegExp(word, "gi");
- let result, indices = [];
+ let regExp = new RegExp(word, "gi");
+ let result, indices = [];
- while ((result = regExp.exec(textSearch))) {
- indices.push(result.index);
- }
+ while ((result = regExp.exec(textSearch))) {
+ indices.push(result.index);
+ }
- // Looping through each spot the word is found in the concatinated string
- indices.forEach(function(startValue, startIndex) {
- let endValue = startValue + word.length;
- let startNode = null;
- let endNode = null;
- let nodeStartIndex = null;
+ // Looping through each spot the word is found in the concatinated string
+ indices.forEach(function(startValue, startIndex) {
+ let endValue = startValue + word.length;
+ let startNode = null;
+ let endNode = null;
+ let nodeStartIndex = null;
- // Determining the start and end node to highlight from
- nodeSizes.forEach(function(lengthNodes, index) {
- // Determining the start node
- if (!startNode && lengthNodes >= startValue) {
- startNode = textNodes[index];
- nodeStartIndex = index;
- if (index > 0 ) {
- startValue -= nodeSizes[index - 1];
- }
- }
- // Determining the end node
- if (!endNode && lengthNodes >= endValue) {
- endNode = textNodes[index];
- if (index != nodeStartIndex || index > 0 ) {
- endValue -= nodeSizes[index - 1];
- }
- }
- });
- // Selection the section to higlight
- let range = document.createRange();
- range.setStart(startNode, startValue);
- range.setEnd(endNode, endValue);
- findSelection.addRange(range);
+ // Determining the start and end node to highlight from
+ nodeSizes.forEach(function(lengthNodes, index) {
+ // Determining the start node
+ if (!startNode && lengthNodes >= startValue) {
+ startNode = textNodes[index];
+ nodeStartIndex = index;
+ if (index > 0 ) {
+ startValue -= nodeSizes[index - 1];
+ }
+ }
+ // Determining the end node
+ if (!endNode && lengthNodes >= endValue) {
+ endNode = textNodes[index];
+ if (index != nodeStartIndex || index > 0 ) {
+ endValue -= nodeSizes[index - 1];
+ }
+ }
});
+ // Selection the section to higlight
+ let range = document.createRange();
+ range.setStart(startNode, startValue);
+ range.setEnd(endNode, endValue);
+ findSelection.addRange(range);
+ });
- return indices.length > 0;
+ return indices.length > 0;
}
/**
- * Finding if search phrase is in TextContent Attribute
- *
- * @param Node nodeObject
- * Html element
+ * Finding if search phrase in defined node property (textContet, value, label)
+ *
+ * @param Node nodePropertyObject
+ * specific html element property
* @param String searchPhrase
- * word or words to search for
- * @returns boolean
- */
-function getTextContentAttribute(nodeObject, searchPhrase) {
- if (typeof nodeObject.textContent == "string" && nodeObject.textContent != ""
- && stringMatchesFilters(nodeObject.textContent, searchPhrase)) {
- return true;
- }
- return false;
-}
-
-/**
- * Finding if search phrase is in Label Attribute
- *
- * @param Node nodeObject
- * Html element
- * @param String searchPhrase
- * word or words to search for
+ * word or words to search for
* @returns boolean
+ * Returns true when found in textContent, false otherwise
*/
-function getLabelAttribute(nodeObject, searchPhrase) {
- if (typeof nodeObject.label == "string" && nodeObject.label != ""
- && stringMatchesFilters(nodeObject.label, searchPhrase)) {
- return true;
- }
- return false;
-}
-
-/**
- * Finding if search phrase is in Value Attribute
- *
- * @param Node nodeObject
- * Html element
- * @param String searchPhrase
- * word or words to search for
- * @returns boolean
- */
-function getValueAttribute(nodeObject, searchPhrase, findSelection) {
- if (typeof nodeObject.value == "string" && nodeObject.value != ""
- && stringMatchesFilters(nodeObject.value, searchPhrase)) {
- return true;
- }
- return false;
+function searchNodeProperty(nodePropertyObject, searchPhrase) {
+ if (typeof nodePropertyObject == "string" && nodePropertyObject != ""
+ && stringMatchesFilters(nodePropertyObject, searchPhrase)) {
+ return true;
+ }
+ return false;
}
/**
* Getter for Selection Controller
- *
+ *
* @returns controller
*/
function getSelectionController() {
- // Yuck. See bug 138068.
- let docShell = window.QueryInterface(Ci.nsIInterfaceRequestor)
- .getInterface(Ci.nsIWebNavigation)
- .QueryInterface(Ci.nsIDocShell);
+ // Yuck. See bug 138068.
+ let docShell = window.QueryInterface(Ci.nsIInterfaceRequestor)
+ .getInterface(Ci.nsIWebNavigation)
+ .QueryInterface(Ci.nsIDocShell);
- let controller = docShell.QueryInterface(Ci.nsIInterfaceRequestor)
- .getInterface(Ci.nsISelectionDisplay)
- .QueryInterface(Ci.nsISelectionController);
+ let controller = docShell.QueryInterface(Ci.nsIInterfaceRequestor)
+ .getInterface(Ci.nsISelectionDisplay)
+ .QueryInterface(Ci.nsISelectionController);
- return controller;
+ return controller;
}
/**
* SHows or hides content according to search input
*
* @param String event
- * to search for filter words in
- * @returns boolean
+ * to search for filter words in
*/
function searchFunc(event) {
- let words = event.target.value.trim();
+ let words = event.target.value.trim();
- // Controller
- let controller = getSelectionController();
- let findSelection = controller.getSelection(Ci.nsISelectionController.SELECTION_FIND);
- findSelection.removeAllRanges();
+ // Controller
+ let controller = getSelectionController();
+ let findSelection = controller.getSelection(Ci.nsISelectionController.SELECTION_FIND);
+ findSelection.removeAllRanges();
- // Init for Search Results tab
- let srHeader = document.getElementById("header-searchResults");
- let noResults = document.getElementById("noResultsFound");
+ // Init for Search Results tab
+ let srHeader = document.getElementById("header-searchResults");
+ let noResults = document.getElementById("noResultsFound");
+ let strings = document.getElementById("searchResultBundle");
- if (words) {
- console.time("SearchTime");
+ if (words) {
+ console.time("SearchTime");
- // Showing the Search Results Tag
- gotoPref("paneSearchResults");
- srHeader.setAttribute("hidden", "false");
- searchResultsCategory.setAttribute("hidden", "false");
+ // Showing the Search Results Tag
+ gotoPref("paneSearchResults");
+ srHeader.hidden = false;
+ // setAttribute("hidden", "false");
+ searchResultsCategory.hidden = false;
+ // setAttribute("hidden", "false");
+
+ let searchFound = false;
- let notSearchFound = true;
-
- // Building the range for highlighted areas
- let rootPreferences = document.getElementById("mainPrefPane")
- let rootPreferencesChildren = rootPreferences.childNodes;
+ // Building the range for highlighted areas
+ let rootPreferences = document.getElementById("mainPrefPane")
+ let rootPreferencesChildren = rootPreferences.childNodes;
- // Showing all the children to bind JS, Access Keys, etc
- for (let i = 0; i < rootPreferences.childElementCount; i++) {
- rootPreferencesChildren[i].setAttribute("hidden", "false");
- }
+ // Showing all the children to bind JS, Access Keys, etc
+ for (let i = 0; i < rootPreferences.childElementCount; i++) {
+ rootPreferencesChildren[i].hidden = false;
+ // setAttribute("hidden", "false");
+ }
- // Showing or Hiding specific section depending on if words are found
- for (let i = 0; i < rootPreferences.childElementCount; i++) {
- if (nodeRecursion(rootPreferencesChildren[i], words, findSelection)) {
- rootPreferencesChildren[i].setAttribute("hidden", "false");
- notSearchFound = false;
- } else {
- rootPreferencesChildren[i].setAttribute("hidden", "true");
- }
- }
- srHeader.setAttribute("hidden", "false");
+ // Showing or Hiding specific section depending on if words are found
+ for (let i = 0; i < rootPreferences.childElementCount; i++) {
+ if (nodeRecursion(rootPreferencesChildren[i], words, findSelection)) {
+ rootPreferencesChildren[i].hidden = false;
+ // setAttribute("hidden", "false");
+ searchFound = true;
+ } else {
+ rootPreferencesChildren[i].hidden = true;
+ // setAttribute("hidden", "true");
+ }
+ }
+ srHeader.hidden = false;
+ // setAttribute("hidden", "false");
- if(notSearchFound){
- noResults.setAttribute("hidden", "false");
- for (let i = 0; i < noResults.childNodes.length; i++) {
- noResults.childNodes[i].setAttribute("hidden", "false");
- }
+ if (!searchFound) {
+ noResults.hidden = false;
+ // setAttribute("hidden", "false");
+ for (let i = 0; i < noResults.childNodes.length; i++) {
+ if (i == 0) {
+ noResults.childNodes[0].textContent = strings.getFormattedString("sorryMessage", [words]);
}
- console.timeEnd("SearchTime");
- } else {
- searchResultsCategory.setAttribute("hidden", "true");
+ noResults.childNodes[i].hidden = false;
+ // setAttribute("hidden", "false");
+ }
+ }
+ console.timeEnd("SearchTime");
+ } else {
+ searchResultsCategory.hidden = true;
+ // setAttribute("hidden", "true");
- srHeader.setAttribute("hidden", "true");
- noResults.setAttribute("hidden", "true");
- // Hiding the child nodes so they will not be searched
- for (let i = 0; i < noResults.childNodes.length; i++) {
- noResults.childNodes[i].setAttribute("hidden", "true");
- }
-
- // Going back to General when cleared
- gotoPref("paneGeneral");
+ srHeader.hidden = true;
+ // setAttribute("hidden", "true");
+ noResults.hidden = true;
+ // setAttribute("hidden", "true");
+ // Hiding the child nodes so they will not be searched
+ for (let i = 0; i < noResults.childNodes.length; i++) {
+ noResults.childNodes[i].hidden = true;
+ // setAttribute("hidden", "true");
}
+ // Going back to General when cleared
+ gotoPref("paneGeneral");
+ }
+
}
/**
* Finding leaf nodes and checking their content for words to search
*
* @param Node nodeObject
- * Html element
+ * Html element
* @param String searchPhrase
- * The list of words to search for
+ * The list of words to search for
* @param Object findSelection
- * Selection tool
+ * SelectionController
* @returns boolean
+ * Returns true when found in atleast one childNode, false otherwise
*/
function nodeRecursion(nodeObject, searchPhrase, findSelection) {
- let foundIn = false;
- if (nodeObject.childElementCount == 0) {
- let leafTextNodes, otherTextNodes = [];
- // List of words to search on
- let listOfWords = searchPhrase.trim().split();
-
- if (nodeObject) {
- leafTextNodes = textNodesUnder(nodeObject);
- }
- if (nodeObject.boxObject) {
- otherTextNodes = textNodesUnder(nodeObject.boxObject);
- }
-
- // Searching in the Text Nodes
- leafTextNodes.forEach(function(node) {
- listOfWords.forEach(function(word) {
- let boolAns = searchWord(node, node.textContent, word, findSelection);
- foundIn = foundIn || boolAns;
- });
- });
+ let foundIn = false;
+ if (nodeObject.childElementCount == 0) {
+ let leafTextNodes, otherTextNodes = [];
+ // List of words to search on
+ let listOfWords = searchPhrase.trim().split();
- // Collecting data from boxObject
- let nodeSizes = [];
- let allNodeText = "";
- let runningSize = 0;
-
- otherTextNodes.forEach(function(node) {
- runningSize += node.textContent.length;
- allNodeText += node.textContent;
- nodeSizes.push(runningSize);
- });
-
- listOfWords.forEach(function(word) {
- // Linux machines where access key is presented
- let splitAns = multiSearch(otherTextNodes, nodeSizes, allNodeText, word, findSelection);
-
- // Searching in the buttons
- let buttonAns = getLabelAttribute(nodeObject, word);
-
- // Label tag that does not have textContent but text is in Value attr
- let labelAns = getValueAttribute(nodeObject, word, findSelection);
-
- foundIn = foundIn || splitAns || buttonAns || labelAns;
- });
+ if (nodeObject) {
+ leafTextNodes = textNodesUnder(nodeObject);
+ }
+ if (nodeObject.boxObject) {
+ otherTextNodes = textNodesUnder(nodeObject.boxObject);
}
- for (let i = 0; i < nodeObject.childNodes.length; i++) {
- // Search only if child node is not hidden
- if (!nodeObject.childNodes[i].hidden) {
- let boolAns = nodeRecursion(nodeObject.childNodes[i], searchPhrase, findSelection);
- foundIn = foundIn || boolAns;
- }
+ // Searching in the Text Nodes
+ leafTextNodes.forEach(function(node) {
+ listOfWords.forEach(function(word) {
+ let boolAns = searchWord(node, word, findSelection);
+ foundIn = foundIn || boolAns;
+ });
+ });
+
+ // Collecting data from boxObject
+ let nodeSizes = [];
+ let allNodeText = "";
+ let runningSize = 0;
+
+ otherTextNodes.forEach(function(node) {
+ runningSize += node.textContent.length;
+ allNodeText += node.textContent;
+ nodeSizes.push(runningSize);
+ });
+
+ listOfWords.forEach(function(word) {
+ // Access key are presented
+ let splitAns = multiSearch(otherTextNodes, nodeSizes, allNodeText, word, findSelection);
+
+ // Searching in the buttons label property
+ let buttonAns = searchNodeProperty(nodeObject["label"], word);
+
+ // Label tag that does not have textContent but text is in Value attr
+ let labelAns = searchNodeProperty(nodeObject["value"], word);
+
+ foundIn = foundIn || splitAns || buttonAns || labelAns;
+ });
+ }
+
+ for (let i = 0; i < nodeObject.childNodes.length; i++) {
+ // Search only if child node is not hidden
+ if (!nodeObject.childNodes[i].hidden) {
+ let boolAns = nodeRecursion(nodeObject.childNodes[i], searchPhrase, findSelection);
+ foundIn = foundIn || boolAns;
}
- return foundIn;
-}
\ No newline at end of file
+ }
+ return foundIn;
+}
--- a/browser/components/preferences/in-content/preferences.js
+++ b/browser/components/preferences/in-content/preferences.js
@@ -77,17 +77,17 @@ function init_all() {
categories.setAttribute("keyboard-navigation", "true");
}
});
categories.addEventListener("mousedown", function() {
this.removeAttribute("keyboard-navigation");
});
window.addEventListener("hashchange", onHashChange);
- gotoPref("paneGeneral");
+ gotoPref();
init_dynamic_padding();
var initFinished = new CustomEvent("Initialized", {
"bubbles": true,
"cancelable": true
});
document.dispatchEvent(initFinished);
@@ -155,17 +155,18 @@ function telemetryBucketForCategory(cate
}
function onHashChange() {
gotoPref();
}
function gotoPref(aCategory) {
let categories = document.getElementById("categories");
- const kDefaultCategoryInternalName = categories.firstElementChild.value;
+ // Going to the first child that is not hidden
+ const kDefaultCategoryInternalName = categories.childNodes[1].value;
let hash = document.location.hash;
let category = aCategory || hash.substr(1) || kDefaultCategoryInternalName;
category = friendlyPrefCategoryNameToInternalName(category);
// Updating the hash (below) or changing the selected category
// will re-enter gotoPref.
if (gLastHash == category)
return;
--- a/browser/components/preferences/in-content/preferences.xul
+++ b/browser/components/preferences/in-content/preferences.xul
@@ -20,16 +20,17 @@
<!ENTITY % globalPreferencesDTD SYSTEM "chrome://global/locale/preferences.dtd">
<!ENTITY % preferencesDTD SYSTEM
"chrome://browser/locale/preferences/preferences.dtd">
<!ENTITY % privacyDTD SYSTEM "chrome://browser/locale/preferences/privacy.dtd">
<!ENTITY % tabsDTD SYSTEM "chrome://browser/locale/preferences/tabs.dtd">
<!ENTITY % searchDTD SYSTEM "chrome://browser/locale/preferences/search.dtd">
<!ENTITY % syncBrandDTD SYSTEM "chrome://browser/locale/syncBrand.dtd">
<!ENTITY % syncDTD SYSTEM "chrome://browser/locale/preferences/sync.dtd">
+<!ENTITY % searchResultsDTD SYSTEM "chrome://browser/locale/preferences/searchResults.dtd">
<!ENTITY % securityDTD SYSTEM
"chrome://browser/locale/preferences/security.dtd">
<!ENTITY % containersDTD SYSTEM
"chrome://browser/locale/preferences/containers.dtd">
<!ENTITY % sanitizeDTD SYSTEM "chrome://browser/locale/sanitize.dtd">
<!ENTITY % mainDTD SYSTEM "chrome://browser/locale/preferences/main.dtd">
<!ENTITY % aboutHomeDTD SYSTEM "chrome://browser/locale/aboutHome.dtd">
<!ENTITY % contentDTD SYSTEM "chrome://browser/locale/preferences/content.dtd">
@@ -48,16 +49,17 @@
%securityDTD;
%containersDTD;
%sanitizeDTD;
%mainDTD;
%aboutHomeDTD;
%contentDTD;
%applicationsDTD;
%advancedDTD;
+%searchResultsDTD;
]>
#ifdef XP_WIN
#define USE_WIN_TITLE_STYLE
#endif
<page xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml"
--- a/browser/components/preferences/in-content/searchResults.xul
+++ b/browser/components/preferences/in-content/searchResults.xul
@@ -1,12 +1,15 @@
+<stringbundle id="searchResultBundle" src="chrome://browser/locale/preferences/searchResults.properties"/>
+
+
<hbox id="header-searchResults"
class="header"
hidden="true"
data-category="paneSearchResults">
<label class="header-name" flex="1">&paneSearchResults.title;</label>
<html:a class="help-button" target="_blank" aria-label="&helpButton.label;"></html:a>
</hbox>
<groupbox id="noResultsFound" align="start" data-category="paneSearchResults" hidden="true">
- <label hidden="true">Sorry! No results are found for the searched word</label>
- <label hidden="true"> Need help? Visit <a href="https://support.mozilla.org/t5/Mozilla-Support-English/ct-p/Mozilla-EN" class="text-link">Firefox Support</a></label>
+ <label hidden="true"></label>
+ <label hidden="true">&needHelp.label;<a href="https://support.mozilla.org/t5/Mozilla-Support-English/ct-p/Mozilla-EN" class="text-link">&supportPage.label;</a></label>
</groupbox>
--- a/browser/components/preferences/in-content/tests/browser_search_within_preferences.js
+++ b/browser/components/preferences/in-content/tests/browser_search_within_preferences.js
@@ -1,133 +1,159 @@
/*
This file contains tests for the preferences search bar
*/
/**
* Tests to see if search bar is being hidden when pref is turned off
*/
-add_task(function*(){
- Services.prefs.setBoolPref("browser.preference.search",false);
- yield openPreferencesViaOpenPreferencesAPI("paneGeneral", undefined, {leaveOpen: true});
- let mainSeachEmelemt = gBrowser.contentDocument.querySelectorAll('#searchTextIMF');
- is(mainSeachEmelemt.length, 1, "There should only be one element name searchTextIMF querySelectorAll");
- ok(is_hidden(mainSeachEmelemt[0]), "Search box should be hidden");
- yield BrowserTestUtils.removeTab(gBrowser.selectedTab);
+add_task(function*() {
+ Services.prefs.setBoolPref("browser.preference.search", false);
+ yield openPreferencesViaOpenPreferencesAPI("paneGeneral", undefined, {leaveOpen: true});
+ let searchInput = gBrowser.contentDocument.querySelectorAll("#searchTextIMF");
+ is(searchInput.length, 1, "There should only be one element name searchTextIMF querySelectorAll");
+ is_element_hidden(searchInput[0], "Search box should be hidden");
+ yield BrowserTestUtils.removeTab(gBrowser.selectedTab);
});
/**
* Tests to see if search bar is being shown when pref is turned one
*/
-add_task(function*(){
- Services.prefs.setBoolPref("browser.preference.search",true);
- yield openPreferencesViaOpenPreferencesAPI("paneGeneral", undefined, {leaveOpen: true});
- let mainSeachEmelemt = gBrowser.contentDocument.querySelectorAll('#searchTextIMF');
- is(mainSeachEmelemt.length, 1, "There should only be one element name searchTextIMF querySelectorAll");
- ok(!is_hidden(mainSeachEmelemt[0]), "Search box should be shown");
- yield BrowserTestUtils.removeTab(gBrowser.selectedTab);
- Services.prefs.setBoolPref("browser.preference.search",false);
+add_task(function*() {
+ Services.prefs.setBoolPref("browser.preference.search", true);
+ yield openPreferencesViaOpenPreferencesAPI("paneGeneral", undefined, {leaveOpen: true});
+ let searchInput = gBrowser.contentDocument.getElementById("searchTextIMF");
+ is_element_visible(searchInput, "Search box should be shown");
+ yield BrowserTestUtils.removeTab(gBrowser.selectedTab);
+ Services.prefs.setBoolPref("browser.preference.search", false);
});
/**
* Test for "Search Result" panel
*/
-add_task(function*(){
- Services.prefs.setBoolPref("browser.preference.search",true);
- yield openPreferencesViaOpenPreferencesAPI("paneGeneral", undefined, {leaveOpen: true});
+add_task(function*() {
+ Services.prefs.setBoolPref("browser.preference.search", true);
+ yield openPreferencesViaOpenPreferencesAPI("paneGeneral", undefined, {leaveOpen: true});
- let searchResultsPane = gBrowser.contentDocument.getElementById("category-search-results");
+ let searchResultsPane = gBrowser.contentDocument.getElementById("category-search-results");
- ok(is_hidden(searchResultsPane), "Should not be in search results pane yet");
+ is_element_hidden(searchResultsPane, "Should not be in search results pane yet");
- // Performs search
- let mainSeachEmelemt = gBrowser.contentDocument.getElementById("searchTextIMF");
- mainSeachEmelemt.click();
- yield new Promise(resolve => setTimeout(resolve, 1000));
- mainSeachEmelemt.value = "password";
- mainSeachEmelemt.click();
+ // Performs search
+ let searchInput = gBrowser.contentDocument.getElementById("searchTextIMF");
+ searchInput.click();
+ yield new Promise(resolve => setTimeout(resolve, 1000));
+ searchInput.value = "password";
+ searchInput.click();
- // Checks we are in paneSearchResults
- ok(!is_hidden(searchResultsPane), "Should be in search results pane");
+ // Checks we are in paneSearchResults
+ is_element_visible(searchResultsPane, "Should be in search results pane");
- // Takes search off
- mainSeachEmelemt.value = "";
- mainSeachEmelemt.click();
+ // Takes search off
+ searchInput.value = "";
+ searchInput.click();
- // Checks if back to normal
- ok(is_hidden(searchResultsPane), "Should not be in search results pane");
+ // Checks if back to normal
+ is_element_hidden(searchResultsPane, "Should not be in search results pane");
- yield BrowserTestUtils.removeTab(gBrowser.selectedTab);
- Services.prefs.setBoolPref("browser.preference.search",false);
+ yield BrowserTestUtils.removeTab(gBrowser.selectedTab);
+ Services.prefs.setBoolPref("browser.preference.search", false);
});
/**
* Test for "password" case
* When we search "password", it should show the "passwordGroup"
*/
+add_task(function*() {
+ Services.prefs.setBoolPref("browser.preference.search", true);
+ yield openPreferencesViaOpenPreferencesAPI("paneGeneral", undefined, {leaveOpen: true});
-add_task(function*(){
- Services.prefs.setBoolPref("browser.preference.search",true);
- yield openPreferencesViaOpenPreferencesAPI("paneGeneral", undefined, {leaveOpen: true});
+ let searchResults = gBrowser.contentDocument.getElementById("passwordsGroup");
- let searchResults = gBrowser.contentDocument.getElementById("passwordsGroup");
-
- ok(is_hidden(searchResults), "Should not be in search results yet");
+ is_element_hidden(searchResults, "Should not be in search results yet");
- // Performs search
- let mainSeachEmelemt = gBrowser.contentDocument.getElementById("searchTextIMF");
- mainSeachEmelemt.click();
- yield new Promise(resolve => setTimeout(resolve, 1000));
- mainSeachEmelemt.value = "password";
- mainSeachEmelemt.click();
+ // Performs search
+ let searchInput = gBrowser.contentDocument.getElementById("searchTextIMF");
+ searchInput.click();
+ yield new Promise(resolve => setTimeout(resolve, 1000));
+ searchInput.value = "password";
+ searchInput.click();
- // Checks we are in we have found it
- ok(!is_hidden(searchResults), "Should be in search results");
+ // Checks we are in we have found it
+ is_element_visible(searchResults, "Should be in search results");
- // Takes search off
- mainSeachEmelemt.value = "";
- mainSeachEmelemt.click();
+ // Takes search off
+ searchInput.value = "";
+ searchInput.click();
- // Checks if back to normal
- ok(is_hidden(searchResults), "Should not be in search results");
+ // Checks if back to normal
+ is_element_hidden(searchResults, "Should not be in search results");
- yield BrowserTestUtils.removeTab(gBrowser.selectedTab);
- Services.prefs.setBoolPref("browser.preference.search",false);
+ yield BrowserTestUtils.removeTab(gBrowser.selectedTab);
+ Services.prefs.setBoolPref("browser.preference.search", false);
});
/**
* Test for if nothing is found
*/
-add_task(function*(){
- Services.prefs.setBoolPref("browser.preference.search",true);
- yield openPreferencesViaOpenPreferencesAPI("paneGeneral", undefined, {leaveOpen: true});
+add_task(function*() {
+ Services.prefs.setBoolPref("browser.preference.search", true);
+ yield openPreferencesViaOpenPreferencesAPI("paneGeneral", undefined, {leaveOpen: true});
+
+ let searchResults = gBrowser.contentDocument.getElementById("noResultsFound");
+
+ is_element_hidden(searchResults, "Should not be in search results yet");
- let searchResults = gBrowser.contentDocument.getElementById("noResultsFound");
+ // Performs search
+ let searchInput = gBrowser.contentDocument.getElementById("searchTextIMF");
+ searchInput.click();
+ yield new Promise(resolve => setTimeout(resolve, 1000));
+ searchInput.value = "coach";
+ searchInput.click();
- ok(is_hidden(searchResults), "Should not be in search results yet");
+ // Checks we are in no results found
+ is_element_visible(searchResults, "Should be in search results");
+
+ // Takes search off
+ searchInput.value = "";
+ searchInput.click();
+
+ // Checks if back to normal
+ is_element_hidden(searchResults, "Should not be in search results");
- // Performs search
- let mainSeachEmelemt = gBrowser.contentDocument.getElementById("searchTextIMF");
- mainSeachEmelemt.click();
- yield new Promise(resolve => setTimeout(resolve, 1000));
- mainSeachEmelemt.value = "coach";
- mainSeachEmelemt.click();
+ yield BrowserTestUtils.removeTab(gBrowser.selectedTab);
+ Services.prefs.setBoolPref("browser.preference.search", false);
+});
+
+/**
+ * Test for if we go back to general tab after search case
+ */
+add_task(function*() {
+ Services.prefs.setBoolPref("browser.preference.search", true);
+ yield openPreferencesViaOpenPreferencesAPI("privacy", undefined, {leaveOpen: true});
+
+ let generalPane = gBrowser.contentDocument.getElementById("header-general");
- // Checks we are in no results found
- ok(!is_hidden(searchResults), "Should be in search results");
+ is_element_hidden(generalPane, "Should not be in general");
- // Takes search off
- mainSeachEmelemt.value = "";
- mainSeachEmelemt.click();
+ // Performs search
+ let searchInput = gBrowser.contentDocument.getElementById("searchTextIMF");
+ searchInput.click();
+ yield new Promise(resolve => setTimeout(resolve, 1000));
+ searchInput.value = "password";
+ searchInput.click();
- // Checks if back to normal
- ok(is_hidden(searchResults), "Should not be in search results");
+ // Takes search off
+ searchInput.value = "";
+ searchInput.click();
+
+ // Checks if back to normal
+ is_element_visible(generalPane, "Should be in generalPane");
- yield BrowserTestUtils.removeTab(gBrowser.selectedTab);
- Services.prefs.setBoolPref("browser.preference.search",false);
-
-});
\ No newline at end of file
+ yield BrowserTestUtils.removeTab(gBrowser.selectedTab);
+ Services.prefs.setBoolPref("browser.preference.search", false);
+});
new file mode 100644
--- /dev/null
+++ b/browser/locales/en-US/chrome/browser/preferences/searchResults.dtd
@@ -0,0 +1,6 @@
+<!-- This Source Code Form is subject to the terms of the Mozilla Public
+ - License, v. 2.0. If a copy of the MPL was not distributed with this
+ - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
+
+<!ENTITY needHelp.label "Need help? Visit ">
+<!ENTITY supportPage.label "Firefox Support">
new file mode 100644
--- /dev/null
+++ b/browser/locales/en-US/chrome/browser/preferences/searchResults.properties
@@ -0,0 +1,6 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+# in descriptionApplications, %S will be replaced by the word being searched
+sorryMessage=Sorry! No results were found for "%S"
--- a/browser/locales/jar.mn
+++ b/browser/locales/jar.mn
@@ -78,16 +78,18 @@
locale/browser/preferences/privacy.dtd (%chrome/browser/preferences/privacy.dtd)
locale/browser/preferences/security.dtd (%chrome/browser/preferences/security.dtd)
locale/browser/preferences/containers.dtd (%chrome/browser/preferences/containers.dtd)
locale/browser/preferences/sync.dtd (%chrome/browser/preferences/sync.dtd)
locale/browser/preferences/tabs.dtd (%chrome/browser/preferences/tabs.dtd)
locale/browser/preferences/search.dtd (%chrome/browser/preferences/search.dtd)
locale/browser/preferences/siteDataSettings.dtd (%chrome/browser/preferences/siteDataSettings.dtd)
locale/browser/preferences/translation.dtd (%chrome/browser/preferences/translation.dtd)
+ locale/browser/preferences/searchResults.dtd (%chrome/browser/preferences/searchResults.dtd)
+ locale/browser/preferences/searchResults.properties (%chrome/browser/preferences/searchResults.properties)
locale/browser/syncBrand.dtd (%chrome/browser/syncBrand.dtd)
locale/browser/syncSetup.properties (%chrome/browser/syncSetup.properties)
% resource search-plugins chrome://browser/locale/searchplugins/
#if BUILD_FASTER
locale/browser/searchplugins/ (searchplugins/*.xml)
locale/browser/searchplugins/list.json (search/list.json)
#else
locale/browser/searchplugins/ (.deps/generated_@AB_CD@/*.xml)