Closed
Bug 1249055
Opened 9 years ago
Closed 9 years ago
Calling alarms.getAll() throws an exception: TypeError: alarms.map is not a function
Categories
(WebExtensions :: Untriaged, defect)
WebExtensions
Untriaged
Tracking
(firefox47 fixed)
Tracking | Status | |
---|---|---|
firefox47 | --- | fixed |
People
(Reporter: bsilverberg, Assigned: bsilverberg)
References
Details
Attachments
(1 file)
JavaScript error: chrome://extensions/content/ext-alarms.js, line 130: TypeError: alarms.map is not a function
This is because `alarms` [1] is a Set not an Array.
[1] https://dxr.mozilla.org/mozilla-central/source/toolkit/components/extensions/ext-alarms.js#130
Assignee | ||
Updated•9 years ago
|
Assignee: nobody → bob.silverberg
Status: NEW → ASSIGNED
Flags: blocking-webextensions+
Assignee | ||
Comment 1•9 years ago
|
||
Review commit: https://reviewboard.mozilla.org/r/35287/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/35287/
Attachment #8720390 -
Flags: review?(kmaglione+bmo)
Assignee | ||
Comment 2•9 years ago
|
||
Note that I also changed a bit of the boilerplate in the other tests in `test_ext_alarms.html` to match my chosen syntax for the new test, which I think is a bit cleaner.
Blocks: 1190320
Assignee | ||
Comment 3•9 years ago
|
||
Comment on attachment 8720390 [details]
MozReview Request: Bug 1249055 - Calling alarms.getAll() throws an exception, r?kmag
Review request updated; see interdiff: https://reviewboard.mozilla.org/r/35287/diff/1-2/
Assignee | ||
Comment 4•9 years ago
|
||
I fixed another bug that was in `get()` and added coverage for get(), getAll() and clearAll(). I think there is room for improvement in the test. In particular, I feel like the test depends on the different methods being called in sequence, but I'm not sure that the way the test is written guarantees that will happen.
This is now ready for an initial review, Kris.
Comment 5•9 years ago
|
||
Comment on attachment 8720390 [details]
MozReview Request: Bug 1249055 - Calling alarms.getAll() throws an exception, r?kmag
https://reviewboard.mozilla.org/r/35287/#review32015
::: toolkit/components/extensions/ext-alarms.js:130
(Diff revision 2)
> - let result = alarms.map(alarm => alarm.data);
> + let result = Array.from(alarms).map(alarm => alarm.data);
`Array.from(alarms, alarm => alarm.data)`
::: toolkit/components/extensions/test/mochitest/test_ext_alarms.html:115
(Diff revision 2)
> + suffixes.map(suffix => {
Please use `.forEach` or a for-of loop rather than `.map`. Same below.
::: toolkit/components/extensions/test/mochitest/test_ext_alarms.html:116
(Diff revision 2)
> + chrome.alarms.create(ALARM_NAME + suffix, {when: Date.now() + suffix});
0-3 milliseconds is not a lot. Some of these are going to fire before you check them when we switch to OOP extensions.
::: toolkit/components/extensions/test/mochitest/test_ext_alarms.html:117
(Diff revision 2)
> + return suffix;
This isn't used.
::: toolkit/components/extensions/test/mochitest/test_ext_alarms.html:136
(Diff revision 2)
> + browser.test.assertEq("undefined", typeof alarm, "non-existent alarm should be undefined");
Please compare against `undefined` rather than using `typeof`
::: toolkit/components/extensions/test/mochitest/test_ext_alarms.html:140
(Diff revision 2)
> + chrome.alarms.clearAll(wasCleared => {
We should also test `.clear()` here. I know it's tested above, but it seems strange for it to be the only API method not tested in this task.
::: toolkit/components/extensions/test/mochitest/test_ext_alarms.html:145
(Diff revision 2)
> + browser.test.sendMessage("clearAll");
This should be sent from the `getAll` callback.
Attachment #8720390 -
Flags: review?(kmaglione+bmo)
Assignee | ||
Comment 6•9 years ago
|
||
Comment on attachment 8720390 [details]
MozReview Request: Bug 1249055 - Calling alarms.getAll() throws an exception, r?kmag
Review request updated; see interdiff: https://reviewboard.mozilla.org/r/35287/diff/2-3/
Attachment #8720390 -
Flags: review?(kmaglione+bmo)
Assignee | ||
Comment 7•9 years ago
|
||
Comment on attachment 8720390 [details]
MozReview Request: Bug 1249055 - Calling alarms.getAll() throws an exception, r?kmag
Review request updated; see interdiff: https://reviewboard.mozilla.org/r/35287/diff/3-4/
Assignee | ||
Comment 8•9 years ago
|
||
https://reviewboard.mozilla.org/r/35287/#review32015
> This should be sent from the `getAll` callback.
I nested the various tests in a way that I believe will ensure that they get executed in the correct order. I wonder if it would be better to do this with `then()` instead of all this nesting. What do you think?
Assignee | ||
Comment 9•9 years ago
|
||
https://reviewboard.mozilla.org/r/35287/#review32015
> I nested the various tests in a way that I believe will ensure that they get executed in the correct order. I wonder if it would be better to do this with `then()` instead of all this nesting. What do you think?
I tried to rewrite it using `then()` but I think the alarms API isn't written in a way that allows that. It seems to insist that I pass a callback into methods like `get()` and `clear()`.
Comment 10•9 years ago
|
||
https://reviewboard.mozilla.org/r/35287/#review32015
> I tried to rewrite it using `then()` but I think the alarms API isn't written in a way that allows that. It seems to insist that I pass a callback into methods like `get()` and `clear()`.
Yeah, that's going to be a problem until they're updated to use schema bindings.
Assignee | ||
Comment 11•9 years ago
|
||
https://reviewboard.mozilla.org/r/35287/#review32015
> Yeah, that's going to be a problem until they're updated to use schema bindings.
I've started working on some of the other missing coverage, but it's going to depend on this patch because of the bug fixes. Do you think we can land this soon, or would you prefer that I just keep adding more coverage to this patch?
Comment 12•9 years ago
|
||
This is ready to land. I thought I gave it an r+, but mozreview...
Comment 13•9 years ago
|
||
Comment on attachment 8720390 [details]
MozReview Request: Bug 1249055 - Calling alarms.getAll() throws an exception, r?kmag
https://reviewboard.mozilla.org/r/35287/#review32235
Attachment #8720390 -
Flags: review?(kmaglione+bmo) → review+
Assignee | ||
Comment 14•9 years ago
|
||
Assignee | ||
Comment 15•9 years ago
|
||
Thanks Kris! Pushing to try and I'll mark it for checkin once try is happy.
Assignee | ||
Updated•9 years ago
|
Keywords: checkin-needed
Assignee | ||
Updated•9 years ago
|
Iteration: --- → 47.3 - Mar 7
Comment 16•9 years ago
|
||
bugherder landing |
Keywords: checkin-needed
Comment 17•9 years ago
|
||
https://hg.mozilla.org/integration/fx-team/rev/9cf43731a81106da80a5ca3e3bd066d551666a9b
Bug 1249055: Follow-up: Fix ESLint errors. r=me
Comment 18•9 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/38e5c1ca1eda
https://hg.mozilla.org/mozilla-central/rev/9cf43731a811
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
status-firefox47:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla47
Updated•6 years ago
|
Product: Toolkit → WebExtensions
You need to log in
before you can comment on or make changes to this bug.
Description
•