Closed Bug 1190320 Opened 9 years ago Closed 9 years ago

Test coverage for alarms extension API

Categories

(WebExtensions :: Untriaged, defect)

defect
Not set
normal

Tracking

(firefox47 fixed)

RESOLVED FIXED
mozilla47
Iteration:
47.3 - Mar 7
Tracking Status
firefox47 --- fixed

People

(Reporter: gkrizsanits, Assigned: bsilverberg)

References

Details

Attachments

(1 file)

Blocks: 1185459
This API is still missing coverage for: * Alarms with a |when| property. * Observer callbacks for canceled alarms being ignored. * Extant alarms being cleared on extension shutdown. * The |get|, |getAll|, and |clearAll| API methods. * The one-argument forms of |alarms.create| and |alarms.clear| (although these should be replaced by schema checks). * |alarms.clear| ignoring alarms without matching names. https://people.mozilla.org/~kmaglione/webextension-test-coverage/toolkit/components/extensions/ext-alarms.js.html
Component: Extension Compatibility → WebExtensions
Product: Firefox → Toolkit
Flags: blocking-webextensions-
Flags: blocking-webextensions- → blocking-webextensions+
I'm going to attempt to work on this. Wish me luck!
Assignee: nobody → bob.silverberg
Status: NEW → ASSIGNED
Depends on: 1249055
I've got a patch just about ready that adds all of the missing coverage above, except for the part about checking that alarms are cleared on extension shutdown. I'm not sure how to do that, i.e., check the state of alarms after the extension has been shutdown. Do you have any suggestions?
Iteration: --- → 47.3 - Mar 7
Add new alarm coverage: * Alarms with a |when| property. * Observer callbacks for canceled alarms being ignored. * The one-argument forms of |alarms.create| and |alarms.clear|. * |alarms.clear| ignoring alarms without matching names. Review commit: https://reviewboard.mozilla.org/r/36243/diff/#index_header See other reviews: https://reviewboard.mozilla.org/r/36243/
Attachment #8722791 - Flags: review?(kmaglione+bmo)
Comment on attachment 8722791 [details] MozReview Request: Bug 1190320 - Test coverage for alarms extension API, r?kmag https://reviewboard.mozilla.org/r/36243/#review32805 ::: toolkit/components/extensions/test/mochitest/test_ext_alarms.html:69 (Diff revision 1) > + browser.test.log("running test_cleared_alarm_does_not_fire"); These aren't really necessary. The name of the task function is printed before each test is run. ::: toolkit/components/extensions/test/mochitest/test_ext_alarms.html:71 (Diff revision 1) > + chrome.alarms.onAlarm.addListener(function(alarm) { Please use an arrow function. Same for the others. Also, please use "browser." rather than "chrome." ::: toolkit/components/extensions/test/mochitest/test_ext_alarms.html:72 (Diff revision 1) > + browser.test.notifyFail("cleared alarm does not fire"); Just `browser.test.fail(`. `notifyPass` and `notifyFail` should always have the same argument. ::: toolkit/components/extensions/test/mochitest/test_ext_alarms.html:107 (Diff revision 1) > + browser.test.notifyFail("alarm fired within expected time"); `notifyFail` should have the same argument as `awaitFinish`. You can have a separate `browser.test.fail` and `browser.test.notifyFail`, though. Also, this timeout should be canceled when you receive the alarm callback. ::: toolkit/components/extensions/test/mochitest/test_ext_alarms.html:131 (Diff revision 1) > + chrome.alarms.clear(ALARM_NAME + 1, wasCleared => { Please use "1" to make it clear you're adding this to a string rather than a number.
Attachment #8722791 - Flags: review?(kmaglione+bmo) → review+
Comment on attachment 8722791 [details] MozReview Request: Bug 1190320 - Test coverage for alarms extension API, r?kmag Review request updated; see interdiff: https://reviewboard.mozilla.org/r/36243/diff/1-2/
Note that, as I commented above, I don't think I covered the case you described as: * Extant alarms being cleared on extension shutdown. How would I test that alarms are cleared after an extension is shutdown?
Flags: needinfo?(kmaglione+bmo)
(In reply to Bob Silverberg [:bsilverberg] from comment #7) > Note that, as I commented above, I don't think I covered the case you > described as: > > * Extant alarms being cleared on extension shutdown. > > How would I test that alarms are cleared after an extension is shutdown? Probably just by importing Extension.jsm and making sure the entries are gone. This has to be done from a chrome test, though.
Flags: needinfo?(kmaglione+bmo)
This one seems to have eslint issues as well. Were there just some new rules added? I have eslint running on commit locally and it didn't catch these either. I just tried to rebase against fx-team to pick up the changes that you made to the other alarm test and I somehow messed it up totally. I seem to have lost most of my changes. I'm calling it a day for tonight, but I'll probably ask for some help with this tomorrow.
A rule for whitespace inside curly brackets was added last week. Aside from that, try now runs ESLint checks by default. Before, you had to ask for them to be run. Er, yeah, sorry about the rebase. I had to make some pretty noisy changes to fix the callback depth issue.
Comment on attachment 8722791 [details] MozReview Request: Bug 1190320 - Test coverage for alarms extension API, r?kmag Review request updated; see interdiff: https://reviewboard.mozilla.org/r/36243/diff/2-3/
I fixed the eslint issues and rebased correctly (I think). Pushed to try again to see what happens.
Try looks good!
Keywords: checkin-needed
Oops, that was an older try push I was looking at. The most recent one is still at 53%, but looking good so far.
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla47
Product: Toolkit → WebExtensions
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: