Closed Bug 1656016 Opened 5 years ago Closed 5 years ago

Write automated test(s) to cover manual test 'PiP window controls functionality .'

Categories

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

task

Tracking

()

RESOLVED FIXED
81 Branch
Tracking Status
firefox81 --- fixed

People

(Reporter: tracy, Assigned: tracy)

References

Details

Attachments

(1 file)

PiP window controls functionality is a manual test we'd like to automate. This test checks basic functionality of the PiP controls.

Assignee: nobody → twalker
Status: NEW → ASSIGNED

So the way this test would work is:

  1. Pref on the mute/unmute toggle, which is only enabled in Nightly for now.
  2. Open up a PiP window for a video that is playing
  3. Click on the "pause" button in the player, and ensure that the video pauses
  4. Click on the "play" button in the player, and ensure that the video plays again
  5. Click on the "mute" button in the player and ensure that the video mutes
  6. Click on the "unmute" button in the player and ensure that the video unmutes
  7. Click on the "unpip" button in the player and ensure that the PiP player window closes and the video continues to play
  8. Re-open the PiP window on the playing video, and then click on the "close" button. Ensure that the PiP player window closes, and the video is paused.

The pre-existing tests are in toolkit/components/pictureinpicture/tests and can be used as reference. The head.js file contains some pretty handy shared functions that can take care of a lot of boiler plate.

I recommend getting started by adding the test with the ./mach addtest command, like so:

./mach addtest toolkit/components/pictureinpicture/tests/browser_playerControls.js

You can run the test while developing using:

./mach mochitest toolkit/components/pictureinpicture/tests/browser_playerControls.js

I'd start by looking at toolkit/components/pictureinpicture/tests/browser_showMessage.js to see how it works. Note that it's testing two different types of videos (with and without the controls attribute), which I don't think will be necessary for this test. Just choosing one is fine.

The test opens up a new tab, and then does:

let pipWin = await triggerPictureInPicture(browser, videoID);

That's key - that's going to get you your player window. You can then access the DOM for the player window via pipWin.document. So, for example, to get the play/pause toggle button, you should be able to do:

let playPause = pipWin.document.getElementById("playpause");
playPause.click(); // If the video is playing, this should pause it.

For things like play, pause, mute and unmute, you'll want to then check the state of the video after the button is clicked. You can do that using SpecialPowers.spawn to run a function within the content area to get access to the underlying video element and look at its properties. Some examples: https://searchfox.org/mozilla-central/rev/56bb74ea8e04bdac57c33cbe9b54d889b9262ade/toolkit/components/pictureinpicture/tests/browser_closePlayer.js#14-23

This should hopefully get you started. Let me know if and when you get stuck, and I'll guide you through.

Depends on: 1656610
Severity: -- → S3
Priority: -- → P1
Pushed by mconley@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/0e8938777f94 Add test for PiP player controls r=mconley

Backed out changeset 0e8938777f94 (bug 1656016) for browser_playerControls.js failures

Push with failures: https://treeherder.mozilla.org/#/jobs?repo=autoland&group_state=expanded&fromchange=0e8938777f94c4099ab02920868bba784095c8c7&searchStr=mochitest-browser-chrome&tochange=25802f39f81f187335d779d3152f6fc14ed06d96&selectedTaskRun=GU5XoNe0TUq5hfmL78EHYA.0

Backout link: https://hg.mozilla.org/integration/autoland/rev/25802f39f81f187335d779d3152f6fc14ed06d96

Failure log: https://treeherder.mozilla.org/logviewer.html#/jobs?job_id=312400548&repo=autoland&lineNumber=7307

