Closed Bug 775580 Opened 12 years ago Closed 12 years ago

Remove calls to addVisit from test_sorting.js

Categories

(Toolkit :: Places, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla20

People

(Reporter: Paolo, Assigned: Paolo)

References

Details

Attachments

(1 file, 2 obsolete files)

This "pilot" bug removes one instance of nested asynchronous addVisit calls.

The same approach could be applied in various other places as well.
Attached patch The patch (obsolete) — Splinter Review
This includes new promiseAsyncUpdates and promiseAddVisits helpers.
Assignee: nobody → paolo.mozmail
Status: NEW → ASSIGNED
Attachment #643873 - Flags: feedback?(mak77)
Attachment #643873 - Flags: feedback?(mak77) → feedback?(dteller)
Blocks: 776465
Depends on: 763311
Comment on attachment 643873 [details] [diff] [review]
The patch

Review of attachment 643873 [details] [diff] [review]:
-----------------------------------------------------------------

Looks good to me, thanks.
Attachment #643873 - Flags: feedback+
Attached patch Updated patch (obsolete) — Splinter Review
This adds the final version of the promiseAddVisits function.
Attachment #643873 - Attachment is obsolete: true
Attachment #683501 - Flags: review?(mak77)
Comment on attachment 683501 [details] [diff] [review]
Updated patch

Review of attachment 683501 [details] [diff] [review]:
-----------------------------------------------------------------

::: toolkit/components/places/tests/head_common.js
@@ +942,5 @@
> + * on success, or reports a test error on failure.
> + *
> + * @see promiseAddVisits
> + */
> +function addVisits(aPlaceInfo, aCallback, aStack)

please file a follow-up bug to get rid of this duplicated helper, we should just switch everything to the promiseAddVisits version.

Add a "@note deprecated, please use promiseAddVisits instead."

::: toolkit/components/places/tests/queries/test_sorting.js
@@ +1267,2 @@
>        // sorting reversed, usually SORT_BY have ASC and DESC
> +      yield test.check_reverse();

most setup(), all of check() and all of check_reverse() calls are synchronous and don't return anything, doesn't yield require to get a promise? Is this voodoo magic from Task?
(In reply to Marco Bonardo [:mak] from comment #4)
> most setup(), all of check() and all of check_reverse() calls are
> synchronous and don't return anything, doesn't yield require to get a
> promise? Is this voodoo magic from Task?

OK I think I got an answer by the fact Task just continues if yield is not a promise. Though looks strange to use it in check and check_reverse, I couldn't find an async case there.
(In reply to Marco Bonardo [:mak] from comment #5)
> OK I think I got an answer by the fact Task just continues if yield is not a
> promise. Though looks strange to use it in check and check_reverse, I
> couldn't find an async case there.

Yeah, this is done on purpose (see the Task.jsm documentation) to avoid pitfalls
that may happen when you batch-remove a call that is not needed anymore, and
doing that you also remove the last yield call. For example, before:

  add_task(function test() {
    yield prepareLegacyDataStructures();
    do_check_true(featureIsOk);
  });

And after:

  add_task(function test() {
    do_check_true(featureIsOk);
  });

This is trivial here, but may not be so obvious in longer test functions. In
this case it's the other way around, in case you need to add a yield statement.
(In reply to Paolo Amadini [:paolo] from comment #6)
> (In reply to Marco Bonardo [:mak] from comment #5)
> > OK I think I got an answer by the fact Task just continues if yield is not a
> > promise. Though looks strange to use it in check and check_reverse, I
> > couldn't find an async case there.
> 
> Yeah, this is done on purpose (see the Task.jsm documentation) to avoid
> pitfalls
> that may happen when you batch-remove a call that is not needed anymore, and
> doing that you also remove the last yield call. For example, before:

the test timeouts in such a case, doesn't it? So it's a detectable issue once you do the change and see the test fails.
Attached patch Revised patchSplinter Review
Attachment #683501 - Attachment is obsolete: true
Attachment #687066 - Flags: review?(mak77)
Attachment #687066 - Flags: review?(mak77) → review+
https://hg.mozilla.org/integration/mozilla-inbound/rev/d8c571638b32
Target Milestone: --- → mozilla20
https://hg.mozilla.org/mozilla-central/rev/d8c571638b32
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: