Only grant permissions to new extensions from sync if they have the expected version
[chromium-blink-merge.git] / chrome / browser / resources / chromeos / chromevox / testing / fake_objects.js
blob8c5419f7b28bbdafe38a9988e75fa1a20f137f39
1 // Copyright 2014 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.
5 /**
6 * Fakes a Chrome event that supports one listener.
7 * @constructor
8 * @extends {ChromeEvent}
9 */
10 function FakeChromeEvent() {
11 /**
12 * @private
13 * @type {Function}
15 this.listener_ = null;
18 FakeChromeEvent.prototype = {
19 /**
20 * Fakes the corresponding call on a Chrome event. Sets the listener and
21 * fails the test if it is already set.
22 * @param {Function} listener The new listener.
24 addListener: function(listener) {
25 this.assertNoListener();
26 this.listener_ = listener;
29 /**
30 * Gets the listener of the event, failing the test if there's none.
31 * @return {Function} The event's listener.
33 getListener: function() {
34 assertNotEquals(null, this.listener_);
35 return this.listener_;
38 /**
39 * Asserts that this object doesn't have any listener added.
41 assertNoListener: function() {
42 assertEquals(null, this.listener_);