Closed
Bug 828185
Opened 12 years ago
Closed 12 years ago
Change as many as possible instances of "throw" to assert.* calls
Categories
(Mozilla QA Graveyard :: Mozmill Tests, defect, P3)
Mozilla QA Graveyard
Mozmill Tests
Tracking
(firefox18 fixed, firefox19 fixed, firefox20 fixed, firefox21 fixed, firefox-esr17 fixed)
People
(Reporter: daniela.p98911, Assigned: daniela.p98911)
References
()
Details
(Whiteboard: s=130128 u=enhancement c=assertions p=1)
Attachments
(2 files, 3 obsolete files)
32.61 KB,
patch
|
AndreeaMatei
:
review+
whimboo
:
checkin+
|
Details | Diff | Splinter Review |
30.89 KB,
patch
|
AndreeaMatei
:
review+
whimboo
:
checkin+
|
Details | Diff | Splinter Review |
All instances of "throw new Error(...)" should be changed with assert.* calls where possible.
Comment 1•12 years ago
|
||
Dave, that was my proposal which would make the code way cleaner. What do you think about? Here an example:
if (condition) {
throw new Error("My message");
}
vs.
assert.ok(condition, "My message");
Priority: -- → P3
Summary: Change the instances of "throw" with assert.* calls → Change as many as possible instances of "throw" to assert.* calls
Comment 2•12 years ago
|
||
Fine by me.
Comment 3•12 years ago
|
||
See https://developer.mozilla.org/en/Mozmill_Tests how to get started.
Whiteboard: [mentor=whimboo][lang=js][good first bug]
Updated•12 years ago
|
Whiteboard: [mentor=whimboo][lang=js][good first bug] → s=130128 u=enhancement c=assertions p=1
Assignee | ||
Updated•12 years ago
|
Assignee: nobody → dpetrovici
Assignee | ||
Updated•12 years ago
|
Status: NEW → ASSIGNED
Assignee | ||
Comment 4•12 years ago
|
||
patch v1.0
I have changed all instances of
if(condition)
throw...
to
assert.ok(!condition, message) - we are checking that the condition is true in assert and if it is false we throw exception.
For instance:
if (aRoot === undefined || aRoot === null)
throw new Error("The root element has to be specified.");
Changed to:
assert.ok(aRoot !== undefined && aRoot !== null, "The root element has to be specified."); - we are evaluating if aRoot is not undefined/null and if it is undefined or null we are throwing the error
Attachment #708114 -
Flags: review?(hskupin)
Attachment #708114 -
Flags: review?(dave.hunt)
Attachment #708114 -
Flags: review?(andreea.matei)
Comment 5•12 years ago
|
||
Comment on attachment 708114 [details] [diff] [review]
patch v1.0
Review of attachment 708114 [details] [diff] [review]:
-----------------------------------------------------------------
Good start Daniela!
Overall I will also check for the cases where we declare the variable and then use assert.* for it, to make it in the same block. No need for an extra line.
::: lib/addons.js
@@ +78,5 @@
> get discoveryPane() {
> // Make sure the "Get Add-ons" pane is selected
> var getAddons = this.getCategoryById({id: "discover"});
>
> + assert.ok(this.selectedCategory.getNode() === getAddons.getNode(),
We could use assert.equal here, that will also throw the error message if those are not equal.
Please add a single quote after Add-ons in the message so we have " the 'Get Add-ons' pane "
@@ +633,5 @@
> subtype: spec.attribute,
> value: spec.value
> });
>
> + assert.ok(categories.length !== 0, arguments.callee.name + ": Categories could not be found.");
We should use assert.notEqual() here.
@@ +762,5 @@
> this.controller.window.document.removeEventListener("ViewChanged",
> onViewChanged, false);
> }
>
> + assert.ok(this.selectedCategory.getNode() === category.getNode(),
We should use assert.equal() and check directly for the ids, this way we could avoid the got-expected part as well.
::: lib/prefs.js
@@ +339,5 @@
> * (Optional) A callback handler to launch the preference dialog
> */
> function openPreferencesDialog(controller, callback, launcher) {
> + assert.ok(controller, "No controller given for Preferences Dialog");
> + assert.ok(typeof callback === "function", "No callback given for Preferences Dialog");
We can use assert.equal() here as well.
::: lib/software-update.js
@@ +188,3 @@
>
> var patchCount = this.activeUpdate.patchCount;
> + assert.ok(patchCount === 1 || patchCount === 2, "An update must have one or two patches included.");
Please move the message to the next line so it won't exceed the characters limit.
::: lib/ui/private-browsing.js
@@ +89,5 @@
> var cmdKey = utils.getEntity(this.getDtds(), "privateBrowsingCmd.commandkey");
> aController.keypress(null, cmdKey, {accelKey: true, shiftKey: true});
> break;
> case "callback":
> + assert.ok(typeof aCallback === "function", "No callback given for opening the private browsing window");
Assert.equal() here too.
Attachment #708114 -
Flags: review?(hskupin)
Attachment #708114 -
Flags: review?(dave.hunt)
Attachment #708114 -
Flags: review?(andreea.matei)
Attachment #708114 -
Flags: review-
Assignee | ||
Comment 6•12 years ago
|
||
Changes done per review
Attachment #708114 -
Attachment is obsolete: true
Attachment #708569 -
Flags: review?(hskupin)
Attachment #708569 -
Flags: review?(dave.hunt)
Attachment #708569 -
Flags: review?(andreea.matei)
Assignee | ||
Comment 7•12 years ago
|
||
Forgot the reports:
Addons: http://mozmill-crowd.blargon7.com/#/addons/report/0dbaa964aec88a2f5637c68c9620dd81
Functional: http://mozmill-crowd.blargon7.com/#/functional/report/0dbaa964aec88a2f5637c68c96210621
http://mozmill-crowd.blargon7.com/#/functional/report/0dbaa964aec88a2f5637c68c96211454
Endurance:
http://mozmill-crowd.blargon7.com/#/endurance/report/0dbaa964aec88a2f5637c68c9621a4f5
Update:
http://mozmill-crowd.blargon7.com/#/update/report/0dbaa964aec88a2f5637c68c9621e5ec
http://mozmill-crowd.blargon7.com/#/update/report/0dbaa964aec88a2f5637c68c9621f044
Comment 8•12 years ago
|
||
Comment on attachment 708569 [details] [diff] [review]
patch v1.1
Review of attachment 708569 [details] [diff] [review]:
-----------------------------------------------------------------
Sorry for missing on the previous review, but for the assert.ok calls at least, the message should be the positive/expected behaviour. Because our output will be "Expected behaviour - got false".
Throw was displaying the exception.
For example:
assert.ok(name, arguments.callee.name + ": name not supplied.");
should have "Name has been supplied", so in case of error we will get that expected behaviour got false.
Same is required here: https://developer.mozilla.org/en-US/docs/Mozmill_Tests/Mozmill_Style_Guide#Error_Messages
Attachment #708569 -
Flags: review?(hskupin)
Attachment #708569 -
Flags: review?(dave.hunt)
Attachment #708569 -
Flags: review?(andreea.matei)
Attachment #708569 -
Flags: review-
Assignee | ||
Comment 9•12 years ago
|
||
Fixed error messages.
Reports are here:
Addons: http://mozmill-crowd.blargon7.com/#/addons/report/0dbaa964aec88a2f5637c68c9646ff54
Functional:
http://mozmill-crowd.blargon7.com/#/functional/report/0dbaa964aec88a2f5637c68c964731ac
http://mozmill-crowd.blargon7.com/#/functional/report/0dbaa964aec88a2f5637c68c96475cf2
Endurance: http://mozmill-crowd.blargon7.com/#/endurance/report/0dbaa964aec88a2f5637c68c9647a120
Update: http://mozmill-crowd.blargon7.com/#/update/report/0dbaa964aec88a2f5637c68c9647917f
http://mozmill-crowd.blargon7.com/#/update/report/0dbaa964aec88a2f5637c68c96478507
Attachment #708569 -
Attachment is obsolete: true
Attachment #709024 -
Flags: review?(hskupin)
Attachment #709024 -
Flags: review?(dave.hunt)
Attachment #709024 -
Flags: review?(andreea.matei)
Comment 10•12 years ago
|
||
Comment on attachment 709024 [details] [diff] [review]
patch v1.2
Review of attachment 709024 [details] [diff] [review]:
-----------------------------------------------------------------
Looks good now, but I would leave r? for Henrik and Dave, regarding the use of assert.equal().
Attachment #709024 -
Flags: review?(andreea.matei) → review+
Comment 11•12 years ago
|
||
Comment on attachment 709024 [details] [diff] [review]
patch v1.2
Review of attachment 709024 [details] [diff] [review]:
-----------------------------------------------------------------
::: lib/addons.js
@@ +747,5 @@
> this.controller.window.document.removeEventListener("ViewChanged",
> onViewChanged, false);
> }
>
> + assert.equal(this.getCategoryId({category: this.selectedCategory}), categoryId,
This check is wrong. You have to take the values from the if statement and not from the message.
@@ +825,5 @@
> */
> set selectedSearchFilter(aValue) {
> var filter = this.getSearchFilter({attribute: "value", value: aValue});
>
> + assert.ok(SEARCH_FILTER.indexOf(aValue) !== -1,
Clearly an assert.notEqual() call.
::: lib/dom-utils.js
@@ +510,5 @@
> * @param {object} aRoot
> * Element to use as root for node collection
> */
> set root(aRoot) {
> + assert.ok(aRoot !== undefined && aRoot !== null, "The root element has been specified.");
this is just assert.ok(aRoot, ...)
::: lib/software-update.js
@@ +183,5 @@
> get isCompleteUpdate() {
> // Throw when isCompleteUpdate is called without an update. This should
> // never happen except if the test is incorrectly written.
> + assert.ok(this.activeUpdate, arguments.callee.name + ": isCompleteUpdate called " +
> + "with an update");
Please do not modify the message.
::: lib/utils.js
@@ +271,5 @@
> var elem = '<elem id="elementID">&' + entityId + ';</elem>';
> var doc = parser.parseFromString(header + elem, 'text/xml');
> var elemNode = doc.querySelector('elem[id="elementID"]');
>
> + assert.notEqual(elemNode, null,
this is an assert.ok(!elemNode, ...)
Attachment #709024 -
Flags: review?(hskupin)
Attachment #709024 -
Flags: review?(dave.hunt)
Attachment #709024 -
Flags: review-
Assignee | ||
Comment 12•12 years ago
|
||
Changes done per review. Reports are below.
Functional:
http://mozmill-crowd.blargon7.com/#/functional/report/ad726b5c70cf80fbf8135edfca373a2a
http://mozmill-crowd.blargon7.com/#/functional/report/ad726b5c70cf80fbf8135edfca371ee6
Addons:
http://mozmill-crowd.blargon7.com/#/addons/report/ad726b5c70cf80fbf8135edfca375924
Endurance:
http://mozmill-crowd.blargon7.com/#/endurance/report/ad726b5c70cf80fbf8135edfca3775a8
Update:
http://mozmill-crowd.blargon7.com/#/update/report/ad726b5c70cf80fbf8135edfca38a0a2
http://mozmill-crowd.blargon7.com/#/update/report/ad726b5c70cf80fbf8135edfca388244
Attachment #709024 -
Attachment is obsolete: true
Attachment #710158 -
Flags: review?(andreea.matei)
Comment 13•12 years ago
|
||
Comment on attachment 710158 [details] [diff] [review]
patch v1.3
Review of attachment 710158 [details] [diff] [review]:
-----------------------------------------------------------------
Great, think we're done now, for default.
Attachment #710158 -
Flags: review?(andreea.matei) → review+
Updated•12 years ago
|
Keywords: checkin-needed
Comment 14•12 years ago
|
||
Comment on attachment 710158 [details] [diff] [review]
patch v1.3
Review of attachment 710158 [details] [diff] [review]:
-----------------------------------------------------------------
http://hg.mozilla.org/qa/mozmill-tests/rev/7e8af6459749 (default)
Attachment #710158 -
Flags: checkin+
Updated•12 years ago
|
status-firefox18:
--- → affected
status-firefox19:
--- → affected
status-firefox20:
--- → affected
status-firefox21:
--- → fixed
status-firefox-esr17:
--- → affected
Keywords: checkin-needed
Assignee | ||
Comment 15•12 years ago
|
||
The patch for default applies clearly on Aurora and no additional instances of throw need to be changed. Reports for Aurora are:
Addons:
http://mozmill-crowd.blargon7.com/#/addons/report/1641bc2f6438595b86015bd9010db28f
Functional:
http://mozmill-crowd.blargon7.com/#/functional/report/1641bc2f6438595b86015bd9010da33b
http://mozmill-crowd.blargon7.com/#/functional/report/1641bc2f6438595b86015bd9010d8cc9
Endurance:
http://mozmill-crowd.blargon7.com/#/endurance/report/1641bc2f6438595b86015bd9010dd86e
Update:
http://mozmill-crowd.blargon7.com/#/update/report/1641bc2f6438595b86015bd9010e17ad
http://mozmill-crowd.blargon7.com/#/update/report/1641bc2f6438595b86015bd9010e1ed0
The patch for Beta applies clearly on Release and ESR17.
Reports for Beta are:
Addons:
http://mozmill-crowd.blargon7.com/#/addons/report/1641bc2f6438595b86015bd9010e2200
Functional:
http://mozmill-crowd.blargon7.com/#/functional/report/1641bc2f6438595b86015bd9010ddcb9
http://mozmill-crowd.blargon7.com/#/functional/report/1641bc2f6438595b86015bd9010db2c8
Endurance:
http://mozmill-crowd.blargon7.com/#/endurance/report/1641bc2f6438595b86015bd9010e090e
Update:
http://mozmill-crowd.blargon7.com/#/update/report/1641bc2f6438595b86015bd9010e3df0
http://mozmill-crowd.blargon7.com/#/update/report/1641bc2f6438595b86015bd9010e433e
Reports for Release are:
Addons: http://mozmill-crowd.blargon7.com/#/addons/report/1641bc2f6438595b86015bd9010ed1a9
Functional:
http://mozmill-crowd.blargon7.com/#/functional/report/1641bc2f6438595b86015bd9010e997f
http://mozmill-crowd.blargon7.com/#/functional/report/1641bc2f6438595b86015bd9010e79b5
Endurance:
http://mozmill-crowd.blargon7.com/#/endurance/report/1641bc2f6438595b86015bd9010eaa5a
Update:
http://mozmill-crowd.blargon7.com/#/update/report/1641bc2f6438595b86015bd9010e5f7a
http://mozmill-crowd.blargon7.com/#/update/report/1641bc2f6438595b86015bd9010e6170
Reports for ESR17 are:
Addons: http://mozmill-crowd.blargon7.com/#/addons/report/1641bc2f6438595b86015bd90110941d
Functional:
http://mozmill-crowd.blargon7.com/#/functional/report/1641bc2f6438595b86015bd901105ce9
http://mozmill-crowd.blargon7.com/#/functional/report/1641bc2f6438595b86015bd901104333
Endurance:
http://mozmill-crowd.blargon7.com/#/endurance/report/1641bc2f6438595b86015bd9011079f2
Update:
http://mozmill-crowd.blargon7.com/#/update/report/1641bc2f6438595b86015bd9010ff515
http://mozmill-crowd.blargon7.com/#/update/report/1641bc2f6438595b86015bd9010fffe1
Attachment #710611 -
Flags: review?(andreea.matei)
Comment 16•12 years ago
|
||
Comment on attachment 710611 [details] [diff] [review]
patch v1.0 Beta, Release and ESR17
Review of attachment 710611 [details] [diff] [review]:
-----------------------------------------------------------------
Applies cleanly to those branches, same changes, just none on the PB lib since there is none.
Thanks Daniela!
Attachment #710611 -
Flags: review?(andreea.matei) → review+
Updated•12 years ago
|
Keywords: checkin-needed
Comment 17•12 years ago
|
||
Comment on attachment 710611 [details] [diff] [review]
patch v1.0 Beta, Release and ESR17
Review of attachment 710611 [details] [diff] [review]:
-----------------------------------------------------------------
http://hg.mozilla.org/qa/mozmill-tests/rev/7bceb2f73376 (aurora)
http://hg.mozilla.org/qa/mozmill-tests/rev/8af96aa9d78b (beta)
http://hg.mozilla.org/qa/mozmill-tests/rev/50140dba1409 (release)
http://hg.mozilla.org/qa/mozmill-tests/rev/79516aaf58a6 (esr17)
Attachment #710611 -
Flags: checkin+
Updated•12 years ago
|
Assignee | ||
Comment 18•12 years ago
|
||
The patch for Beta got landed on Aurora. The patch for default needs to be landed on Aurora.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Comment 19•12 years ago
|
||
Sorry that was my fault. Thanks for checking!
http://hg.mozilla.org/qa/mozmill-tests/rev/e38882bd9467 (backout)
http://hg.mozilla.org/qa/mozmill-tests/rev/eb6a9f4c7221 (transplant from default)
Status: REOPENED → RESOLVED
Closed: 12 years ago → 12 years ago
Resolution: --- → FIXED
Updated•6 years ago
|
Product: Mozilla QA → Mozilla QA Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•