Chromium Code Reviews| 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 /** | |
| 6 * @implements {settings.ExtensionControlBrowserProxy} | |
| 7 * @constructor | |
| 8 * @extends {settings.TestBrowserProxy} | |
| 9 */ | |
| 10 function TestExtensionControlBrowserProxy() { | |
|
dpapad
2016/11/23 18:39:55
Can you reuse the already existing https://cs.chro
Dan Beam
2016/11/23 22:17:41
who wrote that?!
Done.
| |
| 11 settings.TestBrowserProxy.call(this, [ | |
| 12 'disableExtension' | |
| 13 ]); | |
| 14 } | |
| 15 | |
| 16 TestExtensionControlBrowserProxy.prototype = { | |
| 17 __proto__: settings.TestBrowserProxy.prototype, | |
| 18 | |
| 19 /** @override */ | |
| 20 disableExtension: function(extensionId) { | |
| 21 this.methodCalled('disableExtension', extensionId); | |
| 22 }, | |
| 23 }; | |
| 24 | |
| 25 suite('extension controlled indicator', function() { | |
| 26 /** @type {TestExtensionControlBrowserProxy} */ | |
| 27 var browserProxy; | |
| 28 | |
| 29 /** @type {ExtensionControlledIndicatorElement} */ | |
| 30 var indicator; | |
| 31 | |
| 32 setup(function() { | |
| 33 PolymerTest.clearBody(); | |
| 34 browserProxy = new TestExtensionControlBrowserProxy(); | |
| 35 settings.ExtensionControlBrowserProxyImpl.instance_ = browserProxy; | |
| 36 indicator = document.createElement('extension-controlled-indicator'); | |
| 37 indicator.extensionId = 'peiafolljookckjknpgofpbjobgbmpge'; | |
| 38 indicator.extensionCanBeDisabled = true; | |
| 39 indicator.extensionName = 'The Bestest Name Ever'; | |
| 40 document.body.appendChild(indicator); | |
| 41 Polymer.dom.flush(); | |
| 42 }); | |
| 43 | |
| 44 test('disable button tracks extensionCanBeDisabled', function() { | |
| 45 assertTrue(indicator.extensionCanBeDisabled); | |
| 46 assertTrue(!!indicator.$$('paper-button')); | |
| 47 | |
| 48 indicator.extensionCanBeDisabled = false; | |
| 49 Polymer.dom.flush(); | |
| 50 assertFalse(!!indicator.$$('paper-button')); | |
| 51 }); | |
| 52 | |
| 53 test('label text and href', function() { | |
| 54 var imgSrc = indicator.$$('img').src; | |
| 55 assertTrue(imgSrc.includes(indicator.extensionId)); | |
| 56 | |
| 57 var label = indicator.$$('span'); | |
| 58 assertTrue(!!label); | |
| 59 var labelLink = label.querySelector('a'); | |
| 60 assertTrue(!!labelLink); | |
| 61 assertEquals(labelLink.textContent, indicator.extensionName); | |
| 62 | |
| 63 assertEquals('chrome://extensions', new URL(labelLink.href).origin); | |
| 64 assertTrue(labelLink.href.includes(indicator.extensionId)); | |
| 65 | |
| 66 indicator.extensionId = 'dpjamkmjmigaoobjbekmfgabipmfilij'; | |
| 67 indicator.extensionName = "A Slightly Less Good Name (Can't Beat That ^)"; | |
| 68 Polymer.dom.flush(); | |
| 69 | |
| 70 imgSrc = indicator.$$('img').src; | |
| 71 assertTrue(imgSrc.includes(indicator.extensionId)); | |
| 72 | |
| 73 label = indicator.$$('span'); | |
| 74 assertTrue(!!label); | |
| 75 labelLink = label.querySelector('a'); | |
| 76 assertTrue(!!labelLink); | |
| 77 assertEquals(labelLink.textContent, indicator.extensionName); | |
| 78 }); | |
| 79 | |
| 80 test('tapping disable button invokes browser proxy', function() { | |
| 81 var disableButton = indicator.$$('paper-button'); | |
| 82 assertTrue(!!disableButton); | |
| 83 MockInteractions.tap(disableButton); | |
| 84 return browserProxy.whenCalled('disableExtension').then( | |
| 85 function (extensionId) { | |
| 86 assertEquals(extensionId, indicator.extensionId); | |
| 87 }); | |
| 88 }); | |
| 89 }); | |
| OLD | NEW |