Closed
Bug 756607
Opened 13 years ago
Closed 13 years ago
Rewrite device WebAPI Marionette tests
Categories
(Core :: DOM: Device Interfaces, defect)
Tracking
()
RESOLVED
FIXED
mozilla15
People
(Reporter: philikon, Assigned: philikon)
References
Details
Attachments
(3 files, 2 obsolete files)
7.25 KB,
patch
|
jgriffin
:
review+
|
Details | Diff | Splinter Review |
2.77 KB,
patch
|
jgriffin
:
review+
|
Details | Diff | Splinter Review |
28.08 KB,
patch
|
jgriffin
:
review+
|
Details | Diff | Splinter Review |
With bug 754178 and bug 754216 in place, we can start writing simpler Marionette tests against some device WebAPIs entirely in JS.
Assignee | ||
Comment 1•13 years ago
|
||
Assignee: nobody → philipp
Attachment #626136 -
Flags: review?(jgriffin)
Comment 2•13 years ago
|
||
Comment on attachment 626136 [details] [diff] [review]
Part 1 (v1): Rewrite battery tests
Review of attachment 626136 [details] [diff] [review]:
-----------------------------------------------------------------
Looks good.
For code like so:
> runEmulatorCmd("power status not-charging", function(result) {
> is(result[0], "OK");
>
> ok(EventTracker.seen.chargingchange, "Seen a 'chargingchange' event");
> verifyAPI(discharging);
> });
it seems we're assuming that the change to the battery state will propagate into the gecko event handler by the time the Marionette emulator callback is fired...will that always be the case? I have no idea.
Attachment #626136 -
Flags: review?(jgriffin) → review+
Assignee | ||
Comment 3•13 years ago
|
||
(In reply to Jonathan Griffin (:jgriffin) from comment #2)
> it seems we're assuming that the change to the battery state will propagate
> into the gecko event handler by the time the Marionette emulator callback is
> fired...will that always be the case? I have no idea.
From my observation I thought this was the case. But you're right, we should probably not rely on this. I'll look into writing a helper to synchronize on both events/callbacks so that we don't depend on their order.
Comment 4•13 years ago
|
||
(In reply to Philipp von Weitershausen [:philikon] from comment #3)
> (In reply to Jonathan Griffin (:jgriffin) from comment #2)
> > it seems we're assuming that the change to the battery state will propagate
> > into the gecko event handler by the time the Marionette emulator callback is
> > fired...will that always be the case? I have no idea.
>
> From my observation I thought this was the case. But you're right, we should
> probably not rely on this. I'll look into writing a helper to synchronize on
> both events/callbacks so that we don't depend on their order.
Maybe it's a safe bet. The Marionette event has to go out to the Python testrunner via telnet, and then back into gecko over the remote debugger socket, so perhaps it will always be slow enough that the gecko event handler will get notified first.
I'm not following closely but relying on timing is not a good idea. Can we investigate a way to strongly order what needs to be ordered here?
Assignee | ||
Comment 6•13 years ago
|
||
(In reply to Chris Jones [:cjones] [:warhammer] from comment #5)
> I'm not following closely but relying on timing is not a good idea. Can we
> investigate a way to strongly order what needs to be ordered here?
I'm pretty sure we can't guarantee an order of events happening between multiple processes that are talking over telnet sockets and emulated devices etc. I think the only thing we can expect here is to correlate two events.
Let's chat. IRC ping outstanding.
(In reply to Chris Jones [:cjones] [:warhammer] from comment #7)
> Let's chat. IRC ping outstanding.
Was there a conclusion to this that can be rolled up into the bug?
Assignee | ||
Comment 9•13 years ago
|
||
cjones raised a good point in our IRC discussion: when we're talking to the emulator to manipulate state, we really only care about the resulting Gecko event. If the emulator response code indicates a failure, we're hosed anyway and the whole run is pretty much invalid. Marionette already checks emulator return codes, so where appropriate, the test flow should be controlled by Gecko events. Filed bug 758448 to make runEmulatorCmd callbacks optional.
Attachment #626136 -
Attachment is obsolete: true
Attachment #627034 -
Flags: review?(jgriffin)
Comment on attachment 627034 [details] [diff] [review]
Part 1 (v2): Rewrite battery tests
Re: not wanting to go off the emulator for order, wouldn't that apply to stuff like full() or discharging() too?
I suspect you're using the emulator because we don't expect an event to fire, but I think that leaves the code open to a race where it calls verifyAPI before an extraneous event fires and doesn't realize it fired.
Instead, perhaps it should wait to see if an event fires within a fixed timeout, and pass when it does not.
Also,
+ runEmulatorCmd("power capacity " + newCapacity);
+
+ battery.onlevelchange = function onlevelchange(event) {
+ battery.onlevelchange = unexpectedEvent;
+ verifyAPI(charging);
+ };
I realize the chance that the event fires before the assignment to onlevelchange can happen is slim, but would the safest bet be to assign the handler before running the emulator command?
Assignee | ||
Comment 11•13 years ago
|
||
(In reply to Geo Mealer [:geo] from comment #10)
> Comment on attachment 627034 [details] [diff] [review]
> Part 1 (v2): Rewrite battery tests
>
> Re: not wanting to go off the emulator for order, wouldn't that apply to
> stuff like full() or discharging() too?
>
> I suspect you're using the emulator because we don't expect an event to
> fire,
Correct. In fact, we fail if we see events firing, thanks to unexpectedEvent.
> but I think that leaves the code open to a race where it calls
> verifyAPI before an extraneous event fires and doesn't realize it fired.
>
> Instead, perhaps it should wait to see if an event fires within a fixed
> timeout, and pass when it does not.
Proving the non-existence of an event is always tricky. In the cases you're worried about, an event would have to race at least two runEmulatorCmd() calls. I find that pretty unlikely. But ok, if you would feel better, we can play the waiting game like you suggest. I just find it hard to come up with a number that works on developer machines as well as CI.
> + runEmulatorCmd("power capacity " + newCapacity);
> +
> + battery.onlevelchange = function onlevelchange(event) {
> + battery.onlevelchange = unexpectedEvent;
> + verifyAPI(charging);
> + };
>
> I realize the chance that the event fires before the assignment to
> onlevelchange can happen is slim, but would the safest bet be to assign the
> handler before running the emulator command?
It's impossible. JS is single threaded, nothing can run between those two lines.
Comment 12•13 years ago
|
||
Comment on attachment 627034 [details] [diff] [review]
Part 1 (v2): Rewrite battery tests
Looks good. I'm not sure what to do to verify that events don't occur either; waiting a couple of seconds is probably generally safe, but there's never any guarantee...
Attachment #627034 -
Flags: review?(jgriffin) → review+
Thanks for the clarification re: threading and why you're unconcerned. I'll have to reconcile my understanding of async functions with that (mostly when control of the thread can pass). It'll be a fun exercise. :)
Re: the waiting, it's true that the best we could do is "no event within N time." Sounds like you don't think it's terribly valuable and is a lot of hassle and I'm fine going with your instinct on it.
OTOH, if we had a general pattern or helper for that, there are a lot of APIs that throw events that could use it. We can always revisit that later.
Assignee | ||
Comment 14•13 years ago
|
||
Started converting the telephony tests. A couple of empty tests still, will tackle those asap.
Attachment #627082 -
Flags: feedback?(jgriffin)
Assignee | ||
Comment 15•13 years ago
|
||
Also got a WIP for SMS tests.
Comment 16•13 years ago
|
||
Comment on attachment 627082 [details] [diff] [review]
Part 2 (WIP 1): Rewrite telephony tests
Review of attachment 627082 [details] [diff] [review]:
-----------------------------------------------------------------
Nice, I like!
::: dom/telephony/test/marionette/test_outgoing_answer_hangup.js
@@ +33,5 @@
> + ok(outgoing);
> + is(outgoing.number, number);
> + is(outgoing.state, "dialing");
> +
> + //is(ouygoing, telephony.active); // bug 757587
ouygoing -> outgoing
Attachment #627082 -
Flags: feedback?(jgriffin) → feedback+
Assignee | ||
Comment 17•13 years ago
|
||
Still a bunch of stuff to do on this front, but I think we should defer these to follow-ups. Filed bug 759521, 757587, 759533.
Attachment #627082 -
Attachment is obsolete: true
Attachment #628118 -
Flags: review?(jgriffin)
Assignee | ||
Comment 18•13 years ago
|
||
Comment on attachment 627084 [details] [diff] [review]
Part 3 (v1): Rewrite SMS tests
I'm going to call this ready for now. Filed bug 759529 for testing outgoing SMS separately.
Attachment #627084 -
Attachment description: Part 3 (WIP 1): Rewrite SMS tests → Part 3 (v1): Rewrite SMS tests
Attachment #627084 -
Flags: review?(jgriffin)
Comment 19•13 years ago
|
||
Comment on attachment 628118 [details] [diff] [review]
Part 2 (v1): Rewrite telephony tests
Review of attachment 628118 [details] [diff] [review]:
-----------------------------------------------------------------
Looks great!
Attachment #628118 -
Flags: review?(jgriffin) → review+
Updated•13 years ago
|
Attachment #627084 -
Flags: review?(jgriffin) → review+
Assignee | ||
Comment 20•13 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/c1ad9e9f6632
https://hg.mozilla.org/mozilla-central/rev/013b22ee36b7
https://hg.mozilla.org/mozilla-central/rev/1c1318dbdf55
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla15
You need to log in
before you can comment on or make changes to this bug.
Description
•