[task 2020-08-07T15:22:22.041Z] 15:22:22     INFO - TEST-START | toolkit/components/pictureinpicture/tests/browser_playerControls.js
[task 2020-08-07T15:22:22.658Z] 15:22:22     INFO - TEST-INFO | started process screentopng
[task 2020-08-07T15:22:23.647Z] 15:22:23     INFO - TEST-INFO | screentopng: exit 0
[task 2020-08-07T15:22:23.648Z] 15:22:23     INFO - Buffered messages logged at 15:22:22
[task 2020-08-07T15:22:23.649Z] 15:22:23     INFO - Entering test bound 
[task 2020-08-07T15:22:23.650Z] 15:22:23     INFO - Testing with-controls case.
[task 2020-08-07T15:22:23.651Z] 15:22:23     INFO - Waiting for videos to be ready
[task 2020-08-07T15:22:23.652Z] 15:22:23     INFO - TEST-PASS | toolkit/components/pictureinpicture/tests/browser_playerControls.js | Got Picture-in-Picture window. - 
[task 2020-08-07T15:22:23.652Z] 15:22:23     INFO - TEST-PASS | toolkit/components/pictureinpicture/tests/browser_playerControls.js | The video is not paused - 
[task 2020-08-07T15:22:23.653Z] 15:22:23     INFO - TEST-PASS | toolkit/components/pictureinpicture/tests/browser_playerControls.js | The video is paused - 
[task 2020-08-07T15:22:23.654Z] 15:22:23     INFO - Buffered messages finished
[task 2020-08-07T15:22:23.655Z] 15:22:23     INFO - TEST-UNEXPECTED-FAIL | toolkit/components/pictureinpicture/tests/browser_playerControls.js | The video is playing - 
[task 2020-08-07T15:22:23.655Z] 15:22:23     INFO - Stack trace:
[task 2020-08-07T15:22:23.656Z] 15:22:23     INFO - chrome://mochikit/content/browser-test.js:test_ok:1299
[task 2020-08-07T15:22:23.656Z] 15:22:23     INFO - chrome://mochitests/content/browser/toolkit/components/pictureinpicture/tests/browser_playerControls.js:null:50
[task 2020-08-07T15:22:23.656Z] 15:22:23     INFO - TEST-PASS | toolkit/components/pictureinpicture/tests/browser_playerControls.js | The audio is playing - 
[task 2020-08-07T15:22:23.656Z] 15:22:23     INFO - TEST-PASS | toolkit/components/pictureinpicture/tests/browser_playerControls.js | The audio is muted - 
[task 2020-08-07T15:22:23.656Z] 15:22:23     INFO - Not taking screenshot here: see the one that was previously logged
[task 2020-08-07T15:22:23.657Z] 15:22:23     INFO - TEST-UNEXPECTED-FAIL | toolkit/components/pictureinpicture/tests/browser_playerControls.js | The audio is playing - 
[task 2020-08-07T15:22:23.657Z] 15:22:23     INFO - Stack trace:
[task 2020-08-07T15:22:23.657Z] 15:22:23     INFO - chrome://mochikit/content/browser-test.js:test_ok:1299
[task 2020-08-07T15:22:23.657Z] 15:22:23     INFO - chrome://mochitests/content/browser/toolkit/components/pictureinpicture/tests/browser_playerControls.js:null:59
[task 2020-08-07T15:22:23.658Z] 15:22:23     INFO - Not taking screenshot here: see the one that was previously logged
[task 2020-08-07T15:22:23.659Z] 15:22:23     INFO - TEST-UNEXPECTED-FAIL | toolkit/components/pictureinpicture/tests/browser_playerControls.js | The video is not paused - 
[task 2020-08-07T15:22:23.659Z] 15:22:23     INFO - Stack trace:
[task 2020-08-07T15:22:23.660Z] 15:22:23     INFO - chrome://mochikit/content/browser-test.js:test_ok:1299
[task 2020-08-07T15:22:23.660Z] 15:22:23     INFO - chrome://mochitests/content/browser/toolkit/components/pictureinpicture/tests/browser_playerControls.js:null:66
[task 2020-08-07T15:22:23.661Z] 15:22:23     INFO - TEST-PASS | toolkit/components/pictureinpicture/tests/browser_playerControls.js | Got Picture-in-Picture window. - 
[task 2020-08-07T15:22:23.662Z] 15:22:23     INFO - Not taking screenshot here: see the one that was previously logged
[task 2020-08-07T15:22:23.662Z] 15:22:23     INFO - TEST-UNEXPECTED-FAIL | toolkit/components/pictureinpicture/tests/browser_playerControls.js | The video is not paused - 
[task 2020-08-07T15:22:23.663Z] 15:22:23     INFO - Stack trace:
[task 2020-08-07T15:22:23.663Z] 15:22:23     INFO - chrome://mochikit/content/browser-test.js:test_ok:1299
[task 2020-08-07T15:22:23.663Z] 15:22:23     INFO - chrome://mochitests/content/browser/toolkit/components/pictureinpicture/tests/browser_playerControls.js:null:71
[task 2020-08-07T15:22:23.665Z] 15:22:23     INFO - TEST-PASS | toolkit/components/pictureinpicture/tests/browser_playerControls.js | The video is paused - 
[task 2020-08-07T15:22:23.665Z] 15:22:23     INFO - Leaving test bound 
[task 2020-08-07T15:22:23.666Z] 15:22:23     INFO - GECKO(21953) | MEMORY STAT | vsize 3478MB | residentFast 359MB | heapAllocated 137MB
[task 2020-08-07T15:22:23.668Z] 15:22:23     INFO - TEST-OK | toolkit/components/pictureinpicture/tests/browser_playerControls.js | took 1214ms
Flags: needinfo?(twalker)

Mike, unpause of the paused video failed. Any ideas why this is failing in production?

Flags: needinfo?(mconley)

Answered in Phabricator.

Flags: needinfo?(mconley)

Patch on the way. However, I need to get access to try restored (see bug 1658335), to confirm raciness is fixed there.

Flags: needinfo?(twalker)
Pushed by mconley@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/4dbe45d42066 Add test for PiP player controls r=mconley
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → 81 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: