Commit 7723a589 authored by lukasza's avatar lukasza Committed by Commit bot

Fix a race - synchronize test completion with media's loadstart event.

Presence of OOPIFs introduces a delay into loading of cross-origin media and
exposes a race in the
http/tests/security/mixedContent/insecure-audio-video-in-main-frame.html
test.  To get rid of the race, we should wait until media has actually
started to load, before posting / reporting that the test is "done".

BUG=582541
TEST=The affected test passes when run 100 times with and without --site-per-process flag.

Review URL: https://codereview.chromium.org/1703333002

Cr-Commit-Position: refs/heads/master@{#376065}
parent 41f2fe9d
......@@ -78,9 +78,6 @@ http/tests/security/xssAuditor/full-block-script-tag-cross-domain.html [ Failure
http/tests/security/xssAuditor/full-block-post-from-iframe.html [ Failure ]
http/tests/security/xssAuditor/xss-protection-parsing-01.html [ Failure ]
# https://crbug.com/582541 - MixedContentChecker::shouldBlockFetch returns false with --site-per-process
http/tests/security/mixedContent/insecure-audio-video-in-main-frame.html [ Failure ]
# https://crbug.com/582522 - extra mixedContent checks reported with --site-per-process
http/tests/security/mixedContent/insecure-iframe-in-iframe.html [ Failure ]
......
......@@ -3,13 +3,31 @@
<video></video>
<script>
window.addEventListener('load', function () {
var windowOpener = window.opener;
var isAudioLoaded = false;
var isVideoLoaded = false;
function checkTestCompletion() {
if (isAudioLoaded && isVideoLoaded && windowOpener) {
windowOpener.postMessage('done', '*');
}
}
// Assigning via JavaScript after 'load' rather than direclty in the
// markup in order to avoid the console's flaky "what line am I on?"
// autodetection.
document.querySelector('audio').src = "http://127.0.0.1:8080/resources/test.mp4";
document.querySelector('video').src = "http://127.0.0.1:8080/resources/test.mp4";
if (window.opener)
window.opener.postMessage('done', '*');
var audioElement = document.querySelector('audio');
audioElement.src = "http://127.0.0.1:8080/resources/test.mp4";
audioElement.addEventListener("loadstart", function(event) {
isAudioLoaded = true;
checkTestCompletion();
});
var videoElement = document.querySelector('video');
videoElement.src = "http://127.0.0.1:8080/resources/test.mp4";
videoElement.addEventListener("loadstart", function(event) {
isVideoLoaded = true;
checkTestCompletion();
});
});
</script>
</body>
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