Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
This commit is contained in:
parent
93e3a48004
commit
b38dea0597
25901 changed files with 9982925 additions and 369 deletions
96
gaia/shared/test/unit/mocks/mock_presentation_session.js
Executable file
96
gaia/shared/test/unit/mocks/mock_presentation_session.js
Executable file
|
|
@ -0,0 +1,96 @@
|
|||
(function(exports) {
|
||||
'use strict';
|
||||
|
||||
// Mock API from http://bit.ly/1uAh0jd
|
||||
var MockPresentationSession = {
|
||||
_id: undefined,
|
||||
|
||||
get id () {
|
||||
return this._id;
|
||||
},
|
||||
|
||||
_mEventHandlers: {
|
||||
'statechange': [],
|
||||
'message': []
|
||||
},
|
||||
|
||||
_onstatechange: undefined,
|
||||
|
||||
set onstatechange (handler) {
|
||||
if (typeof handler === 'function') {
|
||||
this._onstatechange = handler;
|
||||
}
|
||||
},
|
||||
|
||||
_onmessage: undefined,
|
||||
|
||||
set onmessage (handler) {
|
||||
if (typeof handler === 'function') {
|
||||
this._onmessage = handler;
|
||||
}
|
||||
},
|
||||
|
||||
get onmessage () {
|
||||
return this._onmessage;
|
||||
},
|
||||
|
||||
send: function(data) {
|
||||
},
|
||||
|
||||
disconnect: function() {
|
||||
this._state = false;
|
||||
},
|
||||
|
||||
// two states: true and false
|
||||
_state: false,
|
||||
|
||||
get state () {
|
||||
return this._state;
|
||||
},
|
||||
|
||||
addEventListener: function(eventName, handler) {
|
||||
if (this._mEventHandlers[eventName] && typeof handler === 'function') {
|
||||
this._mEventHandlers[eventName].push(handler);
|
||||
}
|
||||
},
|
||||
|
||||
removeEventListener: function(eventName, handler) {
|
||||
if (this._mEventHandlers[eventName]) {
|
||||
var index = this._mEventHandlers[eventName].indexOf(handler);
|
||||
if (index >= 0) {
|
||||
this._mEventHandlers[eventName].splice(index, 1);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_mFireEvent: function(eventName, eventObject) {
|
||||
if (typeof this['_on' + eventName] === 'function') {
|
||||
this['_on' + eventName](eventObject);
|
||||
}
|
||||
|
||||
if (this._mEventHandlers[eventName]) {
|
||||
this._mEventHandlers[eventName].forEach(function(handler) {
|
||||
handler(eventObject);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
_mCreateSession: function() {
|
||||
this._mReset();
|
||||
this._id = 'testsession';
|
||||
return this;
|
||||
},
|
||||
|
||||
_mReset: function() {
|
||||
for (var eventHandlers in this._mEventHandlers) {
|
||||
eventHandlers = [];
|
||||
}
|
||||
this._onstatechange = undefined;
|
||||
this._onmessage = undefined;
|
||||
this._state = false;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
exports.MockPresentationSession = MockPresentationSession;
|
||||
}(window));
|
||||
Loading…
Reference in a new issue