| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 suite('extension controlled indicator', function() { |
| 6 /** @type {TestExtensionControlBrowserProxy} */ |
| 7 var browserProxy; |
| 8 |
| 9 /** @type {ExtensionControlledIndicatorElement} */ |
| 10 var indicator; |
| 11 |
| 12 setup(function() { |
| 13 PolymerTest.clearBody(); |
| 14 browserProxy = new TestExtensionControlBrowserProxy(); |
| 15 settings.ExtensionControlBrowserProxyImpl.instance_ = browserProxy; |
| 16 indicator = document.createElement('extension-controlled-indicator'); |
| 17 indicator.extensionId = 'peiafolljookckjknpgofpbjobgbmpge'; |
| 18 indicator.extensionCanBeDisabled = true; |
| 19 indicator.extensionName = 'The Bestest Name Ever'; |
| 20 document.body.appendChild(indicator); |
| 21 Polymer.dom.flush(); |
| 22 }); |
| 23 |
| 24 test('disable button tracks extensionCanBeDisabled', function() { |
| 25 assertTrue(indicator.extensionCanBeDisabled); |
| 26 assertTrue(!!indicator.$$('paper-button')); |
| 27 |
| 28 indicator.extensionCanBeDisabled = false; |
| 29 Polymer.dom.flush(); |
| 30 assertFalse(!!indicator.$$('paper-button')); |
| 31 }); |
| 32 |
| 33 test('label text and href', function() { |
| 34 var imgSrc = indicator.$$('img').src; |
| 35 assertTrue(imgSrc.includes(indicator.extensionId)); |
| 36 |
| 37 var label = indicator.$$('span'); |
| 38 assertTrue(!!label); |
| 39 var labelLink = label.querySelector('a'); |
| 40 assertTrue(!!labelLink); |
| 41 assertEquals(labelLink.textContent, indicator.extensionName); |
| 42 |
| 43 assertEquals('chrome://extensions', new URL(labelLink.href).origin); |
| 44 assertTrue(labelLink.href.includes(indicator.extensionId)); |
| 45 |
| 46 indicator.extensionId = 'dpjamkmjmigaoobjbekmfgabipmfilij'; |
| 47 indicator.extensionName = "A Slightly Less Good Name (Can't Beat That ^)"; |
| 48 Polymer.dom.flush(); |
| 49 |
| 50 imgSrc = indicator.$$('img').src; |
| 51 assertTrue(imgSrc.includes(indicator.extensionId)); |
| 52 |
| 53 label = indicator.$$('span'); |
| 54 assertTrue(!!label); |
| 55 labelLink = label.querySelector('a'); |
| 56 assertTrue(!!labelLink); |
| 57 assertEquals(labelLink.textContent, indicator.extensionName); |
| 58 }); |
| 59 |
| 60 test('tapping disable button invokes browser proxy', function() { |
| 61 var disableButton = indicator.$$('paper-button'); |
| 62 assertTrue(!!disableButton); |
| 63 MockInteractions.tap(disableButton); |
| 64 return browserProxy.whenCalled('disableExtension').then( |
| 65 function (extensionId) { |
| 66 assertEquals(extensionId, indicator.extensionId); |
| 67 }); |
| 68 }); |
| 69 }); |
| OLD | NEW |