mirror of
https://github.com/jellyfin/jellyfin-web.git
synced 2024-11-18 11:28:23 -07:00
172 lines
13 KiB
HTML
172 lines
13 KiB
HTML
<!doctype html>
|
|
<!--
|
|
@license
|
|
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
|
|
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
|
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
|
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
|
Code distributed by Google as part of the polymer project is also
|
|
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
|
-->
|
|
<html>
|
|
<head>
|
|
|
|
<title>paper-dialog-scrollable tests</title>
|
|
|
|
<meta charset="utf-8">
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
|
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes">
|
|
|
|
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
|
|
|
|
<script src="../../web-component-tester/browser.js"></script>
|
|
<script src="../../test-fixture/test-fixture-mocha.js"></script>
|
|
|
|
<link rel="import" href="../../test-fixture/test-fixture.html">
|
|
<link rel="import" href="../paper-dialog-scrollable.html">
|
|
|
|
<link rel="import" href="../../iron-flex-layout/classes/iron-flex-layout.html">
|
|
|
|
<style>
|
|
.fixed-height {
|
|
height: 400px;
|
|
}
|
|
</style>
|
|
|
|
</head>
|
|
<body>
|
|
|
|
<test-fixture id="basic">
|
|
<template>
|
|
<section class="fixed-height layout vertical">
|
|
<div class="header">Header</div>
|
|
<paper-dialog-scrollable class="flex">
|
|
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
|
|
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
|
|
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
|
|
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
|
|
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
|
|
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
|
|
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
|
|
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
|
|
</paper-dialog-scrollable>
|
|
<div class="footer">Footer</div>
|
|
</section>
|
|
</template>
|
|
</test-fixture>
|
|
|
|
<test-fixture id="only-child">
|
|
<template>
|
|
<section class="fixed-height layout vertical">
|
|
<paper-dialog-scrollable class="flex">
|
|
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
|
|
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
|
|
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
|
|
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
|
|
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
|
|
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
|
|
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
|
|
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
|
|
</paper-dialog-scrollable>
|
|
</section>
|
|
</template>
|
|
</test-fixture>
|
|
|
|
<test-fixture id="short">
|
|
<template>
|
|
<section class="fixed-height layout vertical">
|
|
<div class="header">Header</div>
|
|
<paper-dialog-scrollable class="flex">
|
|
<p>Hello world!</p>
|
|
</paper-dialog-scrollable>
|
|
<div class="footer">Footer</div>
|
|
</section>
|
|
</template>
|
|
</test-fixture>
|
|
|
|
<script>
|
|
|
|
function runAfterScroll(node, scrollTop, callback) {
|
|
var timeout = function() {
|
|
node.scrollTop = scrollTop;
|
|
if (node.scrollTop === scrollTop) {
|
|
// there seems to be no good way to wait for pseudoelement styling to apply and
|
|
// chrome takes a while before getComputedStyle returns the correct values
|
|
setTimeout(function() {
|
|
callback();
|
|
}, 250);
|
|
} else {
|
|
setTimeout(timeout, 10);
|
|
}
|
|
};
|
|
node.scrollTop = scrollTop;
|
|
setTimeout(timeout);
|
|
}
|
|
|
|
suite('basic', function() {
|
|
|
|
test('shows top divider if scrolled', function(done) {
|
|
var container = fixture('basic');
|
|
var scrollable = Polymer.dom(container).querySelector('paper-dialog-scrollable');
|
|
setTimeout(function() {
|
|
runAfterScroll(scrollable.scrollTarget, 10, function() {
|
|
assert.ok(getComputedStyle(scrollable, '::before').content, '::before has content');
|
|
done();
|
|
});
|
|
}, 10);
|
|
});
|
|
|
|
test('shows bottom divider if scrollable', function(done) {
|
|
var container = fixture('basic');
|
|
setTimeout(function() {
|
|
var scrollable = Polymer.dom(container).querySelector('paper-dialog-scrollable');
|
|
requestAnimationFrame(function() {
|
|
assert.ok(getComputedStyle(scrollable, '::after').content, '::after has content');
|
|
done();
|
|
});
|
|
}, 10);
|
|
});
|
|
|
|
test('hides bottom divider if scrolled to bottom', function(done) {
|
|
var container = fixture('basic');
|
|
var scrollable = Polymer.dom(container).querySelector('paper-dialog-scrollable');
|
|
setTimeout(function() {
|
|
runAfterScroll(scrollable.scrollTarget, scrollable.scrollTarget.scrollHeight - scrollable.scrollTarget.offsetHeight, function() {
|
|
var content = getComputedStyle(scrollable, '::after').content;
|
|
assert.ok(!content || content === 'none', '::after does not have content');
|
|
done();
|
|
});
|
|
}, 10);
|
|
});
|
|
|
|
test('does not show dividers if scrolled and only child', function(done) {
|
|
var container = fixture('only-child');
|
|
var scrollable = Polymer.dom(container).querySelector('paper-dialog-scrollable');
|
|
setTimeout(function() {
|
|
runAfterScroll(scrollable.scrollTarget, 10, function() {
|
|
var contentBefore = getComputedStyle(scrollable, '::before').content;
|
|
assert.ok(!contentBefore || contentBefore === 'none', '::before does not have content');
|
|
var contentAfter = getComputedStyle(scrollable, '::after').content;
|
|
assert.ok(!contentAfter || contentAfter === 'none', '::after does not have content');
|
|
done();
|
|
});
|
|
}, 10);
|
|
});
|
|
|
|
test('does not show bottom divider if not scrollable', function(done) {
|
|
var container = fixture('short');
|
|
setTimeout(function() {
|
|
var scrollable = Polymer.dom(container).querySelector('paper-dialog-scrollable');
|
|
var contentAfter = getComputedStyle(scrollable, '::after').content;
|
|
assert.ok(!contentAfter || contentAfter === 'none', '::after does not have content');
|
|
done();
|
|
}, 10);
|
|
});
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
</body>
|
|
</html>
|