NaCl cleanup: Use Bit('build_ARCH') instead of Bit('target_ARCH')
[chromium-blink-merge.git] / remoting / webapp / unittests / chrome_mocks.js
blobe10f081fbecf682a2900f855a4d7f4bd61547934
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 // This file contains various mock objects for the chrome platform to make
6 // unit testing easier.
8 (function(scope){
10 var chromeMocks = {};
12 chromeMocks.Event = function() {
13   this.listeners_ = [];
16 chromeMocks.Event.prototype.addListener = function(callback) {
17   this.listeners_.push(callback);
20 chromeMocks.Event.prototype.removeListener = function(callback) {
21   for (var i = 0; i < this.listeners_.length; i++) {
22     if (this.listeners_[i] === callback) {
23       this.listeners_.splice(i, 1);
24       break;
25     }
26   }
29 chromeMocks.Event.prototype.mock$fire = function(data) {
30   this.listeners_.forEach(function(listener){
31     listener(data);
32   });
35 chromeMocks.runtime = {};
37 chromeMocks.runtime.Port = function() {
38   this.onMessage = new chromeMocks.Event();
39   this.onDisconnect = new chromeMocks.Event();
41   this.name = '';
42   this.sender = null;
45 chromeMocks.runtime.Port.prototype.disconnect = function() {};
46 chromeMocks.runtime.Port.prototype.postMessage = function() {};
48 scope.chromeMocks = chromeMocks;
50 })(window);