Closed Bug 1490333 Opened 6 years ago Closed 6 years ago

Move whenIdle to sync module

Categories

(Remote Protocol :: Marionette, enhancement, P1)

enhancement

Tracking

(firefox64 fixed)

RESOLVED FIXED
mozilla64
Tracking Status
firefox64 --- fixed

People

(Reporter: ato, Assigned: ato)

References

Details

Attachments

(1 file)

The private whenIdle function in testing/marionette/driver.js has
since I wrote it been picked up in other contexts that initially
intended, which means we now need to access it from different places
throughout Marionette.

In preparation for the window tracking refactoring we need to make
it available across JSMs.  Moving it to testing/marionette/sync.js
is an obvious fix.
Assignee: nobody → ato
Status: NEW → ASSIGNED
Priority: -- → P1
This patch moves the private whenIdle function to sync so it can
be shared across JSMs.

It also changes its semantics somewhat, so that instead of taking
a callback function (suitable for DOM event callbacks) it returns
a promise that is resolved when the main thread becomes idle and
the window has completed an animation frame tick.
Attachment #9008085 - Flags: review?(hskupin)
Comment on attachment 9008085 [details] [diff] [review]
marionette: move whenIdle to sync module

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

::: testing/marionette/driver.js
@@ +3663,3 @@
>      window.fullScreen = false;
>    });
> +  await new IdlePromise(window);

Should we better move the assignment of `window.fullscreen` to after this line? Otherwise we could end-up in a race if something fails in `IdlePromise`.

::: testing/marionette/sync.js
@@ +15,5 @@
>  
>  XPCOMUtils.defineLazyGetter(this, "logger", Log.get);
>  
>  this.EXPORTED_SYMBOLS = [
> +  "IdlePromise",

Mind adding at least a basic xpcshell test for it?
Attachment #9008085 - Flags: review?(hskupin) → review+
Comment on attachment 9008085 [details] [diff] [review]
marionette: move whenIdle to sync module

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

::: testing/marionette/driver.js
@@ +3663,3 @@
>      window.fullScreen = false;
>    });
> +  await new IdlePromise(window);

We shouldn’t do this, because the effect we want to achieve is to
induce a delay _after_ switching out of fullscreen that is long
enough for the browser to not think it’s in fullscreen mode anymore.
Waiting for the main thread to become idle before exiting fullscreen
would have the opposite effect.

::: testing/marionette/sync.js
@@ +15,5 @@
>  
>  XPCOMUtils.defineLazyGetter(this, "logger", Log.get);
>  
>  this.EXPORTED_SYMBOLS = [
> +  "IdlePromise",

Sorry, I forgot to do this.  It seems Services.tm is available, so
this shouldn’t be a problem.
Pushed by ato@sny.no:
https://hg.mozilla.org/integration/mozilla-inbound/rev/3624871612dd
marionette: move whenIdle to sync module; r=whimboo
(In reply to Andreas Tolfsen ❲:ato❳ from comment #4)
> ::: testing/marionette/driver.js
> @@ +3663,3 @@
> >      window.fullScreen = false;
> >    });
> > +  await new IdlePromise(window);
> 
> We shouldn’t do this, because the effect we want to achieve is to
> induce a delay _after_ switching out of fullscreen that is long
> enough for the browser to not think it’s in fullscreen mode anymore.
> Waiting for the main thread to become idle before exiting fullscreen
> would have the opposite effect.

That is not what I was asking. My point was that `window.fullScreen` should be set to `false` **after** the idle promise has been resolved.
Please scratch my last comment because I totally misread the code. Sorry.
Pushed by ato@sny.no:
https://hg.mozilla.org/integration/mozilla-inbound/rev/567ccbeb5a4f
marionette: move whenIdle to sync module; r=whimboo
Fixed the dangling comma.

Addressed misunderstanding with whimboo on IRC.
Flags: needinfo?(ato)
https://hg.mozilla.org/mozilla-central/rev/567ccbeb5a4f
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla64
Product: Testing → Remote Protocol
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: