aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@redhat.com>2011-04-28 13:28:55 +0200
committerMatěj Cepl <mcepl@redhat.com>2011-06-05 14:47:40 +0200
commit55d9a312fbba91f1bcf5e3f3291b7bece8abb178 (patch)
treebb9ef165b425273da47aa000268395f87f26678e
parent34bbe8e7306a0d0ec014db7512788ed92c625d19 (diff)
downloadbugzilla-triage-55d9a312fbba91f1bcf5e3f3291b7bece8abb178.tar.gz
Reformatting to MoFo coding style
-rw-r--r--data/lib/addAttachmentRow.js32
-rw-r--r--data/lib/addNewLinks.js35
-rw-r--r--data/lib/bug-page-mod.js12
-rw-r--r--data/lib/bugzillaDOMFunctions.js122
-rw-r--r--data/lib/bzpage.js74
-rw-r--r--data/lib/checkin-context.js6
-rw-r--r--data/lib/color.js60
-rw-r--r--data/lib/fixingAttMIME.js51
-rw-r--r--data/lib/jumpNextBug.js61
-rw-r--r--data/lib/logging-front.js66
-rw-r--r--data/lib/makeBacktraceAttachment.js153
-rw-r--r--data/lib/otherButtons.js79
-rw-r--r--data/lib/preprocessDuplicates.js168
-rw-r--r--data/lib/queries.js122
-rw-r--r--data/lib/rhbzpage.js65
-rw-r--r--data/lib/skip-bug.js8
-rw-r--r--data/lib/urltest.js5
-rw-r--r--data/lib/util.js149
-rw-r--r--data/lib/viewSource.js52
-rw-r--r--data/lib/xorgBugCategories.js38
-rw-r--r--lib/cookiemanager.js4
-rw-r--r--lib/libbugzilla.js40
-rw-r--r--lib/logger.js82
-rw-r--r--lib/main.js135
-rw-r--r--lib/prompts.js31
-rw-r--r--lib/util.js31
-rw-r--r--lib/xmlrpc.js83
-rw-r--r--tests/pagemod-test-helpers.js12
-rw-r--r--tests/test-color.js20
-rw-r--r--tests/test-logger.js52
-rw-r--r--tests/test-match-pattern.js20
-rw-r--r--tests/test-pageMod.js195
-rw-r--r--tests/test-util.js240
-rw-r--r--tests/test-xmlrpc.js39
34 files changed, 1274 insertions, 1068 deletions
diff --git a/data/lib/addAttachmentRow.js b/data/lib/addAttachmentRow.js
index 204192e..a2b67ee 100644
--- a/data/lib/addAttachmentRow.js
+++ b/data/lib/addAttachmentRow.js
@@ -3,39 +3,41 @@
"use strict";
function addAttachmentCallback(resp) {
- var newAttachID = parseInt(resp.params.param.value.array.data.value.int, 10);
+ var newAttachID = parseInt(
+ resp.params.param.value.array.data.value.int, 10);
console.log("attachID = " + newAttachID);
// FIXME callback.call(param, newAttachID, data.length);
}
/**
- *
- * This has to stay in RHBugzillaPage because upstream doesn't have addAttachment
- * XML-RPC call yet.
+ *
+ * This has to stay in RHBugzillaPage because upstream doesn't have
+ * addAttachment XML-RPC call yet.
*/
function addAttachment(data, callback, param) {
var params = [];
if (!constantData.passwordState.passAvailable) {
- console.error("addAttachment : No password, no XML-RPC calls; sorry");
+ console
+ .error("addAttachment : No password, no XML-RPC calls; sorry");
return null;
}
params.push(getBugNo());
params.push({
- description: titleParsedAttachment,
- filename: "parsed-backtrace.txt",
- contenttype: "text/plain",
- data: window.btoa(data),
- nomail: true
+ description : titleParsedAttachment,
+ filename : "parsed-backtrace.txt",
+ contenttype : "text/plain",
+ data : window.btoa(data),
+ nomail : true
});
self.postMessage(new Message("MakeXMLRPCall", {
- url: constantData.XMLRPCData[window.location.hostname].url,
- login: getLogin(),
- method: "bugzilla.addAttachment",
- params: params,
- callRPC: "AddAttachmentCallback"
+ url : constantData.XMLRPCData[window.location.hostname].url,
+ login : getLogin(),
+ method : "bugzilla.addAttachment",
+ params : params,
+ callRPC : "AddAttachmentCallback"
}));
reqCounter++;
}
diff --git a/data/lib/addNewLinks.js b/data/lib/addNewLinks.js
index 02bd658..b8e7bd2 100644
--- a/data/lib/addNewLinks.js
+++ b/data/lib/addNewLinks.js
@@ -36,35 +36,42 @@
* ***** END LICENSE BLOCK ***** */
function addNewLinks(d) {
- var product = d.querySelector("#field_container_product option[selected]");
+ var product = d
+ .querySelector("#field_container_product option[selected]");
var component = d.querySelector("#component option[selected]");
if (product) {
var label = d.getElementById('field_container_product');
- var url = 'enter_bug.cgi?product=' + encodeURIComponent(product.value);
+ var url = 'enter_bug.cgi?product='
+ + encodeURIComponent(product.value);
if (label) {
- createDeadLink("file_new_bug_product", "new", label,
- url, [], "parens");
+ createDeadLink("file_new_bug_product", "new", label, url,
+ [], "parens");
}
}
if (product && component) {
var select = d.querySelector("select#component");
var label = select.parentNode;
- var url = 'enter_bug.cgi?product=' + encodeURIComponent(product.value) +
- '&component=' + encodeURIComponent(component.value);
+ var url = 'enter_bug.cgi?product='
+ + encodeURIComponent(product.value) + '&component='
+ + encodeURIComponent(component.value);
if (label) {
- var componentElement = document.getElementById("bz_component_input");
+ var componentElement = document
+ .getElementById("bz_component_input");
if (componentElement) { // We are in the Red Hat bugzilla
- // do we have components list visible?
- if (document.getElementById('bz_component_input').
- classList.contains("bz_default_hidden")) {
- label = document.getElementById("bz_component_edit_container");
- }
- } else {
+ // do we have components list visible?
+ if (document.getElementById('bz_component_input').classList
+ .contains("bz_default_hidden")) {
+ label = document
+ .getElementById("bz_component_edit_container");
+ }
+ }
+ else {
label = document.getElementById('component').parentNode;
}
- createDeadLink("file_new_bug_component", "new", label, url, [], "parens");
+ createDeadLink("file_new_bug_component", "new", label,
+ url, [], "parens");
}
}
}
diff --git a/data/lib/bug-page-mod.js b/data/lib/bug-page-mod.js
index 192900c..a7fb7e7 100644
--- a/data/lib/bug-page-mod.js
+++ b/data/lib/bug-page-mod.js
@@ -43,7 +43,8 @@ function tweakBugzilla(d) {
// Put the quicksearch text in the quicksearch boxes
quicksearchHandler(d);
- if (!d.getElementById("comments")) // don't process the mid-air collision pages
+ if (!d.getElementById("comments")) // don't process the mid-air collision
+ // pages
return;
// Make the comment box bigger ... TODO not necessary on RH BZ, but doesn't hurt
@@ -270,7 +271,8 @@ function tweakBugzilla(d) {
item = historyItems[++i].querySelectorAll("td")
ccPrefix = (trimContent(item[0]) == 'CC') ?
'<span class="bztw_cc bztw_historyitem">' : '<span class="bztw_historyitem">';
- // avoid showing a trailing semicolon if the previous entry wasn't a CC and this one is
+ // avoid showing a trailing semicolon if the previous entry
+ // wasn't a CC and this one is
var prefix = ccSuffix + ccPrefix;
// check to see if this is a flag setting
flagsFound = findFlag(item);
@@ -601,7 +603,8 @@ AttachmentFlagHandlerCtor.prototype = {
}
}
- // try to put the flag name and type part in a span which we will
+ // try to put the flag name and type part in a span
+ // which we will
// use in setupLinks to inject links into.
match = this._reLinkifyInterestingFlag.exec(previousText);
if (match) {
@@ -636,7 +639,8 @@ AttachmentFlagHandlerCtor.prototype = {
if (!(id in this._db)) {
this._db[id] = [];
}
- name = name.split('@')[0]; // convert the name to the fraction before the @
+ name = name.split('@')[0]; // convert the name to the fraction
+ // before the @
var added = this._parseData(name, trimContent(item[base + 2]));
for (var i = 0; i < added.length; ++i) {
var flag = added[i];
diff --git a/data/lib/bugzillaDOMFunctions.js b/data/lib/bugzillaDOMFunctions.js
index 8392b87..f58f0d9 100644
--- a/data/lib/bugzillaDOMFunctions.js
+++ b/data/lib/bugzillaDOMFunctions.js
@@ -4,13 +4,13 @@
/**
* Select option with given value on the <SELECT> element with given id.
- *
+ *
* Also execute change HTMLEvent, so that the form behaves accordingly.
- *
+ *
* @param id
* @param label
* @return none
- *
+ *
*/
function selectOption (id, label, fireEvent) {
if (!fireEvent) {
@@ -48,10 +48,12 @@ function selectOptionByLabel(id, label, fireEvent) {
/**
* Add object to the text box (comment box or status whiteboard)
- *
- * @param id String with the id of the element
- * @param stuff String/Array to be added to the comment box
- *
+ *
+ * @param id
+ * String with the id of the element
+ * @param stuff
+ * String/Array to be added to the comment box
+ *
* @return none
*/
function addStuffToTextBox (id, stuff) {
@@ -67,9 +69,11 @@ function addStuffToTextBox (id, stuff) {
/**
* Remove a keyword from the element if it is there
- *
- * @param id String with the id of the element
- * @param stuff String/Array with keyword(s) to be removed
+ *
+ * @param id
+ * String with the id of the element
+ * @param stuff
+ * String/Array with keyword(s) to be removed
*/
function removeStuffFromTextBox (id, stuff) {
var changedElement = document.getElementById(id);
@@ -78,9 +82,11 @@ function removeStuffFromTextBox (id, stuff) {
/**
* generalized hasKeyword ... search in the value of the box with given id
- *
- * @param id String with ID of the element we want to check
- * @param str String to be searched for
+ *
+ * @param id
+ * String with ID of the element we want to check
+ * @param str
+ * String to be searched for
* @return Boolean found?
*/
function idContainsWord (id, str) {
@@ -96,8 +102,9 @@ function idContainsWord (id, str) {
/**
* Check for the presence of a keyword
- *
- * @param str String with the keyword
+ *
+ * @param str
+ * String with the keyword
* @return Boolean
*/
function hasKeyword (str) {
@@ -106,11 +113,12 @@ function hasKeyword (str) {
/**
* Set the bug to NEEDINFO state
- *
+ *
* Working function.
+ *
* @return none
- * @todo TODO we may extend this to general setNeedinfo function
- * with parameter [reporter|assignee|general-email-address]
+ * @todo TODO we may extend this to general setNeedinfo function with parameter
+ * [reporter|assignee|general-email-address]
*/
function setNeedinfoReporter () {
clickMouse("needinfo");
@@ -118,7 +126,7 @@ function setNeedinfoReporter () {
}
/**
- *
+ *
*/
function getOwner () {
// TODO(maemo) doesn't work on maemo
@@ -127,9 +135,9 @@ function getOwner () {
}
/**
- * Return maintainer which is per default by bugzilla
- * (which is not necessarily the one who is default maintainer per component)
- *
+ * Return maintainer which is per default by bugzilla (which is not necessarily
+ * the one who is default maintainer per component)
+ *
* @return String with the maintainer's email address
*/
function getDefaultBugzillaMaintainer (component) {
@@ -139,11 +147,15 @@ function getDefaultBugzillaMaintainer (component) {
/**
* Generic function to add new button to the page. Actually copies new button
* from the old one (in order to have the same look-and-feel, etc.
- *
- * @param location Object around which the new button will be added
- * @param after Boolean before or after location ?
- * @param pkg String which package to take the command from
- * @param id String which command to take
+ *
+ * @param location
+ * Object around which the new button will be added
+ * @param after
+ * Boolean before or after location ?
+ * @param pkg
+ * String which package to take the command from
+ * @param id
+ * String which command to take
* @return none
*/
function createNewButton (location, after, cmdObj) {
@@ -195,7 +207,7 @@ function createNewButton (location, after, cmdObj) {
/**
* Get the current title of the bug
- *
+ *
* @return string
*/
function getSummary() {
@@ -204,7 +216,7 @@ function getSummary() {
/**
* Get the current title of the bug
- *
+ *
* @return string
*/
function getSeverity() {
@@ -213,7 +225,7 @@ function getSeverity() {
/**
* Get the current email of the reporter of the bug.
- *
+ *
* @return string
*/
function getReporter () {
@@ -222,7 +234,8 @@ function getReporter () {
if (!reporterElement) {
reporterElement = getOptionTableCell("bz_show_bug_column_1", "Reported", true);
}
- // Maemo calls the label "Reporter" and it doesn't have ids on table columns ... TODO(maemo)
+ // Maemo calls the label "Reporter" and it doesn't have ids on table columns
+ // ... TODO(maemo)
return parseMailto(reporterElement);
}
@@ -252,11 +265,10 @@ function commentsWalker (fce) {
/**
* collect the list of attachments in a structured format
- *
- * @return Array of arrays, one for each attachments;
- * each record has string name of the attachment, integer its id number,
- * string of MIME type, integer of size in kilobytes, and the whole
- * element itself
+ *
+ * @return Array of arrays, one for each attachments; each record has string
+ * name of the attachment, integer its id number, string of MIME type,
+ * integer of size in kilobytes, and the whole element itself
*/
function getAttachments () {
var outAtts = [];
@@ -270,7 +282,7 @@ function getAttachments () {
/**
* Get login of the currently logged-in user.
- *
+ *
* @return String with the login name of the currently logged-in user
*/
function getLogin () {
@@ -282,9 +294,10 @@ function getLogin () {
/**
* adds a person to the CC list, if it isn't already there
- *
- * @param who String with email address or "self" if the current user
- * of the bugzilla should be added
+ *
+ * @param who
+ * String with email address or "self" if the current user of the
+ * bugzilla should be added
*/
function addToCCList (who) {
if (!who) {
@@ -303,7 +316,7 @@ function addToCCList (who) {
/**
* a collect a list of emails on CC list
- *
+ *
* @return Array with email addresses as Strings.
*/
function getCCList () {
@@ -319,14 +332,16 @@ function getCCList () {
/**
* remove elements from the page based on their IDs
- *
- * @param doc Document object
- * @param target String/Array with ID(s)
- * @param remove Boolean indicating whether the node should be
- * actually removed or just hidden.
- * @return none
- * TODO remove parameter could be replaced by function which would
- * do actual activity.
+ *
+ * @param doc
+ * Document object
+ * @param target
+ * String/Array with ID(s)
+ * @param remove
+ * Boolean indicating whether the node should be actually removed or
+ * just hidden.
+ * @return none TODO remove parameter could be replaced by function which would
+ * do actual activity.
*/
function killNodes(doc, target, remove) {
var targetArr = target instanceof Array ? target : target.trim().split(/[,\s]+/);
@@ -343,7 +358,7 @@ function killNodes(doc, target, remove) {
/**
* Is this bug a RHEL bug?
- *
+ *
* @return Boolean true if it is a RHEL bug
*/
function isEnterprise() {
@@ -355,7 +370,7 @@ function isEnterprise() {
/**
* Find out whether the bug is needed an attention of bugZappers
- *
+ *
* @return Boolean whether the bug has been triaged or not
*/
function isTriaged() {
@@ -364,8 +379,9 @@ function isTriaged() {
/**
* Return string with the ID for the external_id SELECT for external bugzilla
- *
- * @param URLhostname String hostname of the external bugzilla
+ *
+ * @param URLhostname
+ * String hostname of the external bugzilla
* @return String with the string for the external_id SELECT
*/
function getBugzillaName(URLhostname, bzLabelNames) {
diff --git a/data/lib/bzpage.js b/data/lib/bzpage.js
index 3a832ea..9e65794 100644
--- a/data/lib/bzpage.js
+++ b/data/lib/bzpage.js
@@ -19,8 +19,8 @@ var constantData = {}; // This should be probably eliminated ASAP or
// or done by other means. TODO
var equivalentComponents = null;
/**
-* central handler processing messages from the main script.
-*/
+ * central handler processing messages from the main script.
+ */
onMessage = function onMessage(msg) {
console.log("onMessage - incoming : msg.cmd = " + msg.cmd);
switch (msg.cmd) {
@@ -53,15 +53,17 @@ onMessage = function onMessage(msg) {
};
/**
- * @param cmd Object with all commands to be executed
- *
- * PROBLEM: according to https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference\
- * /Statements/for...in there is no guaranteed order of execution of
- * commands (i.e., key, commentObj[key] pairs) in for..in cycle.
- * According to https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference\
- * /Operators/Special_Operators/delete_Operator#Cross-browser_issues it seems that
- * everywhere except of Internet Explorer this should work well, but waiting
- * impatiently when this bite us.
+ * @param cmd
+ * Object with all commands to be executed
+ *
+ * PROBLEM: according to
+ * https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference\
+ * /Statements/for...in there is no guaranteed order of execution of commands
+ * (i.e., key, commentObj[key] pairs) in for..in cycle. According to
+ * https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference\
+ * /Operators/Special_Operators/delete_Operator#Cross-browser_issues it seems
+ * that everywhere except of Internet Explorer this should work well, but
+ * waiting impatiently when this bite us.
*/
function executeCommand(cmdObj) {
for (var key in cmdObj) {
@@ -71,9 +73,11 @@ function executeCommand(cmdObj) {
/**
* Actual execution function
- *
- * @param cmdLabel String with the name of the command to be executed
- * @param cmdParams Object with the appropriate parameters for the command
+ *
+ * @param cmdLabel
+ * String with the name of the command to be executed
+ * @param cmdParams
+ * Object with the appropriate parameters for the command
*/
function centralCommandDispatch (cmdLabel, cmdParams) {
console.log("centralCommandDispatch : cmdLabel = " + cmdLabel);
@@ -180,10 +184,11 @@ function centralCommandDispatch (cmdLabel, cmdParams) {
/**
* Change assignee of the bug
- *
- * @param newAssignee String with the email address of new assigneeAElement
- * or 'default' if the component's default assignee should be used.
- * Value null clears "Reset Assignee to default for component" checkbox
+ *
+ * @param newAssignee
+ * String with the email address of new assigneeAElement or 'default'
+ * if the component's default assignee should be used. Value null
+ * clears "Reset Assignee to default for component" checkbox
* @return none
*/
function changeAssignee (newAssignee) {
@@ -223,11 +228,12 @@ function changeAssignee (newAssignee) {
/**
* Adds new option to the 'comment_action' scroll down box
- *
- * @param pkg String package name
- * @param cmd String with the name of the command
- * If the 'comment_action' scroll down box doesn't exist, this
- * function will set up new one.
+ *
+ * @param pkg
+ * String package name
+ * @param cmd
+ * String with the name of the command If the 'comment_action' scroll
+ * down box doesn't exist, this function will set up new one.
*/
function addToCommentsDropdown (cmdObj) {
var select = document.getElementById("comment_action");
@@ -302,7 +308,8 @@ function generateButtons (pkgs, kNodes) {
}
}
}
- // TODO This is weird in this place, but that's the place where all constantData etc.
+ // TODO This is weird in this place, but that's the place where all
+ // constantData etc.
// are finally defined and available.
if (RHBZinit) {
RHBZinit();
@@ -326,7 +333,7 @@ function setConfigurationButton () {
/**
* dd
- *
+ *
* @return Element with the href attribute containng the information
*/
function getOptionTableCell(tableId, label) {
@@ -349,12 +356,13 @@ function getOptionTableCell(tableId, label) {
/**
* Parse the row with the attachment
- *
- * @param DOM element to be parsed
+ *
+ * @param DOM
+ * element to be parsed
* @return array with string name of the attachment, integer its id number,
- * string of MIME type, integer of size in kilobytes, and the whole
- * element itself
- *
+ * string of MIME type, integer of size in kilobytes, and the whole
+ * element itself
+ *
* TODO error handling is missing ... it's bleee
*/
function parseAttachmentLine(inElem) {
@@ -399,7 +407,8 @@ function startup() {
// Prepare for query buttons
// element ID brElementPlace_location is later used in JSON files
// Stay with this add_comment element even if RH BZ upgrades, this seems
- // to be generally much more stable (even with other bugzillas, e.g. b.gnome.org)
+ // to be generally much more stable (even with other bugzillas, e.g.
+ // b.gnome.org)
// then some getElementById.
var commentArea = document.getElementsByName("add_comment")[0].parentNode;
if (commentArea) {
@@ -412,7 +421,8 @@ function startup() {
}
}
- // TODO Probably could be ignored ... used only once on line 973 of rhbzpage.js
+ // TODO Probably could be ignored ... used only once on line 973 of
+ // rhbzpage.js
// if (parseAbrtBacktraces && this.RE.Abrt.test(getSummary())) {
// title = document.getElementById("short_desc_nonedit_display").textContent;
diff --git a/data/lib/checkin-context.js b/data/lib/checkin-context.js
index 8ae482d..0ccec0c 100644
--- a/data/lib/checkin-context.js
+++ b/data/lib/checkin-context.js
@@ -1,11 +1,13 @@
self.on('click', function(node, data) {
- var message = document.getElementById("__bz_tw_checkin_comment");
+ var message = document
+ .getElementById("__bz_tw_checkin_comment");
self.postMessage(message.textContent);
});
self.on('context', function(node) {
if (!onBugzillaPage(document.URL))
return false;
- var message = document.getElementById("__bz_tw_checkin_comment");
+ var message = document
+ .getElementById("__bz_tw_checkin_comment");
return !!message;
});
diff --git a/data/lib/color.js b/data/lib/color.js
index 163071e..4d0c41f 100644
--- a/data/lib/color.js
+++ b/data/lib/color.js
@@ -51,10 +51,13 @@ Color.prototype.toString = function() {
* Converts an RGB color value to HSL. Conversion formula adapted from
* http://en.wikipedia.org/wiki/HSL_color_space. Assumes r, g, and b are
* contained in the set [0, 255] and returns h, s, and l in the set [0, 1].4343
- *
- * @param Number r The red color value
- * @param Number g The green color value
- * @param Number b The blue color value
+ *
+ * @param Number
+ * r The red color value
+ * @param Number
+ * g The green color value
+ * @param Number
+ * b The blue color value
* @return Array The HSL representation
*/
Color.prototype.hsl = function() {
@@ -84,17 +87,22 @@ Color.prototype.hsl = function() {
h /= 6;
}
- return [ h, s, l ];
+ return [
+ h, s, l
+ ];
};
/**
* Converts an HSL color value to RGB. Conversion formula adapted from
* http://en.wikipedia.org/wiki/HSL_color_space. Assumes h, s, and l are
* contained in the set [0, 1] and returns r, g, and b in the set [0, 255].
- *
- * @param Number h The hue
- * @param Number s The saturation
- * @param Number l The lightness
+ *
+ * @param Number
+ * h The hue
+ * @param Number
+ * s The saturation
+ * @param Number
+ * l The lightness
* @return Array The RGB representation
*/
Color.prototype.hslToRgb = function(h, s, l) {
@@ -130,17 +138,22 @@ Color.prototype.hslToRgb = function(h, s, l) {
b = hue2rgb(p, q, h - 1 / 3);
}
- return [ r * 255, g * 255, b * 255 ];
+ return [
+ r * 255, g * 255, b * 255
+ ];
};
/**
* Converts an RGB color value to HSV. Conversion formula adapted from
* http://en.wikipedia.org/wiki/HSV_color_space. Assumes r, g, and b are
* contained in the set [0, 255] and returns h, s, and v in the set [0, 1].
- *
- * @param Number r The red color value
- * @param Number g The green color value
- * @param Number b The blue color value
+ *
+ * @param Number
+ * r The red color value
+ * @param Number
+ * g The green color value
+ * @param Number
+ * b The blue color value
* @return Array The HSV representation
*/
Color.prototype.hsv = function() {
@@ -171,17 +184,22 @@ Color.prototype.hsv = function() {
h /= 6;
}
- return [ h, s, v ];
+ return [
+ h, s, v
+ ];
};
/**
* Converts an HSV color value to RGB. Conversion formula adapted from
* http://en.wikipedia.org/wiki/HSV_color_space. Assumes h, s, and v are
* contained in the set [0, 1] and returns r, g, and b in the set [0, 255].
- *
- * @param Number h The hue
- * @param Number s The saturation
- * @param Number v The value
+ *
+ * @param Number
+ * h The hue
+ * @param Number
+ * s The saturation
+ * @param Number
+ * v The value
* @return Array The RGB representation
*/
Color.prototype.hsvToRgb = function(h, s, v) {
@@ -226,7 +244,9 @@ Color.prototype.hsvToRgb = function(h, s, v) {
break;
}
- return [ r * 255, g * 255, b * 255 ];
+ return [
+ r * 255, g * 255, b * 255
+ ];
};
/**
diff --git a/data/lib/fixingAttMIME.js b/data/lib/fixingAttMIME.js
index a016fe6..365cfae 100644
--- a/data/lib/fixingAttMIME.js
+++ b/data/lib/fixingAttMIME.js
@@ -5,17 +5,15 @@ var reqCounter = 0; // TODO should be probably a dict indexed by called method
/**
* Callback function for the XMLRPC request
- *
- * @param ret Object with xmlhttprequest response with attributes:
- * + status -- int return code
- * + statusText
- * + responseHeaders
- * + responseText
+ *
+ * @param ret
+ * Object with xmlhttprequest response with attributes: + status -- int
+ * return code + statusText + responseHeaders + responseText
*/
function XMLRPCcallback() {
reqCounter--;
if (reqCounter <= 0) {
- setTimeout(function () {
+ setTimeout(function() {
window.location.reload(true);
}, 1000);
}
@@ -24,24 +22,27 @@ function XMLRPCcallback() {
/**
* The worker function -- call XMLRPC to fix MIME type of the particular
* attachment
- *
- * @param id Integer with the attachment id to be fixed
- * @param type String with the new MIME type, optional defaults to "text/plain"
- * @param email Boolean whether email should be sent to appropriate person;
- * option, defaults to false
- *
+ *
+ * @param id
+ * Integer with the attachment id to be fixed
+ * @param type
+ * String with the new MIME type, optional defaults to "text/plain"
+ * @param email
+ * Boolean whether email should be sent to appropriate person; option,
+ * defaults to false
+ *
* updateAttachMimeType($data_ref, $username, $password)
- *
+ *
* Update the attachment mime type of an attachment. The first argument is a
* data hash containing information on the new MIME type and the attachment id
* that you want to act on.
- *
+ *
* $data_ref = { "attach_id" => "<Attachment ID>", # Attachment ID to perform
* MIME type change on. "mime_type" => "<New MIME Type Value>", # Legal MIME
* type value that you want to change the attachment to. "nomail" => 0, #
* OPTIONAL Flag that is either 1 or 0 if you want email to be sent or not for
* this change };
- *
+ *
*/
function fixAttachById(id, XMLRPCURL, type, email) {
var params = [];
@@ -63,18 +64,18 @@ function fixAttachById(id, XMLRPCURL, type, email) {
});
self.postMessage(new Message("MakeXMLRPCall", {
- url: XMLRPCURL,
- login: getLogin(),
- method: "bugzilla.updateAttachMimeType",
- params: params,
- callRPC: "FixAttachmentMIMECallback"
+ url : XMLRPCURL,
+ login : getLogin(),
+ method : "bugzilla.updateAttachMimeType",
+ params : params,
+ callRPC : "FixAttachmentMIMECallback"
}));
reqCounter++;
}
/**
* Add a link to the bad attachment for fixing it.
- *
+ *
* @param
* <TR> DOM jQuery element with a bad attachment
* @return none
@@ -82,6 +83,8 @@ function fixAttachById(id, XMLRPCURL, type, email) {
function addTextLink(row, xmlRpcUrl) {
var elemS = row[4].getElementsByTagName("td");
var elem = elemS[elemS.length - 1];
- createDeadLink("addFix2TextLink", "text", elem,
- fixAttachById, [row[1], xmlRpcUrl], "br");
+ createDeadLink("addFix2TextLink", "text", elem, fixAttachById,
+ [
+ row[1], xmlRpcUrl
+ ], "br");
}
diff --git a/data/lib/jumpNextBug.js b/data/lib/jumpNextBug.js
index 348c776..b777fe8 100644
--- a/data/lib/jumpNextBug.js
+++ b/data/lib/jumpNextBug.js
@@ -2,16 +2,53 @@
// http://www.opensource.org/licenses/mit-license.php
"use strict";
-var nextElement = {};
-var nextRE = new RegExp("Next");
+(function createRelationElements() {
+ var relation = {};
+ var linkLabels = [
+ "First", "Last", "Prev", "Next"
+ ];
+ var labelToRelation = {
+ "First" : {
+ rel : "start"
+ },
+ "Last" : {
+ rel : "last"
+ },
+ "Prev" : {
+ rel : "prev"
+ },
+ "Next" : {
+ rel : "next"
+ }
+ };
-var aNavigElements = document.querySelectorAll("#bugzilla-body .navigation a");
-var filteredElements = Array.filter(aNavigElements, function(elem) {
- return nextRE.test(elem.textContent);
-});
-console.log("filteredElements.length = " + filteredElements.length);
-if (filteredElements.length > 0) {
- nextElement = filteredElements[0];
- nextElement.setAttribute("accesskey", "n");
- nextElement.innerHTML = "<u>N</u>ext";
-}
+ function createLinkRel(rel, href) {
+ var newLinkElement = document.createElement("link");
+ newLinkElement.setAttribute("rel", rel);
+ newLinkElement.setAttribute("href", href);
+ document.getElementsByTagName("head")[0]
+ .appendChild(newLinkElement);
+ }
+
+ var aNavigElements = document
+ .querySelectorAll("#bugzilla-body .navigation a");
+ Array.forEach(aNavigElements, function(elem) {
+ var labelText = elem.textContent.trim();
+ if (isInList(labelText, linkLabels)) {
+ labelToRelation[labelText].href = elem
+ .getAttribute("href");
+ }
+ ;
+ });
+ console.myDebug("labelToRelation = "
+ + labelToRelation.toSource());
+
+ for ( var key in labelToRelation) {
+ if (labelToRelation.hasOwnProperty(key)) {
+ relation = labelToRelation[key];
+ if (relation.href) {
+ createLinkRel(relation.rel, relation.href);
+ }
+ }
+ }
+})();
diff --git a/data/lib/logging-front.js b/data/lib/logging-front.js
index b8343a4..2f85a51 100644
--- a/data/lib/logging-front.js
+++ b/data/lib/logging-front.js
@@ -12,8 +12,7 @@ function addLogRecord() {
rec.date = new Date();
rec.url = document.location.toString();
rec.title = document.title;
- var comment = window.prompt(
- "Enter comments for this comment");
+ var comment = window.prompt("Enter comments for this comment");
if (comment !== null) {
comment = comment.trim();
if (comment.length > 0) {
@@ -22,8 +21,7 @@ function addLogRecord() {
var dateStr = getISODate(rec.date);
var urlStr = window.location.hostname;
var bugNo = getBugNoFromURL(window.location.href);
- rec.key = dateStr + "+" +
- urlStr + "+" + bugNo;
+ rec.key = dateStr + "+" + urlStr + "+" + bugNo;
self.postMessage(new Message("AddLogRecord", rec));
}
return rec;
@@ -33,52 +31,50 @@ function addLogRecord() {
/**
*/
-function setUpLogging () {
+function setUpLogging() {
// Protection against double-call
if (document.getElementById("generateTSButton")) {
- return ;
+ return;
}
// For adding additional buttons to the top toolbar
- var additionalButtons = document.querySelector("#bugzilla-body *.related_actions");
+ var additionalButtons = document
+ .querySelector("#bugzilla-body *.related_actions");
var that = this;
// logging all submits for timesheet
if (!submitHandlerInstalled) {
- document.forms.namedItem("changeform").addEventListener("submit",function (evt) {
- if (addLogRecord() === null) {
- evt.stopPropagation();
- evt.preventDefault();
- }
- }, false);
+ document.forms.namedItem("changeform").addEventListener(
+ "submit", function(evt) {
+ if (addLogRecord() === null) {
+ evt.stopPropagation();
+ evt.preventDefault();
+ }
+ }, false);
submitHandlerInstalled = true;
}
// (id, text, parent, callback, params, before, covered, accesskey)
- createDeadLink("generateTSButton", "Generate TS", additionalButtons,
- function(evt) {
- self.postMessage(new Message("GenerateTS"));
- }, [], "dash", "li");
+ createDeadLink("generateTSButton", "Generate TS",
+ additionalButtons, function(evt) {
+ self.postMessage(new Message("GenerateTS"));
+ }, [], "dash", "li");
createDeadLink("clearLogs", "Clear TS", additionalButtons,
- function(evt) {
- self.postMessage(new Message("ClearTS"));
- }, [], "dash", "li");
+ function(evt) {
+ self.postMessage(new Message("ClearTS"));
+ }, [], "dash", "li");
- createDeadLink("importTSButton", "Import TS", additionalButtons,
- function(evt) {
- self.postMessage(new Message("ImportTS"));
- }, [], "dash", "li");
+ createDeadLink("importTSButton", "Import TS",
+ additionalButtons, function(evt) {
+ self.postMessage(new Message("ImportTS"));
+ }, [], "dash", "li");
- /* TODO
- var clearLogAElem = document.getElementById("clearLogs");
- if (this.log.isEmpty()) {
- clearLogAElem.style.color = this.log.EmptyLogsColor;
- clearLogAElem.style.fontWeight = "normal";
- }
- else {
- clearLogAElem.style.color = this.log.FullLogsColor;
- clearLogAElem.style.fontWeight = "bolder";
- }
- */
+ /*
+ * TODO var clearLogAElem = document.getElementById("clearLogs"); if
+ * (this.log.isEmpty()) { clearLogAElem.style.color = this.log.EmptyLogsColor;
+ * clearLogAElem.style.fontWeight = "normal"; } else {
+ * clearLogAElem.style.color = this.log.FullLogsColor;
+ * clearLogAElem.style.fontWeight = "bolder"; }
+ */
}
diff --git a/data/lib/makeBacktraceAttachment.js b/data/lib/makeBacktraceAttachment.js
index a6b6ab0..6011c06 100644
--- a/data/lib/makeBacktraceAttachment.js
+++ b/data/lib/makeBacktraceAttachment.js
@@ -3,69 +3,68 @@
var titleParsedAttachment = "Part of the thread where crash happened";
/**
- *
+ *
*/
function pasteBacktraceInComments(atts) {
/*
- Let's comment it out, and we'll see if anything breaks.
- TODO This paragraph looks suspicous ... what is it?
- Does it belong to this function?
- var notedLabel = document.querySelector("label[for='newcc']");
- while (notedLabel.firstChild) {
- var node = notedLabel.removeChild(notedLabel.firstChild);
- notedLabel.parentNode.insertBefore(node, notedLabel);
- }
- notedLabel.parentNode.removeChild(notedLabel);
- */
+ * Let's comment it out, and we'll see if anything breaks. TODO This paragraph
+ * looks suspicous ... what is it? Does it belong to this function? var
+ * notedLabel = document.querySelector("label[for='newcc']"); while
+ * (notedLabel.firstChild) { var node =
+ * notedLabel.removeChild(notedLabel.firstChild);
+ * notedLabel.parentNode.insertBefore(node, notedLabel); }
+ * notedLabel.parentNode.removeChild(notedLabel);
+ */
// FIXME BROKEN and its depending functions are even more broken
return null;
- var abrtQueryURL = "https://bugzilla.redhat.com/buglist.cgi?" +
- "cmdtype=dorem&remaction=run&namedcmd=all%20NEW%20abrt%20crashes&"+
- "sharer_id=74116";
+ var abrtQueryURL = "https://bugzilla.redhat.com/buglist.cgi?"
+ + "cmdtype=dorem&remaction=run&namedcmd=all%20NEW%20abrt%20crashes&"
+ + "sharer_id=74116";
var mainTitle = document
.getElementsByClassName("bz_alias_short_desc_container")[0];
- createDeadLink ("callAbrtQuery_link",
- "Abrt bugs", mainTitle, abrtQueryURL, [], false, null, "a");
+ createDeadLink("callAbrtQuery_link", "Abrt bugs", mainTitle,
+ abrtQueryURL, [], false, null, "a");
if (idContainsWord("cf_devel_whiteboard", 'btparsed')) {
addStuffToTextBox('status_whiteboard', 'btparsed');
}
- if (!(isTriaged() || idContainsWord("status_whiteboard",
- 'btparsed') || (atts.length > 0))) {
- var btAttachments = atts
- .filter(function(att) {
- return (/File: backtrace/.test(att[0]));
- });
+ if (!(isTriaged()
+ || idContainsWord("status_whiteboard", 'btparsed') || (atts.length > 0))) {
+ var btAttachments = atts.filter(function(att) {
+ return (/File: backtrace/.test(att[0]));
+ });
// TODO we need to go through all backtrace attachments, but
// just the first one will do for now, we would need to do async
//
- btAttachments.forEach(function(x) {
- var attURL = "https://bugzilla.redhat.com/attachment.cgi?id="
- + x[1];
- if ((!btSnippet) && // ???? FIXME
- (!idContainsWord("status_whiteboard", 'btparsed'))) {
- Request({
- url: attURL,
- onComplete: function(response) {
- if (response.status == 200) {
- btSnippet = parseBacktrace(response.text);
- if (btSnippet) {
- addCheckShowLink(x,btSnippet);
+ btAttachments
+ .forEach(
+ function(x) {
+ var attURL = "https://bugzilla.redhat.com/attachment.cgi?id="
+ + x[1];
+ if ((!btSnippet) && // ???? FIXME
+ (!idContainsWord("status_whiteboard", 'btparsed'))) {
+ Request({
+ url : attURL,
+ onComplete : function(response) {
+ if (response.status == 200) {
+ btSnippet = parseBacktrace(response.text);
+ if (btSnippet) {
+ addCheckShowLink(x, btSnippet);
+ }
+ }
+ }
+ }).get();
}
- }
- }
- }).get();
- }
- }, this);
+ }, this);
}
// Add "show BT" links
if (parsedAttachments.length > 0) {
- this.parsedAttachments.forEach(function (att) {
+ this.parsedAttachments.forEach(function(att) {
addShowParsedBTLink(att);
});
}
@@ -73,85 +72,95 @@ function pasteBacktraceInComments(atts) {
/**
* Open new window with the content of the attachment.
- *
- * @param id Number of the attachment id
+ *
+ * @param id
+ * Number of the attachment id
* @return none
*/
function showAttachment(id) {
- self.postMessage(new Message("OpenURLinPanel",
- "https://" + window.location.hostname + "/attachment.cgi?id=" + id));
+ self.postMessage(new Message("OpenURLinPanel", "https://"
+ + window.location.hostname + "/attachment.cgi?id=" + id));
}
/**
* add a link opening a window with the parsed backtrace
- *
- * @param att Attachment object
+ *
+ * @param att
+ * Attachment object
*/
function addShowParsedBTLink(att) {
var elem = att[4].querySelector("td:last-of-type");
- createDeadLink("showParsedBacktraceWindow-" + att[1], "showBT",
- elem, showAttachment, att[1], true);
+ createDeadLink("showParsedBacktraceWindow-" + att[1],
+ "showBT", elem, showAttachment, att[1], true);
}
/**
* Unfinished ... see above FIXME BROKEN AND DOESN'T WORK
*/
-function addNewAttachmentRow(origAtt,
- newAttId, newAttSize) {
+function addNewAttachmentRow(origAtt, newAttId, newAttSize) {
var that = this;
- var oldAddBTLink = document.getElementById("attachBacktraceActivator");
+ var oldAddBTLink = document
+ .getElementById("attachBacktraceActivator");
oldAddBTLink.parentNode.removeChild(oldAddBTLink);
var newTRElem = origAtt[4].cloneNode(true);
// fix number of the attachment
- Array.forEach(newTRElem.getElementsByTagName("a"), function (aEl) {
- aEl.setAttribute("href",
- aEl.getAttribute("href").replace(origAtt[1], newAttId));
+ Array.forEach(newTRElem.getElementsByTagName("a"), function(
+ aEl) {
+ aEl.setAttribute("href", aEl.getAttribute("href").replace(
+ origAtt[1], newAttId));
});
var aElements = newTRElem.getElementsByTagName("a");
- aElements[0].setAttribute("name","parsed-backtrace.txt");
+ aElements[0].setAttribute("name", "parsed-backtrace.txt");
aElements[0].getElementsByTagName("b")[0].textContent = titleParsedAttachment;
- var sizeSpan = newTRElem.getElementsByClassName("bz_attach_extra_info")[0];
- sizeSpan.textContent = "(" + (newAttSize / 1024).toFixed(2) + " KB, text/plain)";
+ var sizeSpan = newTRElem
+ .getElementsByClassName("bz_attach_extra_info")[0];
+ sizeSpan.textContent = "(" + (newAttSize / 1024).toFixed(2)
+ + " KB, text/plain)";
- // aElements[1].textContent = new Date().toString(); TODO we should add eventually, but not pressing
+ // aElements[1].textContent = new Date().toString(); TODO we should add
+ // eventually, but not pressing
var vcardSpan = newTRElem.getElementsByClassName("vcard")[0];
if (vcardSpan !== undefined) {
var vcardSpanClassList = vcardSpan.classList;
- if (/@redhat\.com/.test(this.login) && !vcardSpanClassList.contains("redhat_user")) {
+ if (/@redhat\.com/.test(this.login)
+ && !vcardSpanClassList.contains("redhat_user")) {
vcardSpanClassList.add("redhat_user");
}
var vcardAElem = vcardSpan.getElementsByTagName("a")[0];
vcardAElem.setAttribute("title", this.login);
vcardAElem.setAttribute("href", "mailto:" + this.login);
vcardAElem.className = "email";
- vcardAElem.innerHTML="<span class='fn'>" + this.login + "</span>";
+ vcardAElem.innerHTML = "<span class='fn'>" + this.login
+ + "</span>";
}
var elem = newTRElem.querySelector("td:last-of-type");
this.createDeadLink("showBacktrace", "show BT", elem,
- this.showAttachment, newAttId, false);
+ this.showAttachment, newAttId, false);
- origAtt[4].parentNode.insertBefore(newTRElem, origAtt[4].nextSibling);
+ origAtt[4].parentNode.insertBefore(newTRElem,
+ origAtt[4].nextSibling);
}
/**
* Add a link to create a new attachment with a parsed backtrace
- *
- * @param oldAtt Object with an attachment row
- * @param snippet String with parsed backtrace
+ *
+ * @param oldAtt
+ * Object with an attachment row
+ * @param snippet
+ * String with parsed backtrace
* @return none
*/
function addCheckShowLink(oldAtt, snippet) {
var elem = oldAtt[4].querySelector("td:last-of-type");
-/*
- createDeadLink("attachBacktraceActivator", "add parsed BT", elem, function(x) {
- // pass function and parameters as two separate parameters, the function to be called from
- // addAttachment
- addAttachment(snippet, addNewAttachmentRow, oldAtt);
- }, [], true);
-*/
+ /*
+ * createDeadLink("attachBacktraceActivator", "add parsed BT", elem,
+ * function(x) { // pass function and parameters as two separate parameters,
+ * the function to be called from // addAttachment addAttachment(snippet,
+ * addNewAttachmentRow, oldAtt); }, [], true);
+ */
}
diff --git a/data/lib/otherButtons.js b/data/lib/otherButtons.js
index 66b5a9b..ab8ec35 100644
--- a/data/lib/otherButtons.js
+++ b/data/lib/otherButtons.js
@@ -4,9 +4,9 @@
/**
* Set background color of all comments made by reporter in ReporterColor color
- *
+ *
*/
-function checkComments () {
+function checkComments() {
var reporter = getReporter();
commentsWalker(function(x) {
var email = parseMailto(x.getElementsByClassName("vcard")[0]
@@ -17,39 +17,39 @@ function checkComments () {
});
}
-function collectComments () {
+function collectComments() {
var outStr = "";
commentsWalker(function(x) {
- outStr += x.getElementsByTagName("pre")[0].textContent + "\n";
+ outStr += x.getElementsByTagName("pre")[0].textContent
+ + "\n";
});
return outStr.trim();
}
/**
* Find default assignee based on the current component
- *
- * @return String what would be a default assignee if
- * we haven't set it up.
+ *
+ * @return String what would be a default assignee if we haven't set it up.
*/
function getDefaultAssignee() {
return filterByRegexp(constantData.defaultAssignee,
- getComponent());
+ getComponent());
}
/**
* Set default assignee
- *
- * @return none
- * sets this.defaultAssignee property according to defaultAssignee list
+ *
+ * @return none sets this.defaultAssignee property according to defaultAssignee
+ * list
*/
function setDefaultAssignee() {
var defAss = getDefaultAssignee();
// Add setting default assignee
if (defAss && (defAss !== getOwner())) {
- createNewButton("bz_assignee_edit_container",true, {
- "name": "Def. Assignee",
- "assignee": "default"
+ createNewButton("bz_assignee_edit_container", true, {
+ "name" : "Def. Assignee",
+ "assignee" : "default"
});
}
}
@@ -67,7 +67,7 @@ function markBugTriaged() {
alert("This won't do! Specify some severity!");
}
else {
- addStuffToTextBox("keywords","Triaged");
+ addStuffToTextBox("keywords", "Triaged");
}
}
@@ -78,12 +78,13 @@ function addingEmbelishments(list) {
var maintCCAddr = "";
if (constantData.CCmaintainer) {
maintCCAddr = filterByRegexp(constantData.CCmaintainer,
- getComponent())[0]; // filterByRegexp returns array, not string
+ getComponent())[0]; // filterByRegexp returns array, not string
}
// we should make visible whether maintCCAddr is in CCList
if (maintCCAddr && isInList(maintCCAddr, getCCList())) {
- var ccEditBoxElem = document.getElementById("cc_edit_area_showhide");
+ var ccEditBoxElem = document
+ .getElementById("cc_edit_area_showhide");
ccEditBoxElem.style.color = "navy";
ccEditBoxElem.style.fontWeight = "bolder";
ccEditBoxElem.style.textDecoration = "underline";
@@ -93,8 +94,8 @@ function addingEmbelishments(list) {
if (config.signature && config.signature.length > 0) {
var signaturesCounter = 0;
var signatureFedoraString = config.signature;
- document.forms.namedItem("changeform").addEventListener("submit",
- function(aEvt) {
+ document.forms.namedItem("changeform").addEventListener(
+ "submit", function(aEvt) {
if (signaturesCounter < 1) {
addStuffToTextBox("comment", signatureFedoraString);
signaturesCounter += 1;
@@ -105,19 +106,19 @@ function addingEmbelishments(list) {
// set default assignee on change of the component
var compElement = document.getElementById("component");
if (compElement && (compElement.options)) {
- document.getElementById("component").addEventListener("change",
- function() {
+ document.getElementById("component").addEventListener(
+ "change", function() {
changeAssignee("default");
}, false);
}
// TODO Get compiz bugs as well
- if ((constantData.chipNames) &&
- (list[0]) &&
- (!FillMagicDoneRE.test(getSummary())) &&
- (maintCCAddr === "xgl-maint@redhat.com")) {
+ if ((constantData.chipNames) && (list[0])
+ && (!FillMagicDoneRE.test(getSummary()))
+ && (maintCCAddr === "xgl-maint@redhat.com")) {
// Add find chip magic button
- var whiteboard_string = document.getElementById("status_whiteboard").value;
+ var whiteboard_string = document
+ .getElementById("status_whiteboard").value;
if (!/card_/.test(whiteboard_string)) {
fillInChipMagic(list[0][1]);
}
@@ -126,10 +127,13 @@ function addingEmbelishments(list) {
/**
* Set branding colours to easily distinguish between Fedora and RHEL bugs
- *
- * @param brand String with product of the current bug
- * @param version String with the version of the bug
- * @param its String with the IsueTracker numbers
+ *
+ * @param brand
+ * String with product of the current bug
+ * @param version
+ * String with the version of the bug
+ * @param its
+ * String with the IsueTracker numbers
* @return none
*/
function setBranding(xLogAtts) {
@@ -147,8 +151,8 @@ function setBranding(xLogAtts) {
brandColor = RHColor;
}
}
- else if (new RegExp("Fedora").test(document.
- getElementById("product").value)) {
+ else if (new RegExp("Fedora").test(document
+ .getElementById("product").value)) {
if (document.getElementById("version").value === "rawhide") {
brandColor = RawhideColor;
}
@@ -161,7 +165,8 @@ function setBranding(xLogAtts) {
document.getElementsByTagName("body")[0].style.background = brandColor
.toString()
+ " none";
- document.getElementById("titles").style.background = brandColor.toString()
+ document.getElementById("titles").style.background = brandColor
+ .toString()
+ " none";
// Remove "Bug" from the title of the bug page, so we have more space with
@@ -169,7 +174,8 @@ function setBranding(xLogAtts) {
var titleElem = document.getElementsByTagName("title")[0];
titleElem.textContent = titleElem.textContent.slice(4);
- var bodyTitleParent = document.getElementById("summary_alias_container").parentNode;
+ var bodyTitleParent = document
+ .getElementById("summary_alias_container").parentNode;
var bodyTitleElem = bodyTitleParent.getElementsByTagName("b")[0];
bodyTitleElem.textContent = bodyTitleElem.textContent.slice(4);
@@ -177,7 +183,8 @@ function setBranding(xLogAtts) {
// for security bugs.
if (hasKeyword("Security")) {
document.getElementById("bugzilla-body").style.background = SalmonPink
- .toString() + ' none';
+ .toString()
+ + ' none';
}
// Make it visible whether the bug has been triaged
@@ -194,6 +201,6 @@ function setBranding(xLogAtts) {
.getElementById("bz_component_edit_container"))) {
compElems.style.background = "red none";
}
-
+
addingEmbelishments(xLogAtts);
}
diff --git a/data/lib/preprocessDuplicates.js b/data/lib/preprocessDuplicates.js
index 44ea5ca..d312fb9 100644
--- a/data/lib/preprocessDuplicates.js
+++ b/data/lib/preprocessDuplicates.js
@@ -36,85 +36,97 @@
* ***** END LICENSE BLOCK ***** */
function preprocessDuplicateMarkers(mainDoc, histDoc) {
- var comments = mainDoc.querySelectorAll(".bz_comment");
- var reDuplicate = /^\s*\*\*\*\s+Bug\s+(\d+)\s+has\s+been\s+marked\s+as\s+a\s+duplicate\s+of\s+this\s+bug.\s+\*\*\*\s*$/i;
- var row = 0;
- var rows = histDoc.querySelectorAll("#bugzilla-body tr");
- for (var i = 1 /* comment 0 can never be a duplicate marker */;
- i < comments.length; ++i) {
- var textHolder = comments[i].querySelector(".bz_comment_text");
- var match = reDuplicate.exec(trimContent(textHolder));
- if (match) {
- // construct the table row to be injected in histDoc
- var bugID = match[1];
- var email = comments[i].querySelector(".bz_comment_user .email")
- .href
- .substr(7);
- var link = textHolder.querySelector("a");
- var title = link.title;
- var time = trimContent(comments[i].querySelector(".bz_comment_time"));
- var what = 'Duplicate';
- var removed = '';
- var number = trimContent(comments[i].querySelector(".bz_comment_number")).
- replace(/[^\d]+/g, '');
- var class_ = '';
- if (/bz_closed/i.test(link.className + " " + link.parentNode.className)) {
- class_ += 'bz_closed ';
- }
- if (link.parentNode.tagName.toLowerCase() == 'i') {
- class_ += 'bztw_unconfirmed ';
- }
- var added = '<a href="show_bug.cgi?id=' + bugID + '" title="' +
- htmlEncode(title) + '" name="c' + number + '" class="' + class_ +
- '">' + bugID + '</a>';
+ var comments = mainDoc.querySelectorAll(".bz_comment");
+ var reDuplicate = /^\s*\*\*\*\s+Bug\s+(\d+)\s+has\s+been\s+marked\s+as\s+a\s+duplicate\s+of\s+this\s+bug.\s+\*\*\*\s*$/i;
+ var row = 0;
+ var rows = histDoc.querySelectorAll("#bugzilla-body tr");
+ for ( var i = 1 /* comment 0 can never be a duplicate marker */; i < comments.length; ++i) {
+ var textHolder = comments[i]
+ .querySelector(".bz_comment_text");
+ var match = reDuplicate.exec(trimContent(textHolder));
+ if (match) {
+ // construct the table row to be injected in histDoc
+ var bugID = match[1];
+ var email = comments[i]
+ .querySelector(".bz_comment_user .email").href
+ .substr(7);
+ var link = textHolder.querySelector("a");
+ var title = link.title;
+ var time = trimContent(comments[i]
+ .querySelector(".bz_comment_time"));
+ var what = 'Duplicate';
+ var removed = '';
+ var number = trimContent(
+ comments[i].querySelector(".bz_comment_number"))
+ .replace(/[^\d]+/g, '');
+ var class_ = '';
+ if (/bz_closed/i.test(link.className + " "
+ + link.parentNode.className)) {
+ class_ += 'bz_closed ';
+ }
+ if (link.parentNode.tagName.toLowerCase() == 'i') {
+ class_ += 'bztw_unconfirmed ';
+ }
+ var added = '<a href="show_bug.cgi?id=' + bugID
+ + '" title="' + htmlEncode(title) + '" name="c'
+ + number + '" class="' + class_ + '">' + bugID
+ + '</a>';
- // inject the table row
- var reachedEnd = false;
- for (; row < rows.length; ++row) {
- var cells = rows[row].querySelectorAll("td");
- if (cells.length != 5)
- continue;
- if (time > trimContent(cells[1])) {
- if (row < rows.length - 1) {
- continue;
- } else {
- reachedEnd = true;
- }
- }
- if (time == trimContent(cells[1])) {
- cells[0].rowSpan++;
- cells[1].rowSpan++;
- var rowContents = [what, removed, added];
- var tr = histDoc.createElement("tr");
- rowContents.forEach(function (cellContents) {
- var td = histDoc.createElement("td");
- td.innerHTML = cellContents;
- tr.appendChild(td);
- });
- if (row != rows.length - 1) {
- rows[row].parentNode.insertBefore(tr, rows[row+1]);
- } else {
- rows[row].parentNode.appendChild(tr);
- }
- } else {
- var rowContents = [email, time, what, removed, added];
- var tr = histDoc.createElement("tr");
- rowContents.forEach(function (cellContents) {
- var td = histDoc.createElement("td");
- td.innerHTML = cellContents;
- tr.appendChild(td);
- });
- if (reachedEnd) {
- rows[row].parentNode.appendChild(tr);
- } else {
- rows[row].parentNode.insertBefore(tr, rows[row]);
- }
- }
- break;
- }
-
- // remove the comment from the main doc
- comments[i].parentNode.removeChild(comments[i]);
+ // inject the table row
+ var reachedEnd = false;
+ for (; row < rows.length; ++row) {
+ var cells = rows[row].querySelectorAll("td");
+ if (cells.length != 5)
+ continue;
+ if (time > trimContent(cells[1])) {
+ if (row < rows.length - 1) {
+ continue;
+ }
+ else {
+ reachedEnd = true;
+ }
+ }
+ if (time == trimContent(cells[1])) {
+ cells[0].rowSpan++;
+ cells[1].rowSpan++;
+ var rowContents = [
+ what, removed, added
+ ];
+ var tr = histDoc.createElement("tr");
+ rowContents.forEach(function(cellContents) {
+ var td = histDoc.createElement("td");
+ td.innerHTML = cellContents;
+ tr.appendChild(td);
+ });
+ if (row != rows.length - 1) {
+ rows[row].parentNode.insertBefore(tr, rows[row + 1]);
+ }
+ else {
+ rows[row].parentNode.appendChild(tr);
+ }
}
+ else {
+ var rowContents = [
+ email, time, what, removed, added
+ ];
+ var tr = histDoc.createElement("tr");
+ rowContents.forEach(function(cellContents) {
+ var td = histDoc.createElement("td");
+ td.innerHTML = cellContents;
+ tr.appendChild(td);
+ });
+ if (reachedEnd) {
+ rows[row].parentNode.appendChild(tr);
+ }
+ else {
+ rows[row].parentNode.insertBefore(tr, rows[row]);
+ }
+ }
+ break;
+ }
+
+ // remove the comment from the main doc
+ comments[i].parentNode.removeChild(comments[i]);
}
+ }
}
diff --git a/data/lib/queries.js b/data/lib/queries.js
index 4bf959a..52c6ce6 100644
--- a/data/lib/queries.js
+++ b/data/lib/queries.js
@@ -2,57 +2,61 @@
// http://www.opensource.org/licenses/mit-license.php
"use strict";
-function getSelection () {
- var text = "";
- var selectionObject = window.getSelection();
- if (selectionObject.rangeCount > 0) {
- text = selectionObject.getRangeAt(0).toString().trim();
- }
- return text;
+function getSelection() {
+ var text = "";
+ var selectionObject = window.getSelection();
+ if (selectionObject.rangeCount > 0) {
+ text = selectionObject.getRangeAt(0).toString().trim();
+ }
+ return text;
}
/**
* Opens a new tab with a query for the given text in the selected component
- *
- * @param text to be searched for
- * @param component String with the component name (maybe latter regexp?)
- * @param product (optional) string with the product name, if undefined,
- * search in all products
+ *
+ * @param text
+ * to be searched for
+ * @param component
+ * String with the component name (maybe latter regexp?)
+ * @param product
+ * (optional) string with the product name, if undefined, search in all
+ * products
* @return None
*
*/
function queryInNewTab(text, component, product, equivComps) {
- var urlStr = "https://" + window.location.hostname + "/buglist.cgi?query_format=advanced";
- if (product) {
- urlStr += "&product=" + product.trim();
- }
- if (component) {
- if (equivComps) {
- var equivCompsArr = equivComps.
- filter(function (REstr) {
- return new RegExp(REstr).test(component);
- }, this);
- if (equivCompsArr.length > 0) {
- component = equivCompsArr[0];
- }
- }
- urlStr += "&component=" + component.trim();
+ var urlStr = "https://" + window.location.hostname
+ + "/buglist.cgi?query_format=advanced";
+ if (product) {
+ urlStr += "&product=" + product.trim();
+ }
+ if (component) {
+ if (equivComps) {
+ var equivCompsArr = equivComps.filter(function(REstr) {
+ return new RegExp(REstr).test(component);
+ }, this);
+ if (equivCompsArr.length > 0) {
+ component = equivCompsArr[0];
+ }
}
+ urlStr += "&component=" + component.trim();
+ }
- // using more complicated query tables here, because they can be more easily
- // edited
- // for further investigative searches
- if (text) {
- text = encodeURIComponent(text.trim());
- var searchText = "&field0-0-0=longdesc&type0-0-0=substring&value0-0-0="
- + text
- + "&field0-0-1=attach_data.thedata&type0-0-1=substring&value0-0-1="
- + text
- + "&field0-0-2=status_whiteboard&type0-0-2=substring&value0-0-2="
- + text;
- urlStr += searchText;
- self.postMessage(new Message("OpenURLinTab", urlStr)); // utils.js is always avaiulable
- }
+ // using more complicated query tables here, because they can be more easily
+ // edited
+ // for further investigative searches
+ if (text) {
+ text = encodeURIComponent(text.trim());
+ var searchText = "&field0-0-0=longdesc&type0-0-0=substring&value0-0-0="
+ + text
+ + "&field0-0-1=attach_data.thedata&type0-0-1=substring&value0-0-1="
+ + text
+ + "&field0-0-2=status_whiteboard&type0-0-2=substring&value0-0-2="
+ + text;
+ urlStr += searchText;
+ self.postMessage(new Message("OpenURLinTab", urlStr)); // utils.js is
+ // always avaiulable
+ }
}
/**
@@ -60,39 +64,42 @@ function queryInNewTab(text, component, product, equivComps) {
* function this.queryInNewTab, and run it.
*/
function queryForSelection() {
- var text = getSelection();
- if (!text) {
- self.postMessage(new Message("GetClipboard", "queryLocal"));
- } else {
- if (equivalentComponents) {
- queryInNewTab(text, getComponent(), getProduct(), equivalentComponents);
- }
- else {
- queryInNewTab(text, getComponent(), getProduct());
- }
+ var text = getSelection();
+ if (!text) {
+ self.postMessage(new Message("GetClipboard", "queryLocal"));
+ }
+ else {
+ if (equivalentComponents) {
+ queryInNewTab(text, getComponent(), getProduct(),
+ equivalentComponents);
}
+ else {
+ queryInNewTab(text, getComponent(), getProduct());
+ }
+ }
}
/**
- *
+ *
*/
function queryUpstreamCallback(text, queryUpBug) {
var searchData = filterByRegexp(queryUpBug, getComponent());
if (!searchData) {
- return ; // not sure why it should happen, but certainly better
+ return; // not sure why it should happen, but certainly better
}
var urlBase = searchData.url;
- text = searchData.searchBy+":"+searchData.fillIn+" "+text.trim();
+ text = searchData.searchBy + ":" + searchData.fillIn + " "
+ + text.trim();
if (searchData.fillIn == "$$$") {
text = text.replace("$$$", getComponent());
}
- text = encodeURIComponent(text).replace("%20","+");
+ text = encodeURIComponent(text).replace("%20", "+");
self.postMessage(new Message("OpenURLinTab", urlBase + text));
}
/**
* Search simple query in the upstream bugzilla appropriate for the component
- *
+ *
* @return none
*/
function queryUpstream(qUpBug) {
@@ -102,7 +109,8 @@ function queryUpstream(qUpBug) {
}
var text = getSelection();
if (!text) {
- self.postMessage(new Message("GetClipboard", "queryUpstream"));
+ self
+ .postMessage(new Message("GetClipboard", "queryUpstream"));
}
else {
queryUpstreamCallback(text, qUpBug);
diff --git a/data/lib/rhbzpage.js b/data/lib/rhbzpage.js
index 5daeea7..752e471 100644
--- a/data/lib/rhbzpage.js
+++ b/data/lib/rhbzpage.js
@@ -16,13 +16,14 @@ var RawhideColor = new Color(0, 119, 0); // or "green", or RGB 0, 119, 0, or
// 120, 0, 23
var RHITColor = new Color(102, 0, 102); // RGB 102, 0, 102; HSL 300, 0, 20
-// [ 126.386] (--) NOUVEAU(0): Chipset: "NVIDIA NVaf"
+// [ 126.386] (--) NOUVEAU(0): Chipset: "NVIDIA NVaf"
var logAnalyzeLogic = {
"AnalyzeInterestingLine": {
/*
- [ 126.378] (--) PCI:*(0:4:0:0) 10de:08a0:106b:00c2 rev 162, Mem @ 0xd2000000/16777216, \
- 0xc0000000/268435456, 0xd0000000/33554432, I/O @ 0x00001000/128, BIOS @ 0x????????/131072
- */
+ * [ 126.378] (--) PCI:*(0:4:0:0) 10de:08a0:106b:00c2 rev 162, Mem @
+ * 0xd2000000/16777216, \ 0xc0000000/268435456, 0xd0000000/33554432, I/O @
+ * 0x00001000/128, BIOS @ 0x????????/131072
+ */
re: [
"^(\\[[ .0-9]+\\])?\\s*\\(--\\) PCI:\\*\\([0-9:]+\\)\\s*" +
"([0-9a-f:]+).*$",
@@ -32,14 +33,13 @@ var logAnalyzeLogic = {
func: chipsetMagic
},
/*
- [ 126.385] (WW) Falling back to old probe method for vesa
- [ 126.385] (WW) Falling back to old probe method for fbdev
- [ 126.386] (--) NOUVEAU(0): Chipset: "NVIDIA NVaf"
- Backtrace:
-
- [ 33.158] Kernel command line: ro root=LABEL=root rd_NO_LUKS rd_NO_LVM rd_NO_MD rd_NO_DM LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYTABLE=us drm.debug=0x04
-
- */
+ * [ 126.385] (WW) Falling back to old probe method for vesa [ 126.385] (WW)
+ * Falling back to old probe method for fbdev [ 126.386] (--) NOUVEAU(0):
+ * Chipset: "NVIDIA NVaf" Backtrace: [ 33.158] Kernel command line: ro
+ * root=LABEL=root rd_NO_LUKS rd_NO_LVM rd_NO_MD rd_NO_DM LANG=en_US.UTF-8
+ * SYSFONT=latarcyrheb-sun16 KEYTABLE=us drm.debug=0x04
+ *
+ */
"AnalyzeXorgLogBacktrace": {
re: "^\\s*(\\[[0-9 .]*\\])?\\s*(\\((EE|WW)\\)|.* [cC]hipset:.*)|\\s*(Backtrace|Kernel command line)",
func: analyzeXorg
@@ -145,8 +145,9 @@ function RHcentralCommandDispatch(cmdLabel, cmdParams) {
/**
* Make it sailent that the some attachments with bad MIME type are present
- *
- * @param atts Array of attachments subarrays
+ *
+ * @param atts
+ * Array of attachments subarrays
* @return none
*/
function markBadAttachments(atts) {
@@ -178,7 +179,7 @@ function markBadAttachments(atts) {
/**
* Open a tab in the upstream bugzilla to create a new bug
- *
+ *
* @return none
*/
function sendBugUpstream() {
@@ -197,7 +198,7 @@ function sendBugUpstream() {
/**
* Add a link opening selected lines of Xorg.0.log
- *
+ *
* @return none
*/
function addCheckXorgLogLink(attList) {
@@ -214,13 +215,14 @@ function addCheckXorgLogLink(attList) {
/**
* Given line to be parsed, find out which chipset it is and fill in the
* whiteboard
- *
- * @param PCIidArrObj object with two fields
- * id Array manufacturer-ID and product-ID (PCI IDs)
- * chipsetLine whole line containing PCI ID.
- * @param driverStr String with the driver name
+ *
+ * @param PCIidArrObj
+ * object with two fields id Array manufacturer-ID and product-ID (PCI
+ * IDs) chipsetLine whole line containing PCI ID.
+ * @param driverStr
+ * String with the driver name
* @return None
- *
+ *
*/
function fillInWhiteBoard(cardName) {
console.myDebug("fillInWhiteBoard: cardName = " + cardName);
@@ -234,8 +236,9 @@ function fillInWhiteBoard(cardName) {
* Get attached Xorg.0.log, parse it and find the value of chip. Does not fill
* the whiteboard itself, just adds button to do so,paramList so that slow
* XMLHttpRequest is done in advance.
- *
- * @param log array of XorgLogAttList
+ *
+ * @param log
+ * array of XorgLogAttList
* @return None
*/
function fillInChipMagic(XlogID) {
@@ -244,8 +247,9 @@ function fillInChipMagic(XlogID) {
/**
* Creates a button to change summary by adding a graphic chip label
- *
- * @param Array with matching results of re.exec()
+ *
+ * @param Array
+ * with matching results of re.exec()
*/
function chipsetMagic (interestingLineArr) {
// parse Xorg.0.log
@@ -287,7 +291,7 @@ function chipsetMagic (interestingLineArr) {
if (cardStr) {
createNewButton("short_desc_nonedit_display", false, {
"name": "Fill In",
- "chipMagic": cardStr,
+ "chipMagic": cardStr
});
}
}
@@ -358,8 +362,9 @@ function findInterestingLine(wholeLog, backMsg) {
/**
* Add information about the upstream bug upstream, and closing it.
- *
- * @param evt Event which called this handler
+ *
+ * @param evt
+ * Event which called this handler
* @return none
*/
function addClosingUpstream() {
@@ -409,7 +414,7 @@ function addClosingUpstream() {
}
/**
- *
+ *
*/
function parseBacktrace (ret) {
var signalHandler = new RegExp("^\\s*#[0-9]*\\s*<signal handler called>");
diff --git a/data/lib/skip-bug.js b/data/lib/skip-bug.js
index 3639448..c909a3e 100644
--- a/data/lib/skip-bug.js
+++ b/data/lib/skip-bug.js
@@ -6,12 +6,12 @@ function reloadPage() {
var stemURL = 'https://HOSTNAME/show_bug.cgi?id=';
var titleElems = document.getElementsByTagName('title');
if (titleElems) {
- var REArr = new RegExp('[bB]ug\\s+([0-9]+)').
- exec(titleElems[0].textContent);
+ var REArr = new RegExp('[bB]ug\\s+([0-9]+)')
+ .exec(titleElems[0].textContent);
var hostname = document.location.hostname;
if (REArr) {
- document.location = stemURL.
- replace('HOSTNAME',hostname) + REArr[1];
+ document.location = stemURL.replace('HOSTNAME', hostname)
+ + REArr[1];
}
}
}
diff --git a/data/lib/urltest.js b/data/lib/urltest.js
index a0dbabf..609e77b 100644
--- a/data/lib/urltest.js
+++ b/data/lib/urltest.js
@@ -1,4 +1,5 @@
function onBugzillaPage(url) {
- return /https:\/\/bugzilla(-[a-zA-Z]+)*\.mozilla\.org/.test(url)
+ return /https:\/\/bugzilla(-[a-zA-Z]+)*\.mozilla\.org/
+ .test(url)
|| /https:\/\/landfill.*\.bugzilla\.org/.test(url);
-} \ No newline at end of file
+}
diff --git a/data/lib/util.js b/data/lib/util.js
index 4a46403..be674bc 100644
--- a/data/lib/util.js
+++ b/data/lib/util.js
@@ -7,16 +7,17 @@
/**
* parse URL to get its parts.
- *
+ *
* @param url
* @return object with all parsed parts of URL as properties
- *
- * Originally from http://james.padolsey.com/javascript/parsing-urls-with-the-dom/
- * Copyright February 19th, 2009, James Padolsey, <license undeclared>
- *
- * This function creates a new anchor element and uses location
- * properties (inherent) to get the desired URL data. Some String
- * operations are used (to normalize results across browsers).
+ *
+ * Originally from
+ * http://james.padolsey.com/javascript/parsing-urls-with-the-dom/ Copyright
+ * February 19th, 2009, James Padolsey, <license undeclared>
+ *
+ * This function creates a new anchor element and uses location properties
+ * (inherent) to get the desired URL data. Some String operations are used (to
+ * normalize results across browsers).
*/
function parseURL(url) {
var a = document.createElement('a');
@@ -47,16 +48,19 @@ function parseURL(url) {
}
/**
- * parse XML object out of string working around various bugs in Gecko implementation
- * see https://developer.mozilla.org/en/E4X for more information
- *
- * @param inStr String with unparsed XML string
+ * parse XML object out of string working around various bugs in Gecko
+ * implementation see https://developer.mozilla.org/en/E4X for more information
+ *
+ * @param inStr
+ * String with unparsed XML string
* @return XML object
*/
function parseXMLfromString (inStuff) {
- // if (typeof inStuff !== 'string') In future we should recognize this.response
+ // if (typeof inStuff !== 'string') In future we should recognize
+ // this.response
// and get just .text property out of it. TODO
- var respStr = inStuff.replace(/^<\?xml\s+version\s*=\s*(["'])[^\1]+\1[^?]*\?>/, ""); // bug 336551
+ var respStr = inStuff.replace(/^<\?xml\s+version\s*=\s*(["'])[^\1]+\1[^?]*\?>/, ""); // bug
+ // 336551
return new XML(respStr);
}
@@ -74,7 +78,9 @@ function getBugNo() {
/**
* Get a bug no from URL ... fails with aliases
- * @param url String with URL to be analyzed
+ *
+ * @param url
+ * String with URL to be analyzed
* @return String with the bug ID
*/
function getBugNoFromURL(url) {
@@ -86,8 +92,9 @@ function getBugNoFromURL(url) {
/**
* Send mouse click to the specified element
- *
- * @param String ID of the element to send mouseclick to
+ *
+ * @param String
+ * ID of the element to send mouseclick to
* @return None
*/
function clickMouse (targetID) {
@@ -98,14 +105,22 @@ function clickMouse (targetID) {
}
/**
- * Create a A element leadink nowhere, but with listener running a callback on the click
- *
- * @param id String with a id to be added to the element
- * @param text String with a string to be added as a textContent of the element
- * @param parent Node which is a parent of the object
- * @param callback Function to be called after clicking on the link
- * @param params Array with parameters of the callback
- * @param Boolean before if there should be a <br> element before.
+ * Create a A element leadink nowhere, but with listener running a callback on
+ * the click
+ *
+ * @param id
+ * String with a id to be added to the element
+ * @param text
+ * String with a string to be added as a textContent of the element
+ * @param parent
+ * Node which is a parent of the object
+ * @param callback
+ * Function to be called after clicking on the link
+ * @param params
+ * Array with parameters of the callback
+ * @param Boolean
+ * before if there should be a <br>
+ * element before.
* @return none
*/
function createDeadLink (id, text, parent, callback, params, before, covered, accesskey) {
@@ -156,13 +171,13 @@ function createDeadLink (id, text, parent, callback, params, before, covered, ac
}
/*
- * From <a> element diggs out just plain email address
- * Note that bugzilla.gnome.org doesn't have mailto: url but
+ * From <a> element diggs out just plain email address Note that
+ * bugzilla.gnome.org doesn't have mailto: url but
* https://bugzilla.gnome.org/page.cgi?id=describeuser.html&login=mcepl%40redhat.com
- *
- * @param aElement Element with href attribute or something else
- * @return String with the address or null
- *
+ *
+ * @param aElement Element with href attribute or something else @return String
+ * with the address or null
+ *
*/
function parseMailto(aElement) {
var emailStr = "", hrefStr = "";
@@ -182,7 +197,7 @@ function parseMailto(aElement) {
/**
* format date to be in ISO format (just day part)
- *
+ *
* @param date
* @return string with the formatted date
*/
@@ -198,9 +213,11 @@ function getISODate(dateStr) {
/**
* Check whether an item is member of the list. Idea is just to make long if
* commands slightly more readable.
- *
- * @param mbr string to be searched in the list
- * @param list list
+ *
+ * @param mbr
+ * string to be searched in the list
+ * @param list
+ * list
* @return position of the string in the list, or -1 if none found.
*/
function isInList(mbr, list) {
@@ -212,12 +229,12 @@ function isInList(mbr, list) {
/**
* Make sure value returned is Array
- *
+ *
* @param Array/String
* @return Array
- *
- * If something else than Array or String is passed to the function
- * the result will be untouched actual argument of the call.
+ *
+ * If something else than Array or String is passed to the function the result
+ * will be untouched actual argument of the call.
*/
function valToArray(val) {
var isArr = val &&
@@ -228,9 +245,11 @@ function valToArray(val) {
/**
* Merges two comma separated string as a list and returns new string
- *
- * @param str String with old values
- * @param value String/Array with other values
+ *
+ * @param str
+ * String with old values
+ * @param value
+ * String/Array with other values
* @return String with merged lists
*/
function addCSVValue(str, value) {
@@ -250,9 +269,11 @@ function addCSVValue(str, value) {
/**
* Treats comma separated string as a list and removes one item from it
- *
- * @param str String treated as a list
- * @param value String with the value to be removed from str
+ *
+ * @param str
+ * String treated as a list
+ * @param value
+ * String with the value to be removed from str
* @return String with the resulting list comma separated
*/
function removeCSVValue(str, value) {
@@ -268,9 +289,11 @@ function removeCSVValue(str, value) {
/**
* select element of the array where regexp in the first element matches second
* parameter of this function
- *
- * @param list Array with regexps and return values
- * @param chosingMark String by which the element of array is to be matched
+ *
+ * @param list
+ * Array with regexps and return values
+ * @param chosingMark
+ * String by which the element of array is to be matched
* @return Object chosen element
*/
function filterByRegexp(list, chosingMark) {
@@ -290,14 +313,16 @@ function filterByRegexp(list, chosingMark) {
/**
* remove elements from the page based on their IDs
- *
- * @param doc Document object
- * @param target String/Array with ID(s)
- * @param remove Boolean indicating whether the node should be
- * actually removed or just hidden.
- * @return none
- * TODO remove parameter could be replaced by function which would
- * do actual activity.
+ *
+ * @param doc
+ * Document object
+ * @param target
+ * String/Array with ID(s)
+ * @param remove
+ * Boolean indicating whether the node should be actually removed or
+ * just hidden.
+ * @return none TODO remove parameter could be replaced by function which would
+ * do actual activity.
*/
function killNodes(doc, target, remove) {
target = target.trim();
@@ -315,8 +340,9 @@ function killNodes(doc, target, remove) {
/**
* Remove duplicate elements from array
- *
- * @param arr Array which needs to be cleaned up
+ *
+ * @param arr
+ * Array which needs to be cleaned up
* @return cleaned up array
*/
function removeDuplicates (arr) {
@@ -332,11 +358,8 @@ function removeDuplicates (arr) {
// ============================================
/**
- * object to pack messaging. Use as in
- self.postMessage(new Message("GetPassword", {
- login: login,
- hostname: location.hostname
- }));
+ * object to pack messaging. Use as in self.postMessage(new
+ * Message("GetPassword", { login: login, hostname: location.hostname }));
*/
function Message(cmd, data) {
this.cmd = cmd;
diff --git a/data/lib/viewSource.js b/data/lib/viewSource.js
index 25cba58..fd47cec 100644
--- a/data/lib/viewSource.js
+++ b/data/lib/viewSource.js
@@ -51,7 +51,7 @@ function viewAttachmentSource(doc) {
if (!table)
return;
var rows = table.querySelectorAll("tr");
- for (var i = 0; i < rows.length; ++i) {
+ for ( var i = 0; i < rows.length; ++i) {
var items = rows[i].querySelectorAll("td");
if (items.length != 3)
continue;
@@ -68,32 +68,36 @@ function viewAttachmentSource(doc) {
// Match mime type followed by ";" (charset) or ")" (no charset)
typeName = span.textContent.match(reAttachmentType)[1];
typeName = typeName.split(";")[0]; // ignore charset following type
- } catch (e) {}
- if (typeName == "application/java-archive" ||
- typeName == "application/x-jar") {
+ }
+ catch (e) {
+ }
+ if (typeName == "application/java-archive"
+ || typeName == "application/x-jar") {
// Due to the fix for bug 369814, only zip files with this special
// mime type can be used with the jar: protocol.
// http://hg.mozilla.org/mozilla-central/rev/be54f6bb9e1e
- addLink(items[2], "JAR Contents", "jar:" + attachHref + "!/");
- // https://bugzilla.mozilla.org/show_bug.cgi?id=369814#c5 has more possible mime types for zips?
- } else if (typeName == "application/zip" ||
- typeName == "application/x-zip-compressed" ||
- typeName == "application/x-xpinstall") {
- addLink(items[2], "Static ZIP Contents", "jar:" + attachHref + "!/");
- } else if (typeName != "text/plain" &&
- typeName != "patch" &&
- // Other types that Gecko displays like text/plain
- // http://mxr.mozilla.org/mozilla-central/source/parser/htmlparser/public/nsIParser.h
- typeName != "text/css" &&
- typeName != "text/javascript" &&
- typeName != "text/ecmascript" &&
- typeName != "application/javascript" &&
- typeName != "application/ecmascript" &&
- typeName != "application/x-javascript" &&
- // Binary image types for which the "source" is not useful
- typeName != "image/gif" &&
- typeName != "image/png" &&
- typeName != "image/jpeg") {
+ addLink(items[2], "JAR Contents", "jar:" + attachHref
+ + "!/");
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=369814#c5 has more
+ // possible mime types for zips?
+ }
+ else if (typeName == "application/zip"
+ || typeName == "application/x-zip-compressed"
+ || typeName == "application/x-xpinstall") {
+ addLink(items[2], "Static ZIP Contents", "jar:"
+ + attachHref + "!/");
+ }
+ else if (typeName != "text/plain" && typeName != "patch" &&
+ // Other types that Gecko displays like text/plain
+ // http://mxr.mozilla.org/mozilla-central/source/parser/htmlparser/public/nsIParser.h
+ typeName != "text/css" && typeName != "text/javascript"
+ && typeName != "text/ecmascript"
+ && typeName != "application/javascript"
+ && typeName != "application/ecmascript"
+ && typeName != "application/x-javascript" &&
+ // Binary image types for which the "source" is not useful
+ typeName != "image/gif" && typeName != "image/png"
+ && typeName != "image/jpeg") {
addLink(items[2], "Source", "view-source:" + attachHref);
}
}
diff --git a/data/lib/xorgBugCategories.js b/data/lib/xorgBugCategories.js
index c2c9c9b..3357ed7 100644
--- a/data/lib/xorgBugCategories.js
+++ b/data/lib/xorgBugCategories.js
@@ -4,25 +4,26 @@
/**
* Returns true if the bug is in a good shape
- *
- * @return Boolean if the bug is either not in the category
- * where we care about it (i.e., we don't have set up categories for
- * this component) or if it is in the concerned categories, then it has
- * a category recorded in the whiteboard input box.
- *
+ *
+ * @return Boolean if the bug is either not in the category where we care about
+ * it (i.e., we don't have set up categories for this component) or if
+ * it is in the concerned categories, then it has a category recorded in
+ * the whiteboard input box.
+ *
*/
function hasXorgBugsCategory() {
var catRE = /\s*\[cat:.*?\]\s*/; // RE for testing whether
// there is already category tag in the Whiteboard
- var isXOrgBug = filterByRegexp(constantData.
- xorgBugsCategories, getComponent());
- var whiteboardContent = document.
- getElementById("status_whiteboard").value;
+ var isXOrgBug = filterByRegexp(
+ constantData.xorgBugsCategories, getComponent());
+ var whiteboardContent = document
+ .getElementById("status_whiteboard").value;
if (isXOrgBug) { // is it XOR?
return catRE.test(whiteboardContent);
- } else {
+ }
+ else {
return true;
}
}
@@ -47,23 +48,24 @@ function makeBugCategoriesList(catList) {
// Fill-in <select> with <options>s for each category one
if (catList) {
- catList.forEach(function (cat) {
+ catList.forEach(function(cat) {
optionElement = document.createElement("option");
optionElement.value = cat;
- optionElement.setAttribute("id", "catId_" +
- cat.replace(" ","").toLowerCase());
+ optionElement.setAttribute("id", "catId_"
+ + cat.replace(" ", "").toLowerCase());
optionElement.appendChild(document.createTextNode(cat));
categoryList.appendChild(optionElement);
});
}
- categoryList.addEventListener("change", function (evt) {
+ categoryList.addEventListener("change", function(evt) {
var selectedCategory = "[cat:" + this.value + "]";
- var whiteboardElement = document.getElementById("status_whiteboard");
+ var whiteboardElement = document
+ .getElementById("status_whiteboard");
if (hasXorgBugsCategory()) {
- whiteboardElement.value = whiteboardElement.
- value.replace(catRE, "");
+ whiteboardElement.value = whiteboardElement.value.replace(
+ catRE, "");
}
addStuffToTextBox("status_whiteboard", selectedCategory);
}, false);
diff --git a/lib/cookiemanager.js b/lib/cookiemanager.js
index 087d6ab..b777ab9 100644
--- a/lib/cookiemanager.js
+++ b/lib/cookiemanager.js
@@ -46,10 +46,10 @@ exports.getHostCookies = function getHostCookies(host) {
if (cookie.rawHost == host) {
result.push({
name: cookie.name,
- value: cookie.value,
+ value: cookie.value
});
}
}
return result;
-}
+};
diff --git a/lib/libbugzilla.js b/lib/libbugzilla.js
index 7e2398b..c85d331 100644
--- a/lib/libbugzilla.js
+++ b/lib/libbugzilla.js
@@ -38,23 +38,26 @@ function log(msg) {
}
/**
- * parse XML object out of string working around various bugs in Gecko implementation
- * see https://developer.mozilla.org/en/E4X for more information
- *
- * @param inStr String with unparsed XML string
+ * parse XML object out of string working around various bugs in Gecko
+ * implementation see https://developer.mozilla.org/en/E4X for more information
+ *
+ * @param inStr
+ * String with unparsed XML string
* @return XML object
*/
function parseXMLfromString (inStuff) {
- // if (typeof inStuff !== 'string') In future we should recognize this.response
+ // if (typeof inStuff !== 'string') In future we should recognize
+ // this.response
// and get just .text property out of it. TODO
- var respStr = inStuff.replace(/^<\?xml\s+version\s*=\s*(["'])[^\1]+\1[^?]*\?>/, ""); // bug 336551
+ var respStr = inStuff.replace(/^<\?xml\s+version\s*=\s*(["'])[^\1]+\1[^?]*\?>/, ""); // bug
+ // 336551
return new XML(respStr);
}
/**
- * In case URL contains alias, not the real bug number, get the real bug no
- * from the XML representation. Sets correct value to this.bugNo.
- *
+ * In case URL contains alias, not the real bug number, get the real bug no from
+ * the XML representation. Sets correct value to this.bugNo.
+ *
* This is a slow variant for bugs other than actual window
*/
function getRealBugNoSlow(bugNo, location, callback) {
@@ -141,14 +144,11 @@ exports.changeJSONURL = function changeJSONURL() {
};
/**
- *
- libbz.getInstalledPackages(msg.data, function (pkgsMsg) {
- worker.postMessage(pkgsMsg);
-
- locationLoginObj: {
- location: window.location.href,
- login: getLogin()
- }
+ *
+ * libbz.getInstalledPackages(msg.data, function (pkgsMsg) {
+ * worker.postMessage(pkgsMsg);
+ *
+ * locationLoginObj: { location: window.location.href, login: getLogin() }
*/
exports.getInstalledPackages = function getInstalledPackages(locationLoginObj, callback) {
var installedPackages = {};
@@ -283,14 +283,16 @@ exports.createUpstreamBug = function createUpstreamBug(urlStr, subject, comment)
});
};
-// Make a XML-RPC call ... most of the business logic should stay in the content script
+// Make a XML-RPC call ... most of the business logic should stay in the content
+// script
exports.makeXMLRPCCall = function makeXMLRPCCall(url, login, method, params, callback) {
var urlObj = urlMod.URL(url);
getPassword(login,
urlObj.schema + "://" + urlObj.host,
function (passwObj) {
if (!passwObj.password) {
- // TODO this should happen, only when user presses Escape in password prompt
+ // TODO this should happen, only when user presses Escape in password
+ // prompt
return null;
}
diff --git a/lib/logger.js b/lib/logger.js
index ce96f69..ed9ac47 100644
--- a/lib/logger.js
+++ b/lib/logger.js
@@ -24,8 +24,10 @@ exports.initialize = function initialize(aMap) {
};
exports.addLogRecord = function addLogRecord(rec) {
- if (myStorage.storage.logs[rec.key] && myStorage.storage.logs[rec.key].comment) {
- myStorage.storage.logs[rec.key].comment += "<br/>\n" + rec.comment;
+ if (myStorage.storage.logs[rec.key]
+ && myStorage.storage.logs[rec.key].comment) {
+ myStorage.storage.logs[rec.key].comment += "<br/>\n"
+ + rec.comment;
}
else {
myStorage.storage.logs[rec.key] = rec;
@@ -54,7 +56,7 @@ exports.importTimeSheet = function importTimeSheet() {
if (fileMod.exists(filename)) {
var otherTS = JSON.parse(fileMod.read(filename));
if (otherTS.logs) {
- for (var rec in otherTS.logs) {
+ for ( var rec in otherTS.logs) {
myStorage.storage.logs[rec] = otherTS.logs[rec];
}
}
@@ -74,27 +76,30 @@ function getBugzillaAbbr(url) {
}
exports.generateTimeSheet = function generateTimeSheet() {
- var docHTML = timeSheetRecordsPrinter(myStorage.storage.logs, new Date());
- libbz.openURLInNewTab("data:text/html;charset=utf-8," + docHTML);
-};
+ var docHTML = timeSheetRecordsPrinter(myStorage.storage.logs,
+ new Date());
+ libbz.openURLInNewTab("data:text/html;charset=utf-8,"
+ + docHTML);
+};
-var timeSheetRecordsPrinter = exports.timeSheetRecordsPrinter =
- function timeSheetRecordsPrinter(records, date) {
- var commentBugRE = new RegExp("[bB]ug\\s+([0-9]+)","g");
+var timeSheetRecordsPrinter = exports.timeSheetRecordsPrinter = function timeSheetRecordsPrinter(
+ records, date) {
+ var commentBugRE = new RegExp("[bB]ug\\s+([0-9]+)", "g");
// sort the records into temporary array
var tmpArr = [];
- var dateStr = date.getFullYear() + "-" +
- xrpc.leadingZero(date.getMonth()+1) + "-" +
- xrpc.leadingZero(date.getDate());
- var outStr = '<!DOCTYPE html>' +
- "<html><head>\n"+
- "<meta charset='utf-8'/>\n"+
- "<title>TimeSheet-"+ dateStr + "</title>\n</head>\n<body>\n" +
- "<h1>TimeSheet</h1>\n";
+ var dateStr = date.getFullYear() + "-"
+ + xrpc.leadingZero(date.getMonth() + 1) + "-"
+ + xrpc.leadingZero(date.getDate());
+ var outStr = '<!DOCTYPE html>' + "<html><head>\n"
+ + "<meta charset='utf-8'/>\n" + "<title>TimeSheet-"
+ + dateStr + "</title>\n</head>\n<body>\n"
+ + "<h1>TimeSheet</h1>\n";
- for (var i in records) {
+ for ( var i in records) {
if (records.hasOwnProperty(i)) {
- tmpArr.push( [ i, records[i] ]);
+ tmpArr.push([
+ i, records[i]
+ ]);
}
}
tmpArr.sort(function(a, b) {
@@ -112,27 +117,24 @@ var timeSheetRecordsPrinter = exports.timeSheetRecordsPrinter =
var currentDay = "";
// now print the array
tmpArr.forEach(function(rec) {
- var x = rec[1];
- var dayStr = utilMod.getISODate(x.date);
- var host = urlMod.URL(x.url).host;
- var BZName = getBugzillaAbbr(x.url);
- var bugNo = utilMod.getBugNo(x.url);
- if (dayStr != currentDay) {
- currentDay = dayStr;
- outStr += "<hr/><p><strong>" + currentDay
- + "</strong></p>\n";
- }
- // replace "bug ####" with a hyperlink to the current bugzilla
- var comment = x.comment.replace(commentBugRE,
- "<a href='http://"+host+"/show_bug.cgi?id=$1'>$&</a>");
- outStr += "<p><em><a href='"
- + x.url
- + "'>Bug "
- + BZName + "/" + bugNo + ": "
- + x.title
- + "</a>"
- + " </em>\n<br/>" + comment + "</p>\n";
+ var x = rec[1];
+ var dayStr = utilMod.getISODate(x.date);
+ var host = urlMod.URL(x.url).host;
+ var BZName = getBugzillaAbbr(x.url);
+ var bugNo = utilMod.getBugNo(x.url);
+ if (dayStr != currentDay) {
+ currentDay = dayStr;
+ outStr += "<hr/><p><strong>" + currentDay
+ + "</strong></p>\n";
+ }
+ // replace "bug ####" with a hyperlink to the current bugzilla
+ var comment = x.comment.replace(commentBugRE,
+ "<a href='http://" + host
+ + "/show_bug.cgi?id=$1'>$&</a>");
+ outStr += "<p><em><a href='" + x.url + "'>Bug " + BZName
+ + "/" + bugNo + ": " + x.title + "</a>"
+ + " </em>\n<br/>" + comment + "</p>\n";
});
outStr += "</body></html>";
return outStr;
-}
+};
diff --git a/lib/main.js b/lib/main.js
index 849da68..f3e9458 100644
--- a/lib/main.js
+++ b/lib/main.js
@@ -23,13 +23,13 @@ function isOurPage(window, matchingURLs) {
var url = window.location.href;
// like ["regexp-url1", "regexp-url2"]
- return matchingURLs.some(function (element,i,a) {
+ return matchingURLs.some(function(element, i, a) {
return new RegExp(element).test(url);
});
}
/**
- *
+ *
*/
function skipThisPage(doc) {
var stemURL = "https://HOSTNAME/show_bug.cgi?id=";
@@ -39,20 +39,21 @@ function skipThisPage(doc) {
var hostname = doc.location.hostname;
if (REArr) {
var bugNo = REArr[1];
- doc.location = stemURL.replace("HOSTNAME",hostname) + bugNo;
+ doc.location = stemURL.replace("HOSTNAME", hostname) + bugNo;
}
}
-var messageHandler = exports.messageHandler = function messageHandler(worker, msg) {
+var messageHandler = exports.messageHandler = function messageHandler(
+ worker, msg) {
switch (msg.cmd) {
case "LogMessage":
console.log(msg.data);
break;
case "ExecCmd":
- libbz.executeCommand(msg.data);
+ libbz.executeCommand(msg.data);
break;
case "AddLogRecord":
- logger.addLogRecord(msg.data);
+ logger.addLogRecord(msg.data);
break;
case "GenerateTS":
logger.generateTimeSheet();
@@ -65,12 +66,12 @@ var messageHandler = exports.messageHandler = function messageHandler(worker, ms
break;
case "GetInstalledPackages":
// send message with packages back
- libbz.getInstalledPackages(msg.data, function (pkgsMsg) {
+ libbz.getInstalledPackages(msg.data, function(pkgsMsg) {
worker.postMessage(pkgsMsg);
});
break;
case "GetClipboard":
- libbz.getClipboard(function (clipboard) {
+ libbz.getClipboard(function(clipboard) {
worker.postMessage(new Message(msg.data, clipboard));
});
break;
@@ -91,18 +92,23 @@ var messageHandler = exports.messageHandler = function messageHandler(worker, ms
break;
case "MakeXMLRPCall":
// url, login, method, params, callback
- libbz.makeXMLRPCCall(msg.data.url, msg.data.login, msg.data.method,
- msg.data.params, function(ret) {
- worker.postMessage(new Message(msg.data.callRPC, ret));
- });
+ libbz
+ .makeXMLRPCCall(msg.data.url, msg.data.login,
+ msg.data.method, msg.data.params, function(ret) {
+ worker.postMessage(new Message(msg.data.callRPC,
+ ret));
+ });
break;
case "GetURL":
- libbz.getURL(msg.data.url, function(stuff) {
- worker.postMessage(new Message(msg.data.backMessage, stuff));
- });
+ libbz.getURL(msg.data.url,
+ function(stuff) {
+ worker.postMessage(new Message(msg.data.backMessage,
+ stuff));
+ });
break;
case "OpenBugUpstream":
- libbz.createUpstreamBug(msg.data.url, msg.data.subject, msg.data.comment);
+ libbz.createUpstreamBug(msg.data.url, msg.data.subject,
+ msg.data.comment);
break;
case "testReady":
// we ignore it here, interesting only in unit test
@@ -113,36 +119,36 @@ var messageHandler = exports.messageHandler = function messageHandler(worker, ms
};
var contentScriptLibraries = [
- self.data.url('lib/urltest.js'),
- self.data.url("lib/util.js"),
- self.data.url("lib/jumpNextBug.js"),
- self.data.url("lib/queries.js"),
- self.data.url("lib/preprocessDuplicates.js"),
- self.data.url("lib/viewSource.js"),
- self.data.url("lib/color.js"),
- self.data.url("lib/addNewLinks.js"),
- self.data.url("lib/bugzillaDOMFunctions.js"),
- self.data.url("lib/xorgBugCategories.js"),
- self.data.url("lib/otherButtons.js"),
- self.data.url("lib/makeBacktraceAttachment.js"),
- self.data.url("lib/fixingAttMIME.js"),
- self.data.url("lib/logging-front.js"),
- self.data.url('lib/bug-page-mod.js'),
- self.data.url("lib/rhbzpage.js"),
- self.data.url("lib/bzpage.js")
+ self.data.url('lib/urltest.js'),
+ self.data.url("lib/util.js"),
+ self.data.url("lib/jumpNextBug.js"),
+ self.data.url("lib/queries.js"),
+ self.data.url("lib/preprocessDuplicates.js"),
+ self.data.url("lib/viewSource.js"),
+ self.data.url("lib/color.js"),
+ self.data.url("lib/addNewLinks.js"),
+ self.data.url("lib/bugzillaDOMFunctions.js"),
+ self.data.url("lib/xorgBugCategories.js"),
+ self.data.url("lib/otherButtons.js"),
+ self.data.url("lib/makeBacktraceAttachment.js"),
+ self.data.url("lib/fixingAttMIME.js"),
+ self.data.url("lib/logging-front.js"),
+ self.data.url('lib/bug-page-mod.js'),
+ self.data.url("lib/rhbzpage.js"),
+ self.data.url("lib/bzpage.js")
];
-libbz.initialize(libbz.config, function () {
+libbz.initialize(libbz.config, function() {
pageMod.PageMod({
- include: [
- "https://bugzilla.redhat.com/show_bug.cgi?id=*",
- "https://bugzilla.mozilla.org/show_bug.cgi?id=*",
- "https://bugzilla.gnome.org/show_bug.cgi?id=*"
+ include : [
+ "https://bugzilla.redhat.com/show_bug.cgi?id=*",
+ "https://bugzilla.mozilla.org/show_bug.cgi?id=*",
+ "https://bugzilla.gnome.org/show_bug.cgi?id=*"
],
- contentScriptWhen: 'ready',
- contentScriptFile: contentScriptLibraries,
- onAttach: function onAttach(worker, msg) {
- worker.on('message', function (msg) {
+ contentScriptWhen : 'ready',
+ contentScriptFile : contentScriptLibraries,
+ onAttach : function onAttach(worker, msg) {
+ worker.on('message', function(msg) {
messageHandler(worker, msg);
});
}
@@ -150,34 +156,37 @@ libbz.initialize(libbz.config, function () {
});
pageMod.PageMod({
- include: [
- "https://bugzilla.redhat.com/process_bug.cgi",
- "https://bugzilla.redhat.com/post_bug.cgi",
- "https://bugzilla.redhat.com/attachment.cgi",
- "https://bugzilla.mozilla.org/process_bug.cgi",
- "https://bugzilla.mozilla.org/post_bug.cgi",
- "https://bugzilla.mozilla.org/attachment.cgi",
- "https://bugzilla.gnome.org/process_bug.cgi",
- "https://bugzilla.gnome.org/post_bug.cgi",
- "https://bugzilla.gnome.org/attachment.cgi"
+ include : [
+ "https://bugzilla.redhat.com/process_bug.cgi",
+ "https://bugzilla.redhat.com/post_bug.cgi",
+ "https://bugzilla.redhat.com/attachment.cgi",
+ "https://bugzilla.mozilla.org/process_bug.cgi",
+ "https://bugzilla.mozilla.org/post_bug.cgi",
+ "https://bugzilla.mozilla.org/attachment.cgi",
+ "https://bugzilla.gnome.org/process_bug.cgi",
+ "https://bugzilla.gnome.org/post_bug.cgi",
+ "https://bugzilla.gnome.org/attachment.cgi"
],
- contentScriptWhen: 'ready',
- contentScriptFile: self.data.url("lib/skip-bug.js")
+ contentScriptWhen : 'ready',
+ contentScriptFile : self.data.url("lib/skip-bug.js")
});
-
// Allow toggling of CC event displays using a context menu entry
contextMenu.Item({
- label: "Toggle CC History",
- contentScriptFile: [self.data.url('lib/urltest.js'),
- self.data.url('lib/cc-context.js')]
+ label : "Toggle CC History",
+ contentScriptFile : [
+ self.data.url('lib/urltest.js'),
+ self.data.url('lib/cc-context.js')
+ ]
});
contextMenu.Item({
- label: "Copy Check-in Comment",
- contentScriptFile: [self.data.url('lib/urltest.js'),
- self.data.url('lib/checkin-context.js')],
- onMessage: function (comment) {
- require("clipboard").set(comment);
+ label : "Copy Check-in Comment",
+ contentScriptFile : [
+ self.data.url('lib/urltest.js'),
+ self.data.url('lib/checkin-context.js')
+ ],
+ onMessage : function(comment) {
+ require("clipboard").set(comment);
}
});
diff --git a/lib/prompts.js b/lib/prompts.js
index 7cfd3d1..3f34e0d 100644
--- a/lib/prompts.js
+++ b/lib/prompts.js
@@ -11,23 +11,23 @@ var promptTitle = "Bugzilla Triage Script";
/**
* shows the text in a simple window
- *
+ *
* @return none
*/
exports.alert = function alert(msg) {
var prompts = Cc["@mozilla.org/embedcomp/prompt-service;1"]
- .getService(Ci.nsIPromptService);
+ .getService(Ci.nsIPromptService);
prompts.alert(null, promptTitle, msg);
};
/**
* general prompts for a string method
- *
+ *
* @return String with the password
*/
exports.prompt = function prompt(prompt, defaultValue) {
var stringValue = {
- value: defaultValue ? defaultValue : ""
+ value : defaultValue ? defaultValue : ""
};
var prompts = Cc["@mozilla.org/embedcomp/prompt-service;1"]
@@ -44,7 +44,7 @@ exports.prompt = function prompt(prompt, defaultValue) {
/**
* returns password with a special password
- *
+ *
* @return String with the password
*/
exports.promptPassword = function promptPassword(prompt) {
@@ -59,8 +59,8 @@ exports.promptPassword = function promptPassword(prompt) {
var check = {
value : true
}; // default the checkbox to true
- var result = prompts.promptPassword(null, "Bugzilla Triage Script", prompt,
- password, null, check);
+ var result = prompts.promptPassword(null,
+ "Bugzilla Triage Script", prompt, password, null, check);
// result is true if OK was pressed, false if cancel was pressed.
// password.value is set if OK was pressed.
// The checkbox is not displayed.
@@ -83,8 +83,9 @@ exports.promptYesNoCancel = function promptOKNoCancel(prompt) {
var prompts = Cc["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Ci.nsIPromptService);
- var result = prompts.confirmEx(null, "Bugzilla Triage Script", prompt,
- prompts.STD_YES_NO_BUTTONS, null, null, null, null, {});
+ var result = prompts.confirmEx(null, "Bugzilla Triage Script",
+ prompt, prompts.STD_YES_NO_BUTTONS, null, null, null,
+ null, {});
if (result === 0) {
return true;
}
@@ -97,22 +98,22 @@ exports.promptYesNoCancel = function promptOKNoCancel(prompt) {
};
/**
- *
+ *
* documentation is https://developer.mozilla.org/en/NsIFilePicker
*/
-exports.promptFileOpenPicker = function promptFilePicker (win) {
+exports.promptFileOpenPicker = function promptFilePicker(win) {
var window = require("window-utils").activeWindow;
var fp = Cc["@mozilla.org/filepicker;1"]
- .createInstance(Ci.nsIFilePicker);
+ .createInstance(Ci.nsIFilePicker);
fp.init(window, "JSON File Open", Ci.nsIFilePicker.modeOpen);
fp.appendFilter("JSON files", "*.json");
fp.appendFilters(Ci.nsIFilePicker.filterAll);
fp.filterIndex = 0;
var res = fp.show();
- if (res === Ci.nsIFilePicker.returnOK ||
- res === Ci.nsIFilePicker.returnReplace ) {
- return fp.file.path;
+ if (res === Ci.nsIFilePicker.returnOK
+ || res === Ci.nsIFilePicker.returnReplace) {
+ return fp.file.path;
}
return null;
};
diff --git a/lib/util.js b/lib/util.js
index d28f001..008d6fb 100644
--- a/lib/util.js
+++ b/lib/util.js
@@ -11,7 +11,7 @@ var urlMod = require("url");
/**
* get parameters of URL as an object (name, value)
*/
-function getParamsFromURL (url, base) {
+function getParamsFromURL(url, base) {
if (!url || (url.toString().length === 0)) {
throw new Error("Missing URL value!");
}
@@ -23,7 +23,7 @@ function getParamsFromURL (url, base) {
var paramsArr = url.path.split("?");
if (paramsArr.length === 1) {
return {};
- }
+ }
// get convert URL parameters to an Object
var params = {}, s = [];
@@ -35,11 +35,11 @@ function getParamsFromURL (url, base) {
}
/**
- * Get a bug no from URL ... fails with aliases
- * It should theoretically belong to bzpage.js, but we don't have
- * unit tests there yet, so keeping here.
- *
- * @param url String with URL to be analyzed
+ * Get a bug no from URL ... fails with aliases It should theoretically belong
+ * to bzpage.js, but we don't have unit tests there yet, so keeping here.
+ *
+ * @param url
+ * String with URL to be analyzed
* @return String with the bug ID (hopefully number, but not for aliases)
*/
exports.getBugNo = function getBugNo(url) {
@@ -51,7 +51,7 @@ exports.getBugNo = function getBugNo(url) {
/**
* format date to be in ISO format (just day part)
- *
+ *
* @param date
* @return string with the formatted date
*/
@@ -60,18 +60,15 @@ exports.getISODate = function getISODate(dateStr) {
return n < 10 ? '0' + n : n;
}
var date = new Date(dateStr);
- return date.getFullYear() + '-' + pad(date.getMonth() + 1) + '-' +
- pad(date.getDate());
+ return date.getFullYear() + '-' + pad(date.getMonth() + 1)
+ + '-' + pad(date.getDate());
};
/**
- * object to pack messaging. Use as in
- postMessage(new Message("GetPassword", {
- login: login,
- hostname: location.hostname
- }));
+ * object to pack messaging. Use as in postMessage(new Message("GetPassword", {
+ * login: login, hostname: location.hostname }));
*/
exports.Message = function Message(cmd, data) {
- this.cmd = cmd;
- this.data = data;
+ this.cmd = cmd;
+ this.data = data;
};
diff --git a/lib/xmlrpc.js b/lib/xmlrpc.js
index e038c4e..3991b04 100644
--- a/lib/xmlrpc.js
+++ b/lib/xmlrpc.js
@@ -3,41 +3,44 @@
// Modification of Matěj Cepl released under the MIT/X11 license
// http://www.opensource.org/licenses/mit-license.php
/*
- *
+ *
* xmlrpc.js beta version 1 Tool for creating XML-RPC formatted requests in
* JavaScript
- *
+ *
* Copyright 2001 Scott Andrew LePera scott@scottandrew.com
- *
- *
+ *
+ *
* License: You are granted the right to use and/or redistribute this code only
* if this license and the copyright notice are included and you accept that no
* warranty of any kind is made or implied by the author.
- *
+ *
*/
/**
* checks whether parameter is an array
- *
- * @param obj Object
+ *
+ * @param obj
+ * Object
* @return Boolean true if obj is array
- *
+ *
* The problem is that in different contexts, Array is not same, and so obj is
* not an instance of SAME Array.
*/
/**
* pads a single number with a leading zero. Heh.
- *
- * @param n String or Number
+ *
+ * @param n
+ * String or Number
* @return String with leading zero added if necessary
- *
+ *
* If the real parameter is not numerical, it is just returned as it is.
*/
var leadingZero = exports.leadingZero = function leadingZero(n) {
if (isNaN(Number(n))) {
return n;
- };
+ }
+ ;
var s = "0" + n;
if (s.length > 2) {
@@ -46,22 +49,24 @@ var leadingZero = exports.leadingZero = function leadingZero(n) {
return s;
};
-var dateToISO8601 = exports.dateToISO8601 = function dateToISO8601(date) {
+var dateToISO8601 = exports.dateToISO8601 = function dateToISO8601(
+ date) {
// wow I hate working with the Date object
console.log("date = " + date);
var year = date.getYear();
var month = leadingZero(date.getMonth());
var day = leadingZero(date.getDate());
- var time = leadingZero(date.getHours()) +
- ":" + leadingZero(date.getMinutes()) +
- ":" + leadingZero(date.getSeconds());
+ var time = leadingZero(date.getHours()) + ":"
+ + leadingZero(date.getMinutes()) + ":"
+ + leadingZero(date.getSeconds());
var converted = year + month + day + "T" + time;
console.log("date = " + converted);
return converted;
};
-var XMLRPCMessage = exports.XMLRPCMessage = function XMLRPCMessage(methodname) {
+var XMLRPCMessage = exports.XMLRPCMessage = function XMLRPCMessage(
+ methodname) {
this.method = methodname || "system.listMethods";
this.params = [];
return this;
@@ -71,20 +76,19 @@ XMLRPCMessage.prototype.myIsArray = function myIsArray(obj) {
return (typeof obj.sort === 'function');
};
-
-XMLRPCMessage.prototype.setMethod = function (methodName) {
+XMLRPCMessage.prototype.setMethod = function(methodName) {
if (methodName !== undefined) {
this.method = methodName;
}
};
-XMLRPCMessage.prototype.addParameter = function (data) {
+XMLRPCMessage.prototype.addParameter = function(data) {
if (data !== undefined) {
this.params.push(data);
}
};
-XMLRPCMessage.prototype.xml = function () {
+XMLRPCMessage.prototype.xml = function() {
var method = this.method;
@@ -97,11 +101,11 @@ XMLRPCMessage.prototype.xml = function () {
xml += "<params>\n";
// do individual parameters
- this.params.forEach(function (data) {
+ this.params.forEach(function(data) {
xml += "<param>\n";
- xml += "<value>" +
- this.getParamXML(this.dataTypeOf(data),
- data) + "</value>\n";
+ xml += "<value>"
+ + this.getParamXML(this.dataTypeOf(data), data)
+ + "</value>\n";
xml += "</param>\n";
}, this);
xml += "</params>\n";
@@ -110,7 +114,7 @@ XMLRPCMessage.prototype.xml = function () {
return xml; // for now
};
-XMLRPCMessage.prototype.dataTypeOf = function (o) {
+XMLRPCMessage.prototype.dataTypeOf = function(o) {
// identifies the data type
var type = typeof (o);
type = type.toLowerCase();
@@ -138,49 +142,50 @@ XMLRPCMessage.prototype.dataTypeOf = function (o) {
return type;
};
-XMLRPCMessage.prototype.doValueXML = function (type, data) {
+XMLRPCMessage.prototype.doValueXML = function(type, data) {
var xml = "<" + type + ">" + data + "</" + type + ">";
return xml;
};
-XMLRPCMessage.prototype.doBooleanXML = function (data) {
+XMLRPCMessage.prototype.doBooleanXML = function(data) {
var value = (data === true) ? 1 : 0;
var xml = "<boolean>" + value + "</boolean>";
return xml;
};
-XMLRPCMessage.prototype.doDateXML = function (data) {
+XMLRPCMessage.prototype.doDateXML = function(data) {
var xml = "<dateTime.iso8601>";
xml += dateToISO8601(data);
xml += "</dateTime.iso8601>";
return xml;
};
-XMLRPCMessage.prototype.doArrayXML = function (data) {
+XMLRPCMessage.prototype.doArrayXML = function(data) {
var xml = "<array><data>\n";
- for (var i = 0; i < data.length; i++) {
- xml += "<value>" +
- this.getParamXML(this.dataTypeOf(data[i]),
- data[i]) + "</value>\n";
+ for ( var i = 0; i < data.length; i++) {
+ xml += "<value>"
+ + this.getParamXML(this.dataTypeOf(data[i]), data[i])
+ + "</value>\n";
}
xml += "</data></array>\n";
return xml;
};
-XMLRPCMessage.prototype.doStructXML = function (data) {
+XMLRPCMessage.prototype.doStructXML = function(data) {
var xml = "<struct>\n";
- for (var i in data) {
+ for ( var i in data) {
xml += "<member>\n";
xml += "<name>" + i + "</name>\n";
- xml += "<value>" + this.getParamXML(this.dataTypeOf(data[i]),
- data[i]) + "</value>\n";
+ xml += "<value>"
+ + this.getParamXML(this.dataTypeOf(data[i]), data[i])
+ + "</value>\n";
xml += "</member>\n";
}
xml += "</struct>\n";
return xml;
};
-XMLRPCMessage.prototype.getParamXML = function (type, data) {
+XMLRPCMessage.prototype.getParamXML = function(type, data) {
var xml;
switch (type) {
case "date":
diff --git a/tests/pagemod-test-helpers.js b/tests/pagemod-test-helpers.js
index 8621421..9980715 100644
--- a/tests/pagemod-test-helpers.js
+++ b/tests/pagemod-test-helpers.js
@@ -1,10 +1,10 @@
"use strict";
-const {Cc,Ci} = require("chrome");
-
+const Cc = require("chrome").Cc;
+const Ci = require("chrome").Ci;
/**
- * A helper function that creates a PageMod, then opens the specified URL
- * and checks the effect of the page mod on 'onload' event via testCallback.
+ * A helper function that creates a PageMod, then opens the specified URL and
+ * checks the effect of the page mod on 'onload' event via testCallback.
*/
exports.testPageMod = function testPageMod(test, testURL, pageModOptions,
testCallback, timeout) {
@@ -20,7 +20,7 @@ exports.testPageMod = function testPageMod(test, testURL, pageModOptions,
var browserWindow = wm.getMostRecentWindow("navigator:browser");
if (!browserWindow) {
test.pass("page-mod tests: could not find the browser window, so " +
- "will not run. Use -a firefox to run the pagemod tests.")
+ "will not run. Use -a firefox to run the pagemod tests.");
return null;
}
@@ -44,7 +44,7 @@ exports.testPageMod = function testPageMod(test, testURL, pageModOptions,
function onPageLoad() {
b.removeEventListener("load", onPageLoad, true);
testCallback(b.contentWindow.wrappedJSObject, function done() {
- pageMods.forEach(function(mod) mod.destroy());
+ pageMods.forEach(function(mod) {mod.destroy()});
// XXX leaks reported if we don't close the tab?
tabBrowser.removeTab(newTab);
test.done();
diff --git a/tests/test-color.js b/tests/test-color.js
index eefb97d..95d3e16 100644
--- a/tests/test-color.js
+++ b/tests/test-color.js
@@ -1,31 +1,31 @@
/*global exports: false, require: false */
// TODO: add some failing tests as well
"use strict";
-//var util = require("color");
+// var util = require("color");
// testing Color object
-var ensureColorNew = function (test) {
+var ensureColorNew = function(test) {
var col = new util.Color(255, 255, 166);
test.assertEqual(col.toString(), "#ffffa6",
- "creation of new RGB Color object");
+ "creation of new RGB Color object");
};
-var ensureColorUpdate = function (test) {
+var ensureColorUpdate = function(test) {
var col = new util.Color(255, 255, 166);
col.update(255, 224, 176);
test.assertEqual(col.toString(), "#ffe0b0",
- "updating Color object");
+ "updating Color object");
};
-var ensureColorHSL = function (test) {
+var ensureColorHSL = function(test) {
var col = new util.Color(255, 224, 176);
test.assertEqual(col.hsl().toSource(),
- "[0.10126582278481013, 1, 0.8450980392156863]",
- "converting to HSL model");
+ "[0.10126582278481013, 1, 0.8450980392156863]",
+ "converting to HSL model");
};
-var ensureColorLight = function (test) {
+var ensureColorLight = function(test) {
var col = new util.Color(255, 224, 176);
test.assertEqual(col.lightColor().toString(), "#e8dcc9",
- "getting a light color");
+ "getting a light color");
};
diff --git a/tests/test-logger.js b/tests/test-logger.js
index 2b087f8..d814838 100644
--- a/tests/test-logger.js
+++ b/tests/test-logger.js
@@ -6,34 +6,34 @@ var logMod = require("logger");
var selfMod = require("self");
var testGenerateTimeSheetDataLogs = {
- "2010-07-27+bugzilla.redhat.com+533567": {
- "date": "2010-07-27T21:28:47.103Z",
- "url": "https://bugzilla.redhat.com/show_bug.cgi?id=533567",
- "title": "KMS:RS480:X200M - GPU lockup (screen goes black)",
- "comment": "removing filled in chip type for Guadec"
+ "2010-07-27+bugzilla.redhat.com+533567" : {
+ "date" : "2010-07-27T21:28:47.103Z",
+ "url" : "https://bugzilla.redhat.com/show_bug.cgi?id=533567",
+ "title" : "KMS:RS480:X200M - GPU lockup (screen goes black)",
+ "comment" : "removing filled in chip type for Guadec"
},
- "2010-07-27+bugzilla.redhat.com+618769": {
- "date": "2010-07-27T21:30:18.845Z",
- "url": "https://bugzilla.redhat.com/show_bug.cgi?id=618769",
- "title": "gdm and display unstable with ATI FirePro V3700 graphics card",
- "comment": "asking for logs"
+ "2010-07-27+bugzilla.redhat.com+618769" : {
+ "date" : "2010-07-27T21:30:18.845Z",
+ "url" : "https://bugzilla.redhat.com/show_bug.cgi?id=618769",
+ "title" : "gdm and display unstable with ATI FirePro V3700 graphics card",
+ "comment" : "asking for logs"
}
};
-var testGenerateTimeSheetResultStr = "<!DOCTYPE html><html><head>\n<meta charset='utf-8'/>\n"+
- "<title>TimeSheet-2011-04-17</title>\n</head>\n<body>\n<h1>TimeSheet</h1>\n"+
- "<hr/><p><strong>2010-07-27</strong></p>\n<p><em>"+
- "<a href='https://bugzilla.redhat.com/show_bug.cgi?id=533567'>Bug RH/533567: "+
- "KMS:RS480:X200M - GPU lockup (screen goes black)</a> </em>\n<br/>removing filled "+
- "in chip type for Guadec</p>\n<p><em><a "+
- "href='https://bugzilla.redhat.com/show_bug.cgi?id=618769'>Bug RH/618769: "+
- "gdm and display unstable with ATI FirePro V3700 graphics card</a> </em>\n"+
- "<br/>asking for logs</p>\n</body></html>";
+var testGenerateTimeSheetResultStr = "<!DOCTYPE html><html><head>\n<meta charset='utf-8'/>\n"
+ + "<title>TimeSheet-2011-04-17</title>\n</head>\n<body>\n<h1>TimeSheet</h1>\n"
+ + "<hr/><p><strong>2010-07-27</strong></p>\n<p><em>"
+ + "<a href='https://bugzilla.redhat.com/show_bug.cgi?id=533567'>Bug RH/533567: "
+ + "KMS:RS480:X200M - GPU lockup (screen goes black)</a> </em>\n<br/>removing filled "
+ + "in chip type for Guadec</p>\n<p><em><a "
+ + "href='https://bugzilla.redhat.com/show_bug.cgi?id=618769'>Bug RH/618769: "
+ + "gdm and display unstable with ATI FirePro V3700 graphics card</a> </em>\n"
+ + "<br/>asking for logs</p>\n</body></html>";
-exports.ensureTimeSheetRecordsPrinter = function (test) {
- logMod.initialize(JSON.parse(selfMod.data.load(
- "bugzillalabelAbbreviations.json")))
- test.assertEqual(logMod.timeSheetRecordsPrinter(testGenerateTimeSheetDataLogs,
- new Date("2011-04-17")), testGenerateTimeSheetResultStr,
- "Generates correct log report from given data.");
+exports.ensureTimeSheetRecordsPrinter = function(test) {
+ logMod.initialize(JSON.parse(selfMod.data
+ .load("bugzillalabelAbbreviations.json")));
+ test.assertEqual(logMod.timeSheetRecordsPrinter(
+ testGenerateTimeSheetDataLogs, new Date("2011-04-17")),
+ testGenerateTimeSheetResultStr,
+ "Generates correct log report from given data.");
};
-
diff --git a/tests/test-match-pattern.js b/tests/test-match-pattern.js
index 9e3d2bd..106937a 100644
--- a/tests/test-match-pattern.js
+++ b/tests/test-match-pattern.js
@@ -1,11 +1,15 @@
-var { MatchPattern } = require("match-pattern");
+var MatchPattern = require("match-pattern").MatchPattern;
-exports.ensureMatchPattern = function (test) {
- var pattern = new MatchPattern("https://bugzilla.redhat.com/attachment.cgi");
+exports.ensureMatchPattern = function(test) {
+ var pattern = new MatchPattern(
+ "https://bugzilla.redhat.com/attachment.cgi");
console.log("pattern = " + pattern);
- test.assert(pattern.
- test("https://bugzilla.redhat.com/attachment.cgi"), "testing match pattern");
- test.assert(!pattern.
- test("https://bugzilla.redhat.com/attachment.cgi?bugid=676538&action=enter"),
- "testing failing match pattern");
+ test.assert(pattern
+ .test("https://bugzilla.redhat.com/attachment.cgi"),
+ "testing match pattern");
+ test
+ .assert(
+ !pattern
+ .test("https://bugzilla.redhat.com/attachment.cgi?bugid=676538&action=enter"),
+ "testing failing match pattern");
};
diff --git a/tests/test-pageMod.js b/tests/test-pageMod.js
index 5434bbd..31cb3dd 100644
--- a/tests/test-pageMod.js
+++ b/tests/test-pageMod.js
@@ -13,126 +13,121 @@ var testURL = self.data.url('tests/change-more-bugs01.html');
var JSONifiedMessage = '{"cmd":"testMessage","data":{"a":"first","b":"second"}}';
exports.ensureMessagesWork = function(test) {
- var msg = new utilMod.Message("testMessage", { a: "first", b: "second" } );
+ var msg = new utilMod.Message("testMessage", {
+ a : "first",
+ b : "second"
+ });
test.assertEqual(msg.cmd, "testMessage",
- "msg.cmd comes over well");
+ "msg.cmd comes over well");
test.assertEqual(msg.data.a, "first",
- "msg.data.a comes over well");
+ "msg.data.a comes over well");
test.assertEqual(msg.data.b, "second",
- "msg.data.b comes over well");
+ "msg.data.b comes over well");
test.assertEqual(JSON.stringify(msg), JSONifiedMessage,
- "JSONification of Message works as well");
+ "JSONification of Message works as well");
};
/*
+ *
+ * var theURL = main.theURL; var testURL =
+ * self.data.url('tests/change-more-bugs01.html');
+ *
+ * var contentScriptLibraries = { "bugzilla.redhat.com": [
+ * self.data.url("util.js"), self.data.url("color.js"),
+ * self.data.url("rhbzpage.js"), self.data.url("bzpage.js") ] };
+ *
+ * libbz.initialize(libbz.config, function () { pageMod.PageMod({ include: [
+ * "https://bugzilla.redhat.com/show_bug.cgi?id=*" ], contentScriptWhen:
+ * 'ready', contentScriptFile: contentScriptLibraries["bugzilla.redhat.com"],
+ * onAttach: function onAttach(worker, msg) { console.log("worker: " + worker);
+ * worker.on('message', function (msg) { messageHandler(worker, msg); }); } });
+ * });
+ *
+ * pageMod.PageMod({ include: [ "https://bugzilla.redhat.com/process_bug.cgi" ],
+ * contentScriptWhen: 'ready', contentScriptFile: self.data.url("skip-bug.js")
+ * });
+ */
-var theURL = main.theURL;
-var testURL = self.data.url('tests/change-more-bugs01.html');
-
-var contentScriptLibraries = {
- "bugzilla.redhat.com": [
- self.data.url("util.js"),
- self.data.url("color.js"),
- self.data.url("rhbzpage.js"),
- self.data.url("bzpage.js")
- ]
-};
-
-libbz.initialize(libbz.config, function () {
- pageMod.PageMod({
- include: [
- "https://bugzilla.redhat.com/show_bug.cgi?id=*"
- ],
- contentScriptWhen: 'ready',
- contentScriptFile: contentScriptLibraries["bugzilla.redhat.com"],
- onAttach: function onAttach(worker, msg) {
- console.log("worker: " + worker);
- worker.on('message', function (msg) {
- messageHandler(worker, msg);
- });
+var ensureSimplePageLoad = function(test) {
+ console.log("testURL = " + testURL);
+ testPageMod(test, testURL, [
+ {
+ include : [
+ "*"
+ ],
+ contentScriptWhen : 'ready',
+ contentScriptFile : [
+ self.data.url("libPW.js"),
+ self.data.url("simplePageWorker.js")
+ ],
+ onAttach : function onAttach(worker) {
+ worker.on('message', function(msg) {
+ switch (msg.cmd) {
+ case "LogMessage":
+ log(msg.data);
+ break;
+ case "CallBack":
+ worker
+ .postMessage(new utilMod.Message("Main", null));
+ break;
+ default:
+ console.error(msg);
+ }
+ });
+ }
}
+ ], function(win, done) {
+ test.assertNotEqual(win.document
+ .getElementsByTagName("form")[0], null,
+ "test of loading the page");
+ done();
});
-});
-
-pageMod.PageMod({
- include: [
- "https://bugzilla.redhat.com/process_bug.cgi"
- ],
- contentScriptWhen: 'ready',
- contentScriptFile: self.data.url("skip-bug.js")
-});
- */
-
-var ensureSimplePageLoad = function (test) {
- console.log("testURL = " + testURL);
- testPageMod(test, testURL, [{
- include: ["*"],
- contentScriptWhen: 'ready',
- contentScriptFile: [
- self.data.url("libPW.js"),
- self.data.url("simplePageWorker.js")
- ],
- onAttach: function onAttach(worker) {
- worker.on('message', function (msg) {
- switch (msg.cmd) {
- case "LogMessage":
- log(msg.data);
- break;
- case "CallBack":
- worker.postMessage(new utilMod.Message("Main", null));
- break;
- default:
- console.error(msg);
- }
- });
- }
- }],
- function (win, done) {
- test.assertNotEqual(win.document.getElementsByTagName("form")[0],
- null, "test of loading the page");
- done();
- });
};
-var ensurePageLoadsWell = function (test) {
+var ensurePageLoadsWell = function(test) {
var wm = Cc['@mozilla.org/appshell/window-mediator;1']
- .getService(Ci.nsIWindowMediator);
- var browserWindow = wm.getMostRecentWindow("navigator:browser");
+ .getService(Ci.nsIWindowMediator);
+ var browserWindow = wm
+ .getMostRecentWindow("navigator:browser");
if (!browserWindow) {
- test.fail("page-mod tests: could not find the browser window, so " +
- "will not run. Use -a firefox to run the pagemod tests.");
- return null;
+ test
+ .fail("page-mod tests: could not find the browser window, so "
+ + "will not run. Use -a firefox to run the pagemod tests.");
+ return null;
}
var loader = test.makeSandboxedLoader();
var pageMod = loader.require("page-mod");
- var testDoc = {}, b = {}, tabBrowser = {}, newTab = {};
+ var testDoc = {}, b = {}, tabBrowser = {}, newTab = {};
pageMod.PageMod({
- include: ["*"],
- contentScriptWhen: 'ready',
- contentScriptFile: [
- self.data.url("libPW.js"),
- self.data.url("pageWorker.js")
- ],
- onAttach: function onAttach(worker) {
- worker.on('message', function (msg) {
- switch (msg.cmd) {
- case "testReady":
- testDoc = b.contentWindow.wrappedJSObject.document;
- test.assertNotEqual(testDoc.getElementById("dupeid_action"),
- null, "test of DOM modifications of the page");
- pageMod.destroy();
- tabBrowser.removeTab(newTab);
- test.done();
- // the test itself
- break;
- default:
- main.messageHandler(worker, msg);
- }
- });
- }
- });
+ include : [
+ "*"
+ ],
+ contentScriptWhen : 'ready',
+ contentScriptFile : [
+ self.data.url("libPW.js"),
+ self.data.url("pageWorker.js")
+ ],
+ onAttach : function onAttach(worker) {
+ worker.on('message', function(msg) {
+ switch (msg.cmd) {
+ case "testReady":
+ testDoc = b.contentWindow.wrappedJSObject.document;
+ test.assertNotEqual(testDoc
+ .getElementById("dupeid_action"), null,
+ "test of DOM modifications of the page");
+ pageMod.destroy();
+ tabBrowser.removeTab(newTab);
+ test.done();
+ // the test itself
+ break;
+ default:
+ main.messageHandler(worker, msg);
+ }
+ });
+ }
+ });
tabBrowser = browserWindow.gBrowser;
newTab = tabBrowser.addTab(testURL);
diff --git a/tests/test-util.js b/tests/test-util.js
index 26c5f6d..7ab6280 100644
--- a/tests/test-util.js
+++ b/tests/test-util.js
@@ -6,13 +6,13 @@ var util = require("util");
var urlMod = require("url");
// testing util.heir
-var ensureHeir = function (test) {
+var ensureHeir = function(test) {
var fedlimid = {}, naoise = {};
function Father(x) {
this.family = x;
}
-
+
Father.prototype.getFamily = function getFamily() {
return this.family;
};
@@ -21,194 +21,216 @@ var ensureHeir = function (test) {
Father.call(this, x);
this.wife = w;
}
-
+
Son.prototype = util.heir(Father);
Son.prototype.constructor = Son;
-
+
Son.prototype.getWife = function getWife() {
return this.wife;
};
-
+
Son.prototype.getFamily = function getFamily() {
- var upFamily =
- Father.prototype.getFamily.call(this);
+ var upFamily = Father.prototype.getFamily.call(this);
return upFamily + ", " + this.wife;
};
-
+
// for curious and non-Celtic
// http://en.wikipedia.org/wiki/Deirdre :)
fedlimid = new Father("mac Daill");
naoise = new Son("Usnech", "Deirdre");
-
+
test.assertEqual(fedlimid.getFamily(), "mac Daill",
- "checking creation of new simple object");
-
+ "checking creation of new simple object");
+
test.assertEqual(naoise.getWife(), "Deirdre",
- "checking creation of new daughter object");
+ "checking creation of new daughter object");
test.assertEqual(naoise.getFamily(), "Usnech, Deirdre",
- "checking creation of new overloaded method");
+ "checking creation of new overloaded method");
};
// testing util.isInList
-var ensureIsInListTrue = function (test) {
- test.assert(util.isInList("a", ["a"]),
- "conversion of a string to an array");
+var ensureIsInListTrue = function(test) {
+ test.assert(util.isInList("a", [
+ "a"
+ ]), "conversion of a string to an array");
};
-var ensureIsInListFalse = function (test) {
- test.assert(!util.isInList("b", ["a"]),
- "conversion of a string to an array");
+var ensureIsInListFalse = function(test) {
+ test.assert(!util.isInList("b", [
+ "a"
+ ]), "conversion of a string to an array");
};
-var ensureIsInListEmpty = function (test) {
+var ensureIsInListEmpty = function(test) {
test.assert(!util.isInList("b", []),
- "conversion of a string to an array");
+ "conversion of a string to an array");
};
-var ensureIsInListNoMember = function (test) {
- test.assert(!util.isInList("", ["x"]),
- "conversion of a string to an array");
+var ensureIsInListNoMember = function(test) {
+ test.assert(!util.isInList("", [
+ "x"
+ ]), "conversion of a string to an array");
};
// testing util.filterByRegexp
-var ensureFilterByRegexp = function (test) {
+var ensureFilterByRegexp = function(test) {
var list = [
- {
- "regexp": "test(ing|ed)",
- "addr": "correct"
- },
- {
- "regexp": "ba.*d",
- "addr": true
- }
+ {
+ "regexp" : "test(ing|ed)",
+ "addr" : "correct"
+ }, {
+ "regexp" : "ba.*d",
+ "addr" : true
+ }
];
-
- test.assertEqual(util.filterByRegexp(list, "testing"), "correct",
- "simple testing of filterByRegexp");
- test.assertEqual(util.filterByRegexp(list, "unknown value"), "",
- "simple testing of filterByRegexp with non-found address");
- test.assert(util.filterByRegexp(list, "baaad"),
- "simple testing of filterByRegexp with non-string return value");
+
+ test.assertEqual(util.filterByRegexp(list, "testing"),
+ "correct", "simple testing of filterByRegexp");
+ test.assertEqual(util.filterByRegexp(list, "unknown value"),
+ "",
+ "simple testing of filterByRegexp with non-found address");
+ test
+ .assert(util.filterByRegexp(list, "baaad"),
+ "simple testing of filterByRegexp with non-string return value");
};
-var ensureFilterByRegexpEmpty = function (test) {
- test.assertRaises(function () {
- util.filterByRegexp(undefined, "tralala");
- },
- "list is undefined",
- "filterByRegexp throws an exception with empty list");
+var ensureFilterByRegexpEmpty = function(test) {
+ test.assertRaises(function() {
+ util.filterByRegexp(undefined, "tralala");
+ }, "list is undefined",
+ "filterByRegexp throws an exception with empty list");
};
// testing util.getISODate
-var ensureGetISODate = function (test) {
- test.assertEqual(util.getISODate("Mon May 31 2010 23:29:09 GMT+0200 (CET)"),
- "2010-05-31", "conversion of a Date to ISO-formatted String");
+var ensureGetISODate = function(test) {
+ test.assertEqual(util
+ .getISODate("Mon May 31 2010 23:29:09 GMT+0200 (CET)"),
+ "2010-05-31",
+ "conversion of a Date to ISO-formatted String");
};
// testing util.valToArray
-var ensureValToArrayString = function (test) {
- test.assertEqual(JSON.stringify(util.valToArray("a")),
- JSON.stringify(["a"]),
- "conversion of a string to an array");
+var ensureValToArrayString = function(test) {
+ test.assertEqual(JSON.stringify(util.valToArray("a")), JSON
+ .stringify([
+ "a"
+ ]), "conversion of a string to an array");
};
-var ensureValToArrayEmpty = function (test) {
- test.assertEqual(JSON.stringify(util.valToArray("")),
- JSON.stringify([""]),
- "conversion of an empty string to an array");
+var ensureValToArrayEmpty = function(test) {
+ test.assertEqual(JSON.stringify(util.valToArray("")), JSON
+ .stringify([
+ ""
+ ]), "conversion of an empty string to an array");
};
-var ensureValToArrayArray = function (test) {
- test.assertEqual(JSON.stringify(util.valToArray(["a"])),
- JSON.stringify(["a"]),
- "non-conversion of an array");
+var ensureValToArrayArray = function(test) {
+ test.assertEqual(JSON.stringify(util.valToArray([
+ "a"
+ ])), JSON.stringify([
+ "a"
+ ]), "non-conversion of an array");
};
// testing util.addCSVValue
-var ensureCSVAddedToNull = function (test) {
+var ensureCSVAddedToNull = function(test) {
test.assertEqual(util.addCSVValue("", "b"), "b",
- "adding a string to empty string");
+ "adding a string to empty string");
};
-var ensureCSVAddedNull = function (test) {
+var ensureCSVAddedNull = function(test) {
test.assertEqual(util.addCSVValue("a", ""), "a",
- "adding nothing to a string");
+ "adding nothing to a string");
};
-var ensureCSVAddedString = function (test) {
+var ensureCSVAddedString = function(test) {
test.assertEqual(util.addCSVValue("a", "b"), "a, b",
- "adding one string to another one");
+ "adding one string to another one");
};
-var ensureCSVAddedArray = function (test) {
- test.assertEqual(util.addCSVValue("a", ["b", "c"]), "a, b, c",
- "adding array to a string");
+var ensureCSVAddedArray = function(test) {
+ test.assertEqual(util.addCSVValue("a", [
+ "b", "c"
+ ]), "a, b, c", "adding array to a string");
};
-var ensureCSVAddedArray2Array = function (test) {
- test.assertEqual(util.addCSVValue("a, b", ["c", "d"]), "a, b, c, d",
- "adding one array to another");
+var ensureCSVAddedArray2Array = function(test) {
+ test.assertEqual(util.addCSVValue("a, b", [
+ "c", "d"
+ ]), "a, b, c, d", "adding one array to another");
};
// testing util.removeCSVValue
-var ensureCSVRemoveSimple = function (test) {
+var ensureCSVRemoveSimple = function(test) {
test.assertEqual(util.removeCSVValue("a, b", "b"), "a",
- "removing one string from an array");
+ "removing one string from an array");
};
// also checking a tolerancy against different ways of writing arrays
-var ensureCSVRemoveNonMember = function (test) {
- test.assertEqual(util.removeCSVValue("a,b", "c"), "a, b",
- "removing a string from an array of which it isn't a member");
+var ensureCSVRemoveNonMember = function(test) {
+ test
+ .assertEqual(util.removeCSVValue("a,b", "c"), "a, b",
+ "removing a string from an array of which it isn't a member");
};
-var ensureCSVRemoveEmpty = function (test) {
+var ensureCSVRemoveEmpty = function(test) {
test.assertEqual(util.removeCSVValue("", "c"), "",
- "removing a string from an empty array");
+ "removing a string from an empty array");
};
// testing util.getObjectKeys
-var ensureGetObjectKeys = function (test) {
+var ensureGetObjectKeys = function(test) {
var testObj = {
- a: 1,
- b: 2
+ a : 1,
+ b : 2
};
test.assertEqual(JSON.stringify(util.getObjectKeys(testObj)),
- JSON.stringify(["a", "b"]),
- "getting keys from a object");
+ JSON.stringify([
+ "a", "b"
+ ]), "getting keys from a object");
};
// testing util.getParamsFromURL
-var ensureGetParamsFromURL = function (test) {
- test.assertEqual(JSON.stringify(util.getParamsFromURL("https://bugzilla.redhat.com/show_bug.cgi?id=549066")),
- JSON.stringify({id:"549066"}),
- "simply compare result of bugzilla show_page URL");
- var complexURL = new urlMod.URL("http://www.google.com/search?ie=UTF-8&oe=UTF-8&sourceid=navclient"+
- "&gfns=1&q=gg+javascript+url+parse");
- test.assertEqual(JSON.stringify(util.getParamsFromURL(complexURL)),
- JSON.stringify({
- "ie":"UTF-8",
- "oe":"UTF-8",
- "sourceid":"navclient",
- "gfns":"1",
- "q":"gg+javascript+url+parse"
- }),
- "simply compare result of bugzilla show_page URL");
- test.assertEqual(JSON.stringify(util.getParamsFromURL("https://bugzilla.redhat.com/")),
- JSON.stringify({}),
- "URL without any parameters");
- test.assertRaises(function () {util.getParamsFromURL("");},
- "Missing URL value!", "No URL");
+var ensureGetParamsFromURL = function(test) {
+ test
+ .assertEqual(
+ JSON
+ .stringify(util
+ .getParamsFromURL("https://bugzilla.redhat.com/show_bug.cgi?id=549066")),
+ JSON.stringify({
+ id : "549066"
+ }), "simply compare result of bugzilla show_page URL");
+ var complexURL = new urlMod.URL(
+ "http://www.google.com/search?ie=UTF-8&oe=UTF-8&sourceid=navclient"
+ + "&gfns=1&q=gg+javascript+url+parse");
+ test.assertEqual(JSON.stringify(util
+ .getParamsFromURL(complexURL)), JSON.stringify({
+ "ie" : "UTF-8",
+ "oe" : "UTF-8",
+ "sourceid" : "navclient",
+ "gfns" : "1",
+ "q" : "gg+javascript+url+parse"
+ }), "simply compare result of bugzilla show_page URL");
+ test.assertEqual(JSON.stringify(util
+ .getParamsFromURL("https://bugzilla.redhat.com/")), JSON
+ .stringify({}), "URL without any parameters");
+ test.assertRaises(function() {
+ util.getParamsFromURL("");
+ }, "Missing URL value!", "No URL");
};
// testing util.getBugNo
-var ensureGetBugNo = function (test) {
- var bugNo = util.getBugNo("https://bugzilla.redhat.com/show_bug.cgi?id=597141");
+var ensureGetBugNo = function(test) {
+ var bugNo = util
+ .getBugNo("https://bugzilla.redhat.com/show_bug.cgi?id=597141");
test.assertEqual(bugNo, 597141, "getting bug number");
- bugNo = util.getBugNo("https://bugzilla.redhat.com/show_bug.cgi?id=serialWacom");
- test.assertEqual(bugNo, "serialWacom", "getting a bug alias; there is no guarantee of getting number!");
+ bugNo = util
+ .getBugNo("https://bugzilla.redhat.com/show_bug.cgi?id=serialWacom");
+ test
+ .assertEqual(bugNo, "serialWacom",
+ "getting a bug alias; there is no guarantee of getting number!");
};
diff --git a/tests/test-xmlrpc.js b/tests/test-xmlrpc.js
index f3f2e56..78bf9d5 100644
--- a/tests/test-xmlrpc.js
+++ b/tests/test-xmlrpc.js
@@ -2,21 +2,21 @@
/*jslint plusplus: false */
"use strict";
var xrpc = require("xmlrpc");
-var xmlOut = "<?xml version=\"1.0\"?>\n" +
- "<methodCall>\n<methodName>bugzilla.updateAttachMimeType</methodName>\n" +
- "<params>\n<param>\n<value><struct>\n<member>\n<name>attach_id</name>\n" +
- "<value><string>myId</string></value>\n</member>\n<member>\n" +
- "<name>mime_type</name>\n<value><string>text/plain</string></value>\n</member>\n" +
- "<member>\n<name>nomail</name>\n<value><string>billg@microsoft.com</string>" +
- "</value>\n</member>\n</struct>\n</value>\n</param>\n<param>\n" +
- "<value><string>me@example.com</string></value>\n</param>\n" +
- "<param>\n<value><string>secret</string></value>\n</param>\n" +
- "<param>\n<value><double>3.14</double></value>\n</param>\n" +
- "<param>\n<value><boolean>1</boolean></value>\n</param>\n" +
- "</params>\n</methodCall>";
+var xmlOut = "<?xml version=\"1.0\"?>\n"
+ + "<methodCall>\n<methodName>bugzilla.updateAttachMimeType</methodName>\n"
+ + "<params>\n<param>\n<value><struct>\n<member>\n<name>attach_id</name>\n"
+ + "<value><string>myId</string></value>\n</member>\n<member>\n"
+ + "<name>mime_type</name>\n<value><string>text/plain</string></value>\n</member>\n"
+ + "<member>\n<name>nomail</name>\n<value><string>billg@microsoft.com</string>"
+ + "</value>\n</member>\n</struct>\n</value>\n</param>\n<param>\n"
+ + "<value><string>me@example.com</string></value>\n</param>\n"
+ + "<param>\n<value><string>secret</string></value>\n</param>\n"
+ + "<param>\n<value><double>3.14</double></value>\n</param>\n"
+ + "<param>\n<value><boolean>1</boolean></value>\n</param>\n"
+ + "</params>\n</methodCall>";
-exports.ensureLeadingZero = function (test) {
- test.assert(typeof(xrpc.leadingZero) == "function");
+exports.ensureLeadingZero = function(test) {
+ test.assert(typeof (xrpc.leadingZero) == "function");
test.assertEqual(xrpc.leadingZero("1"), "01");
test.assertEqual(xrpc.leadingZero(1), "01");
test.assertEqual(xrpc.leadingZero("11"), "11");
@@ -25,12 +25,13 @@ exports.ensureLeadingZero = function (test) {
test.assertEqual(xrpc.leadingZero(111), "111");
test.assertEqual(xrpc.leadingZero("-1"), "-1");
test.assertEqual(xrpc.leadingZero(-1), "-1");
- test.assertEqual(xrpc.leadingZero("zzz"),"zzz");
+ test.assertEqual(xrpc.leadingZero("zzz"), "zzz");
};
// testing xrpc.XMLRPCMessage
-exports.ensureGenerateXMLRPC = function (test) {
- var msg = new xrpc.XMLRPCMessage("bugzilla.updateAttachMimeType");
+exports.ensureGenerateXMLRPC = function(test) {
+ var msg = new xrpc.XMLRPCMessage(
+ "bugzilla.updateAttachMimeType");
msg.addParameter({
'attach_id' : "myId",
'mime_type' : "text/plain",
@@ -40,6 +41,6 @@ exports.ensureGenerateXMLRPC = function (test) {
msg.addParameter("secret");
msg.addParameter(3.14);
msg.addParameter(true);
- test.assertEqual(msg.xml(), xmlOut,
- "generate XML-RPC message");
+ test
+ .assertEqual(msg.xml(), xmlOut, "generate XML-RPC message");
};