Commit 5dea3e1e authored by François Beaufort's avatar François Beaufort Committed by Commit Bot

[Picture-in-Picture] Fix shadow dom crash when exiting PiP.

This CL fixes a tab crash that occurs when calling document.exitPictureInPicture()
if a video in a shadow DOM is already in Picture-in-Picture.

Bug: 904828

Change-Id: I6aed0fa43dd0af1406d4349509101d423f622d96
Reviewed-on: https://chromium-review.googlesource.com/c/1333769Reviewed-by: default avatarMounir Lamouri <mlamouri@chromium.org>
Commit-Queue: François Beaufort <beaufort.francois@gmail.com>
Cr-Commit-Position: refs/heads/master@{#607658}
parent 1a0f3a1b
...@@ -58,5 +58,6 @@ promise_test(async t => { ...@@ -58,5 +58,6 @@ promise_test(async t => {
assert_equals(ids.root4.pictureInPictureElement, null); assert_equals(ids.root4.pictureInPictureElement, null);
assert_equals(ids.root5.pictureInPictureElement, null); assert_equals(ids.root5.pictureInPictureElement, null);
}) })
.then(() => document.exitPictureInPicture());
}); });
</script> </script>
...@@ -32,8 +32,7 @@ ScriptPromise DocumentPictureInPicture::exitPictureInPicture( ...@@ -32,8 +32,7 @@ ScriptPromise DocumentPictureInPicture::exitPictureInPicture(
Document& document) { Document& document) {
PictureInPictureControllerImpl& controller = PictureInPictureControllerImpl& controller =
PictureInPictureControllerImpl::From(document); PictureInPictureControllerImpl::From(document);
Element* picture_in_picture_element = Element* picture_in_picture_element = controller.PictureInPictureElement();
controller.PictureInPictureElement(document);
if (!picture_in_picture_element) { if (!picture_in_picture_element) {
return ScriptPromise::RejectWithDOMException( return ScriptPromise::RejectWithDOMException(
......
...@@ -193,6 +193,10 @@ void PictureInPictureControllerImpl::OnPictureInPictureControlClicked( ...@@ -193,6 +193,10 @@ void PictureInPictureControllerImpl::OnPictureInPictureControlClicked(
} }
} }
Element* PictureInPictureControllerImpl::PictureInPictureElement() const {
return picture_in_picture_element_;
}
Element* PictureInPictureControllerImpl::PictureInPictureElement( Element* PictureInPictureControllerImpl::PictureInPictureElement(
TreeScope& scope) const { TreeScope& scope) const {
if (!picture_in_picture_element_) if (!picture_in_picture_element_)
......
...@@ -46,6 +46,7 @@ class PictureInPictureControllerImpl : public PictureInPictureController { ...@@ -46,6 +46,7 @@ class PictureInPictureControllerImpl : public PictureInPictureController {
Status IsDocumentAllowed() const; Status IsDocumentAllowed() const;
// Returns element currently in Picture-in-Picture if any. Null otherwise. // Returns element currently in Picture-in-Picture if any. Null otherwise.
Element* PictureInPictureElement() const;
Element* PictureInPictureElement(TreeScope&) const; Element* PictureInPictureElement(TreeScope&) const;
// Implementation of PictureInPictureController. // Implementation of PictureInPictureController.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment