mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 943556 - Attempt to fix intermittent orange by using a later event (play instead of loadedmetadata) to check for media element sizes. Also include debugging information for the user agent. Also introduce a waitForCondition to wait until the replaced element has finished resizing based on the videocontrols resizing code. r=Gijs
This commit is contained in:
parent
93be7d818e
commit
42c76cbfe9
23
toolkit/content/tests/widgets/head.js
Normal file
23
toolkit/content/tests/widgets/head.js
Normal file
@ -0,0 +1,23 @@
|
||||
"use strict";
|
||||
|
||||
function waitForCondition(condition, nextTest, errorMsg) {
|
||||
var tries = 0;
|
||||
var interval = setInterval(function() {
|
||||
if (tries >= 30) {
|
||||
ok(false, errorMsg);
|
||||
moveOn();
|
||||
}
|
||||
var conditionPassed;
|
||||
try {
|
||||
conditionPassed = condition();
|
||||
} catch (e) {
|
||||
ok(false, e + "\n" + e.stack);
|
||||
conditionPassed = false;
|
||||
}
|
||||
if (conditionPassed) {
|
||||
moveOn();
|
||||
}
|
||||
tries++;
|
||||
}, 100);
|
||||
var moveOn = function() { clearInterval(interval); nextTest(); };
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
[DEFAULT]
|
||||
support-files =
|
||||
head.js
|
||||
tree_shared.js
|
||||
videocontrols_direction-1-ref.html
|
||||
videocontrols_direction-1a.html
|
||||
|
@ -4,6 +4,7 @@
|
||||
<title>Video controls test</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
||||
<script type="text/javascript" src="head.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
@ -23,22 +24,29 @@ var popup = window.open("seek_with_sound.ogg");
|
||||
popup.addEventListener("load", function onLoad() {
|
||||
popup.removeEventListener("load", onLoad);
|
||||
var video = getMediaElement(popup);
|
||||
if (video.readyState >= video.HAVE_METADATA)
|
||||
if (!video.paused)
|
||||
runTestVideo(video);
|
||||
else {
|
||||
video.addEventListener("loadedmetadata", function onLoadedMetaData() {
|
||||
video.removeEventListener("loadedmetadata", onLoadedMetaData);
|
||||
video.addEventListener("play", function onPlay() {
|
||||
video.removeEventListener("play", onPlay);
|
||||
runTestVideo(video);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
function runTestVideo(aVideo) {
|
||||
var boundingRect = aVideo.getBoundingClientRect();
|
||||
is(boundingRect.width, videoWidth, "Width of the video should match expectation");
|
||||
is(boundingRect.height, videoHeight, "Height of video should match expectation");
|
||||
popup.close();
|
||||
runTestAudioPre();
|
||||
var condition = function() {
|
||||
var boundingRect = aVideo.getBoundingClientRect();
|
||||
return boundingRect.width == videoWidth &&
|
||||
boundingRect.height == videoHeight;
|
||||
};
|
||||
waitForCondition(condition, function() {
|
||||
var boundingRect = aVideo.getBoundingClientRect();
|
||||
is(boundingRect.width, videoWidth, "Width of the video should match expectation");
|
||||
is(boundingRect.height, videoHeight, "Height of video should match expectation");
|
||||
popup.close();
|
||||
runTestAudioPre();
|
||||
}, "The media element should eventually be resized to match the intrinsic size of the video.");
|
||||
}
|
||||
|
||||
function runTestAudioPre() {
|
||||
@ -46,11 +54,11 @@ function runTestAudioPre() {
|
||||
popup.addEventListener("load", function onLoad() {
|
||||
popup.removeEventListener("load", onLoad);
|
||||
var audio = getMediaElement(popup);
|
||||
if (audio.readyState >= audio.HAVE_METADATA)
|
||||
if (!audio.paused)
|
||||
runTestAudio(audio);
|
||||
else {
|
||||
audio.addEventListener("loadedmetadata", function onLoadedMetaData() {
|
||||
audio.removeEventListener("loadedmetadata", onLoadedMetaData);
|
||||
audio.addEventListener("play", function onPlay() {
|
||||
audio.removeEventListener("play", onPlay);
|
||||
runTestAudio(audio);
|
||||
})
|
||||
}
|
||||
@ -58,13 +66,20 @@ function runTestAudioPre() {
|
||||
}
|
||||
|
||||
function runTestAudio(aAudio) {
|
||||
var boundingRect = aAudio.getBoundingClientRect();
|
||||
var isAndroid = (navigator.userAgent.indexOf("Android") !== -1);
|
||||
info("User agent (help diagnose bug #943556): " + navigator.userAgent);
|
||||
var isAndroid = navigator.userAgent.contains("Android");
|
||||
var expectedHeight = isAndroid ? 123 : 28;
|
||||
is(boundingRect.height, expectedHeight,
|
||||
"Height of audio element should be " + expectedHeight + ", which is equal to the controls bar.");
|
||||
popup.close();
|
||||
SimpleTest.finish();
|
||||
var condition = function () {
|
||||
var boundingRect = aAudio.getBoundingClientRect();
|
||||
return boundingRect.height == expectedHeight;
|
||||
};
|
||||
waitForCondition(condition, function () {
|
||||
var boundingRect = aAudio.getBoundingClientRect();
|
||||
is(boundingRect.height, expectedHeight,
|
||||
"Height of audio element should be " + expectedHeight + ", which is equal to the controls bar.");
|
||||
popup.close();
|
||||
SimpleTest.finish();
|
||||
}, "The media element should eventually be resized to match the height of the audio controls.");
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
Loading…
Reference in New Issue
Block a user