Backed out changeset 50141dc32966 (bug 1677080) for causing failures in browser_changePiPSrcInFullscreen.js CLOSED TREE

This commit is contained in:
Noemi Erli 2021-01-20 22:49:33 +02:00
Родитель 6df60ec3bc
Коммит b06a920288
4 изменённых файлов: 5 добавлений и 293 удалений

Просмотреть файл

@ -487,25 +487,12 @@ var PictureInPicture = {
// then save the location and size for opening the new window
let isPlayerWindow =
windowOrPlayer == this.getWeakPipPlayer(actorReference);
if (
isPlayerWindow &&
windowOrPlayer.windowState != windowOrPlayer.STATE_FULLSCREEN
) {
if (isPlayerWindow) {
this.savePosition(windowOrPlayer);
}
let sizeLocation;
// The size and location of the PiP window is stored before the PiP enters
// fullscreen and we will use that information to calculate where it will
// be placed after it exits fullscreen
if (windowOrPlayer.windowState == windowOrPlayer.STATE_FULLSCREEN) {
sizeLocation = windowOrPlayer.getDeferredResize();
} else {
sizeLocation = this.loadPosition();
}
let { top, left, width, height } = sizeLocation;
// The last PiP location and size
let { top, left, width, height } = this.loadPosition();
// Check that previous location and size were loaded
if (!isNaN(top) && !isNaN(left) && !isNaN(width) && !isNaN(height)) {
@ -665,8 +652,8 @@ var PictureInPicture = {
videoData,
actorRef
);
win.resizeToVideo(left, top, width, height);
win.resizeTo(width, height);
win.moveTo(left, top);
},
openToggleContextMenu(window, data) {

Просмотреть файл

@ -70,29 +70,6 @@ function setIsMutedState(isMuted) {
Player.isMuted = isMuted;
}
/**
* Function to resize and reposition the PiP player window
* @param left (int)
* X coordinate
* @param top (int)
* Y coordinate
* @param width (int)
* width
* @param height (int)
* height
*/
function resizeToVideo(left, top, width, height) {
Player.resizeToVideo(left, top, width, height);
}
/**
* Need the size and location of the PiP window before it was fullscreened
* to calculate the new position of the PiP window when it exits fullscreen
*/
function getDeferredResize() {
return Player.deferredResize;
}
/**
* The Player object handles initializing the player, holds state, and handles
* events for updating state.
@ -124,12 +101,6 @@ let Player = {
lastScreenY: -1,
id: -1,
/**
* Used to store size and location of the PiP window when entering/exiting
* fullscren
*/
deferredResize: null,
/**
* When set to a non-null value, a timer is scheduled to hide the controls
* after CONTROLS_FADE_TIMEOUT_MS milliseconds.
@ -300,14 +271,6 @@ let Player = {
Services.obs.notifyObservers(window, "fullscreen-painted");
}
});
// Need to check that we are exiting fullscreen because
// MozDOMFullscreen:Entered has an intentional fall-through and we only
// want to resize after we exit fullscreen
if (this.deferredResize && event.type == "MozDOMFullscreen:Exited") {
let { left, top, width, height } = this.deferredResize;
this.resizeToVideo(left, top, width, height);
this.deferredResize = null;
}
break;
}
@ -343,43 +306,12 @@ let Player = {
if (document.fullscreenElement == document.body) {
document.exitFullscreen();
} else {
// Store the size and location so we know where to put the PiP window after
// it exits fullscreen
this.deferredResize = {
left: window.screenX,
top: window.screenY,
width: window.innerWidth,
height: window.innerHeight,
};
document.body.requestFullscreen();
}
event.preventDefault();
}
},
/**
* Will take in the new size and location for the PiP window and will move
* and resize if not fullscreened. If fullscreened, store for when fullscreen
* is exited
* @param left (int)
* new left position for PiP window
* @param top (int)
* new top position for PiP window
* @param width (int)
* new width for PiP window
* @param height (int)
* new height for PiP window
*/
resizeToVideo(left, top, width, height) {
if (document.fullscreenElement == document.body) {
// store because we can't resize and move the PiP while fullscreened
this.deferredResize = { left, top, width, height };
} else {
window.resizeTo(width, height);
window.moveTo(left, top);
}
},
onClick(event) {
switch (event.target.id) {
case "audio": {

Просмотреть файл

@ -30,7 +30,6 @@ prefs =
media.videocontrols.picture-in-picture.video-toggle.has-used=true
[browser_cannotTriggerFromContent.js]
[browser_changePiPSrcInFullscreen.js]
[browser_closePipPause.js]
[browser_contextMenu.js]
skip-if = os == "linux" && bits == 64 && os_version == "18.04" # Bug 1569205

Просмотреть файл

@ -1,206 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
* This function tests changing the src of a Picture-in-Picture player while
* the player is fullscreened and then ensuring the that video stays
* fullscreened after the src change and that the player will resize to the new
* video size.
*/
add_task(async () => {
await BrowserTestUtils.withNewTab(
{
url: TEST_PAGE,
gBrowser,
},
async browser => {
async function switchVideoSource(src) {
await ContentTask.spawn(browser, { src }, async ({ src }) => {
let doc = content.document;
let video = doc.getElementById("no-controls");
video.src = src;
});
}
const NEW_VIDEO_ASPECT_RATIO = 1.334;
function checkIfEqual(val1, val2, str) {
let equal = Math.abs(val1 - val2);
if (equal <= 1) {
is(equal <= 1, true, str);
} else {
is(val1, val2, str);
}
}
let pipWin = await triggerPictureInPicture(browser, "no-controls");
let resizeCount = 0;
pipWin.addEventListener("resize", e => {
resizeCount++;
});
let left = 100;
let top = 100;
pipWin.moveTo(left, top);
let width = pipWin.innerWidth / 2;
let height = pipWin.innerHeight / 2;
pipWin.resizeTo(width, height);
await BrowserTestUtils.waitForCondition(() => resizeCount == 1);
let controls = pipWin.document.getElementById("controls");
await promiseFullscreenEntered(pipWin, async () => {
EventUtils.sendMouseEvent(
{
type: "dblclick",
},
controls,
pipWin
);
});
Assert.equal(
pipWin.document.fullscreenElement,
pipWin.document.body,
"Double-click caused us to enter fullscreen."
);
await BrowserTestUtils.waitForCondition(() => resizeCount == 2);
await switchVideoSource("test-video.mp4");
await promiseFullscreenExited(pipWin, async () => {
EventUtils.sendMouseEvent(
{
type: "dblclick",
},
controls,
pipWin
);
});
Assert.ok(
!pipWin.document.fullscreenElement,
"Double-click caused us to exit fullscreen."
);
// Would be 4 but two resizes that happen very close together are
// optimized by "coalescing" the two resizes into one resize
await BrowserTestUtils.waitForCondition(() => resizeCount == 3);
checkIfEqual(pipWin.screenX, left, "PiP in same X location");
checkIfEqual(pipWin.screenY, top, "PiP in same Y location");
checkIfEqual(pipWin.innerHeight, height, "PiP has same height");
checkIfEqual(pipWin.innerWidth, width, "PiP has same width");
await ensureMessageAndClosePiP(browser, "no-controls", pipWin, true);
pipWin = await triggerPictureInPicture(browser, "no-controls");
resizeCount = 0;
pipWin.addEventListener("resize", e => {
resizeCount++;
});
controls = pipWin.document.getElementById("controls");
await promiseFullscreenEntered(pipWin, async () => {
EventUtils.sendMouseEvent(
{
type: "dblclick",
},
controls,
pipWin
);
});
Assert.equal(
pipWin.document.fullscreenElement,
pipWin.document.body,
"Double-click caused us to enter fullscreen."
);
await BrowserTestUtils.waitForCondition(() => resizeCount == 1);
await switchVideoSource("test-video-long.mp4");
await promiseFullscreenExited(pipWin, async () => {
EventUtils.synthesizeKey("KEY_Escape", {}, pipWin);
});
Assert.ok(
!pipWin.document.fullscreenElement,
"Double-click caused us to exit fullscreen."
);
// Would be 3 but two resizes that happen very close together are
// optimized by "coalescing" the two resizes into one resize
await BrowserTestUtils.waitForCondition(() => resizeCount == 2);
checkIfEqual(pipWin.screenX, left, "PiP in same X location");
checkIfEqual(pipWin.screenY, top, "PiP in same Y location");
checkIfEqual(pipWin.innerHeight, height, "PiP has same height");
checkIfEqual(
pipWin.innerWidth,
height * NEW_VIDEO_ASPECT_RATIO,
"PiP has same width"
);
await ensureMessageAndClosePiP(browser, "no-controls", pipWin, true);
pipWin = await triggerPictureInPicture(browser, "no-controls");
resizeCount = 0;
pipWin.addEventListener("resize", e => {
resizeCount++;
});
controls = pipWin.document.getElementById("controls");
await promiseFullscreenEntered(pipWin, async () => {
EventUtils.sendMouseEvent(
{
type: "dblclick",
},
controls,
pipWin
);
});
Assert.equal(
pipWin.document.fullscreenElement,
pipWin.document.body,
"Double-click caused us to enter fullscreen."
);
await BrowserTestUtils.waitForCondition(() => resizeCount == 1);
await promiseFullscreenExited(pipWin, async () => {
EventUtils.synthesizeKey("KEY_Escape", {}, pipWin);
});
Assert.ok(
!pipWin.document.fullscreenElement,
"Double-click caused us to exit fullscreen."
);
await BrowserTestUtils.waitForCondition(() => resizeCount == 2);
checkIfEqual(pipWin.screenX, left, "PiP in same X location");
checkIfEqual(pipWin.screenY, top, "PiP in same Y location");
checkIfEqual(pipWin.innerHeight, height, "PiP has same height");
checkIfEqual(
pipWin.innerWidth,
height * NEW_VIDEO_ASPECT_RATIO,
"PiP has same width"
);
await ensureMessageAndClosePiP(browser, "no-controls", pipWin, true);
}
);
});