forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Media Controls] Prevent crash when video is removed on click
This CL adds an isConnected check in the overlay play button's click positioning check to prevent a crash when trying to access the layout data after it's been removed. Bug: 870490, 881772 Change-Id: Ic005ae9d3acc2945ed67645bfe98a237c89e38f0 Reviewed-on: https://chromium-review.googlesource.com/1217065 Reviewed-by: Becca Hughes <[email protected]> Commit-Queue: Tommy Steimel <[email protected]> Cr-Commit-Position: refs/heads/master@{#590058}
- Loading branch information
1 parent
a1f0a5b
commit 98a5ecf
Showing
2 changed files
with
37 additions
and
2 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
third_party/WebKit/LayoutTests/media/controls/remove-on-click-does-not-crash.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<title>Test that when a video is removed on click it does not crash.</title> | ||
<script src="../../resources/testharness.js"></script> | ||
<script src="../../resources/testharnessreport.js"></script> | ||
<script src="../media-controls.js"></script> | ||
<video controls width=500 preload=none src="../content/60_sec_video.webm"></video> | ||
<script> | ||
async_test(t => { | ||
const video = document.querySelector('video'); | ||
|
||
video.addEventListener('click', t.step_func_done(() => { | ||
video.parentNode.removeChild(video); | ||
}), { once: true }); | ||
|
||
video.addEventListener('loadedmetadata', t.step_func(() => { | ||
const coords = getOverlayPlayButtonEdgeCoordinates(); | ||
singleTapAtCoordinates(coords[0], coords[1]); | ||
})); | ||
|
||
function getOverlayPlayButtonEdgeCoordinates() { | ||
const overlayPlayBtn = mediaControlsOverlayPlayButton(video); | ||
const rect = overlayPlayBtn.getBoundingClientRect(); | ||
const x = rect.left + 5; | ||
const y = rect.top + 5; | ||
return [x, y]; | ||
} | ||
|
||
video.load(); | ||
}); | ||
</script> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters