2016-03-04 20:39:49 -07:00
|
|
|
<!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>
|
|
|
|
<meta charset="UTF-8">
|
|
|
|
<title>paper-drawer-panel tests</title>
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
|
|
|
|
|
|
|
|
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
|
|
|
|
<script src="../../web-component-tester/browser.js"></script>
|
|
|
|
|
|
|
|
<link rel="import" href="../paper-drawer-panel.html">
|
|
|
|
<link rel="import" href="../../iron-test-helpers/iron-test-helpers.html">
|
|
|
|
|
|
|
|
</head>
|
|
|
|
<style>
|
|
|
|
body {
|
|
|
|
margin: 0;
|
|
|
|
padding: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
body {
|
|
|
|
margin: 0;
|
|
|
|
padding: 0;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
<body>
|
|
|
|
|
|
|
|
<test-fixture id="drawer">
|
|
|
|
<template>
|
|
|
|
<paper-drawer-panel force-narrow>
|
|
|
|
<div drawer>
|
|
|
|
<input id="innerLink1" tabindex="0" value="inside drawer 1">
|
|
|
|
<input id="innerLink2" tabindex="0" value="inside drawer 2">
|
|
|
|
</div>
|
|
|
|
<div main>
|
|
|
|
<input id="outerLink" tabindex="0" value="outside drawer">
|
|
|
|
</div>
|
|
|
|
</paper-drawer-panel>
|
|
|
|
</template>
|
|
|
|
</test-fixture>
|
|
|
|
|
2016-03-15 19:46:13 -07:00
|
|
|
<test-fixture id="nestedDrawer">
|
|
|
|
<template>
|
|
|
|
<paper-drawer-panel force-narrow>
|
|
|
|
<div drawer>
|
|
|
|
<input id="innerLink1" tabindex="0" value="inside drawer 1">
|
|
|
|
</div>
|
|
|
|
<paper-drawer-panel id="drawer2" main force-narrow>
|
|
|
|
<div drawer>
|
|
|
|
<input id="innerLink2" tabindex="0" value="inside drawer 2">
|
|
|
|
</div>
|
|
|
|
<div main>
|
|
|
|
<input id="outerLink" tabindex="0" value="outside drawer">
|
|
|
|
</div>
|
|
|
|
</paper-drawer-panel>
|
|
|
|
</paper-drawer-panel>
|
|
|
|
</template>
|
|
|
|
</test-fixture>
|
|
|
|
|
|
|
|
|
2016-03-04 20:39:49 -07:00
|
|
|
<script>
|
|
|
|
function ensureDocumentHasFocus() {
|
|
|
|
window.top && window.top.focus();
|
|
|
|
}
|
|
|
|
|
|
|
|
suite('focus', function() {
|
|
|
|
var drawer, innerLink, outerLink;
|
|
|
|
|
|
|
|
setup(function() {
|
|
|
|
drawer = fixture('drawer');
|
|
|
|
innerLink = drawer.querySelector('#innerLink1');
|
|
|
|
outerLink = drawer.querySelector('#outerLink');
|
|
|
|
ensureDocumentHasFocus();
|
|
|
|
});
|
|
|
|
|
|
|
|
test('should not focus content in drawer if the drawer is closed', function(done) {
|
|
|
|
Polymer.Base.async(function() {
|
|
|
|
expect(Polymer.dom(document).activeElement).to.not.be.equal(innerLink);
|
|
|
|
done();
|
|
|
|
}, 1);
|
|
|
|
MockInteractions.focus(innerLink);
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2016-03-15 19:46:13 -07:00
|
|
|
suite('nested drawers', function() {
|
|
|
|
var drawer1, drawer2, innerLink1, innerLink2;
|
|
|
|
|
|
|
|
setup(function() {
|
|
|
|
drawer1 = fixture('nestedDrawer');
|
|
|
|
drawer2 = drawer1.querySelector('#drawer2');
|
|
|
|
innerLink1 = drawer1.querySelector('#innerLink1');
|
|
|
|
innerLink2 = drawer1.querySelector('#innerLink2');
|
|
|
|
ensureDocumentHasFocus();
|
|
|
|
});
|
|
|
|
|
|
|
|
test('should not cause stack overflow', function(done) {
|
|
|
|
var count = 0;
|
|
|
|
var spy = sinon.spy();
|
|
|
|
drawer1.openDrawer();
|
|
|
|
drawer2.openDrawer();
|
|
|
|
|
|
|
|
document.addEventListener('focus', spy, true);
|
|
|
|
|
|
|
|
MockInteractions.focus(innerLink1);
|
|
|
|
MockInteractions.focus(innerLink2);
|
|
|
|
|
|
|
|
Polymer.Base.async(function() {
|
|
|
|
if (spy.callCount > 10) {
|
|
|
|
throw new Error('stack overflow');
|
|
|
|
}
|
|
|
|
done();
|
|
|
|
}, 100);
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2016-03-04 20:39:49 -07:00
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|