Bug 1585769 - Create a fresh <video> element for the Picture-in-Picture player window rather than cloning the original element. r=JSON_voorhees

Cloning the original node was needed when we needed the MediaInfo copied over, but
HTMLVideoElement::CloneElementVisually copies it over for us, so we can create a
fresh <video> element. This should also be a much healthier thing to do
security-wise, since we're not cloning strange nodes from the web.

Differential Revision: https://phabricator.services.mozilla.com/D48123

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Mike Conley 2019-10-10 13:57:48 +00:00
Родитель 77daa88970
Коммит 51b7a87654
1 изменённых файлов: 1 добавлений и 14 удалений

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

@ -947,21 +947,8 @@ class PictureInPictureChild extends ActorChild {
} }
let doc = this.content.document; let doc = this.content.document;
// Clone the original video to get its MediaInfo (specifically, it's dimensions) let playerVideo = doc.createElement("video");
// set right away, but also pause the video since we don't need two copies of it
// playing at the same time. The originating video will be "projected" onto the
// cloned Picture-in-Picture player video via cloneElementVisually.
let playerVideo = originatingVideo.cloneNode();
playerVideo.pause();
playerVideo.removeAttribute("controls");
// Mute the video and rely on the originating video's audio playback.
// This way, we sidestep the AutoplayPolicy blocking stuff.
playerVideo.muted = true;
// Strip any inline styles off of the video, and try to get rid of any surrounding
// whitespace.
playerVideo.setAttribute("style", "");
doc.body.style.overflow = "hidden"; doc.body.style.overflow = "hidden";
doc.body.style.margin = "0"; doc.body.style.margin = "0";