1<!doctype html> 2<!-- 3@license 4Copyright (c) 2015 The Polymer Project Authors. All rights reserved. 5This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt 6The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt 7The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt 8Code distributed by Google as part of the polymer project is also 9subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt 10--> 11<html> 12<head> 13 <title>disabled-state</title> 14 15 <script src="../../webcomponentsjs/webcomponents-lite.js"></script> 16 <script src="../../web-component-tester/browser.js"></script> 17 <link rel="import" href="test-elements.html"> 18</head> 19<body> 20 21 <test-fixture id="TrivialDisabledState"> 22 <template> 23 <test-control></test-control> 24 </template> 25 </test-fixture> 26 27 <test-fixture id="InitiallyDisabledState"> 28 <template> 29 <test-control disabled></test-control> 30 </template> 31 </test-fixture> 32 33 <script> 34 suite('disabled-state', function() { 35 var disableTarget; 36 37 suite('a trivial disabled state', function() { 38 setup(function() { 39 disableTarget = fixture('TrivialDisabledState'); 40 }); 41 42 suite('when disabled is true', function() { 43 test('receives a disabled attribute', function() { 44 disableTarget.disabled = true; 45 expect(disableTarget.hasAttribute('disabled')).to.be.eql(true); 46 }); 47 48 test('receives an appropriate aria attribute', function() { 49 disableTarget.disabled = true; 50 expect(disableTarget.getAttribute('aria-disabled')).to.be.eql('true'); 51 }); 52 }); 53 54 suite('when disabled is false', function() { 55 test('loses the disabled attribute', function() { 56 disableTarget.disabled = true; 57 expect(disableTarget.hasAttribute('disabled')).to.be.eql(true); 58 disableTarget.disabled = false; 59 expect(disableTarget.hasAttribute('disabled')).to.be.eql(false); 60 }); 61 }); 62 }); 63 64 suite('a state with an initially disabled target', function() { 65 setup(function() { 66 disableTarget = fixture('InitiallyDisabledState'); 67 }); 68 69 test('preserves the disabled attribute on target', function() { 70 expect(disableTarget.hasAttribute('disabled')).to.be.eql(true); 71 expect(disableTarget.disabled).to.be.eql(true); 72 }); 73 74 test('adds `aria-disabled` to the target', function() { 75 expect(disableTarget.getAttribute('aria-disabled')).to.be.eql('true'); 76 }); 77 }); 78 }); 79 </script> 80 81</body> 82</html> 83