Add a test of nsITimer delay change semantics

NEW
Unassigned

Status

()

Core
XPCOM
7 years ago
7 years ago

People

(Reporter: jrmuizel, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

7 years ago
Created attachment 561728 [details] [diff] [review]
test nsITimer delay change semantics

While investigating redoing nsITimer I came across some unexpected semantics of changing the delay on repeated timers. I created a test case to document the current semantics to ensure any changes are intentional.
Attachment #561728 - Flags: review?(ehsan)

Comment 1

7 years ago
Comment on attachment 561728 [details] [diff] [review]
test nsITimer delay change semantics

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

::: xpcom/tests/unit/test_nsITimer_delaychange.js
@@ +21,5 @@
> +	  } else if (count == 1) {
> +	      // we only need two ticks so cancel the timer
> +	      timer.cancel();
> +	  } else  {
> +	      abort();

Where is this function defined?

@@ +29,5 @@
> +
> +    timer2 = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
> +    timer2.initWithCallback(function() {
> +	// check that number of times that first timer has fired matches our expectations
> +	do_check_true(count == expectedCount);

Use do_check_eq please.

@@ +33,5 @@
> +	do_check_true(count == expectedCount);
> +	
> +	do_test_finished();
> +
> +	}, 166, timer2.TYPE_ONE_SHOT);

Where are these magic numbers coming from?

@@ +40,5 @@
> +
> +  test_timer(Ci.nsITimer.TYPE_REPEATING_SLACK, 2);
> +  test_timer(Ci.nsITimer.TYPE_REPEATING_PRECISE_CAN_SKIP, 2);
> +  // It's weird that REPEATING_PRECISE timers behave differently here
> +  test_timer(Ci.nsITimer.TYPE_REPEATING_PRECISE, 1);

Can you also document the semantics that you're testing here?

::: xpcom/tests/unit/xpcshell.ini
@@ +39,5 @@
>  [test_systemInfo.js]
>  # Bug 676998: test fails consistently on Android
>  fail-if = os == "android"
>  [test_versioncomparator.js]
> +[test_nsITimer_delaychange.js ]

Please keep the manifest file alphabetically sorted.
Attachment #561728 - Flags: review?(ehsan)
You need to log in before you can comment on or make changes to this bug.