Closed Bug 1599803 Opened 5 years ago Closed 4 years ago

Factor out repeated logic in Picture-in-Picture tests

Categories

(Toolkit :: Video/Audio Controls, task, P3)

task

Tracking

()

RESOLVED FIXED
82 Branch
Tracking Status
firefox82 --- fixed

People

(Reporter: mconley, Assigned: reidshina6)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

We have a number of PiP tests that follow this pattern:

  1. Cause the PiP player window to open
  2. Do a check of some kind
  3. Close the player window, and wait for the "This video is playing in Picture-in-Picture mode" message to go away in the originating video

Example: https://searchfox.org/mozilla-central/rev/cce8b90aece0f42e5025e45282de16066eeaa662/toolkit/components/pictureinpicture/tests/browser_thirdPartyIframe.js#21-46

We can / should probably factor this repeated stuff out into a helper method inside of head.js instead of repeating ourselves again and again.

It's also unclear whether those try / catch / finally blocks are really helpful.

Blocks: 1662870
Assignee: nobody → reidshina6

Here are 3 instances of us doing the same things in some tests:

I think we can factor these out into a helper. Our helper functions for the PiP tests go in this file:

https://searchfox.org/mozilla-central/rev/5d45da52f2fa423c9f4505ede5d1a5c7d48163fc/toolkit/components/pictureinpicture/tests/head.js

So I recommend factoring those 3 instances out into a helper function in head.js with a signature like this:


async function ensureMessageAndClosePiP(browser, videoID, pipWin) {
  //...
}

Do add a docstring above the helper function, and then update the 3 instances I listed above to use it.

You can run the tests by using:

./mach mochitest <path to test>

example:

./mach mochitest toolkit/components/pictureinpicture/tests/browser_keyboardShortcut.js
Pushed by mconley@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/31d155c12756
Factor out repeated logic in Picture-in-Picture tests. r=mconley
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 82 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: