blob: 143b16a749e024b35e86f4731da2a0b84cbb685d [file] [log] [blame]
<!DOCTYPE html>
<html>
<title>Media Controls: Test controls layout correctly in different small sizes.</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../media-controls.js"></script>
<video controls></video>
<script>
async_test(t => {
const video = document.querySelector('video');
video.src = '../content/test.ogv';
video.onloadedmetadata = t.step_func(() => {
// We are testing the changing of sizes instead of single test cases
// because the layout flilkering issue typically happen when changing
// from small size to big size.
const testCases = [ 400, 100, 180, 200, 100, 200, 100, 250, 100, 300 ];
const buttonPanel = buttonPanelElement(video);
const overflowBtn = overflowButton(video);
runTestCase(0);
function runTestCase(index) {
let test = testCases[index];
video.width = test;
testRunner.layoutAndPaintAsyncThen(t.step_func(() => {
expectLayoutCorrectly();
assert_not_equals(getComputedStyle(overflowBtn), 'none',
'Overflow button should always be visible');
let nextIndex = index + 1;
if (nextIndex === testCases.length) {
t.done();
return;
}
runTestCase(nextIndex);
}));
}
function expectLayoutCorrectly() {
let totalWidth = 0;
let children = buttonPanel.children;
for (let i = 0; i < children.length; i++) {
let child = children[i];
if (getComputedStyle(child).display != 'none')
totalWidth += child.getBoundingClientRect().width;
}
assert_true(totalWidth <= buttonPanel.getBoundingClientRect().width,
'All element should fit in button panel');
}
});
});
</script>
</html>