mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-22 17:55:50 +00:00
Bug 1107255-Fix tested Loop callers of window.close to use WindowCloseMixin, r=NiKo`
This commit is contained in:
parent
52778dad2c
commit
0fd9267ee6
@ -223,7 +223,7 @@ loop.conversation = (function(mozL10n) {
|
||||
* At the moment, it does more than that, these parts need refactoring out.
|
||||
*/
|
||||
var IncomingConversationView = React.createClass({displayName: 'IncomingConversationView',
|
||||
mixins: [sharedMixins.AudioMixin],
|
||||
mixins: [sharedMixins.AudioMixin, sharedMixins.WindowCloseMixin],
|
||||
|
||||
propTypes: {
|
||||
client: React.PropTypes.instanceOf(loop.Client).isRequired,
|
||||
@ -315,7 +315,7 @@ loop.conversation = (function(mozL10n) {
|
||||
);
|
||||
}
|
||||
case "close": {
|
||||
window.close();
|
||||
this.closeWindow();
|
||||
return (React.DOM.div(null));
|
||||
}
|
||||
}
|
||||
@ -459,10 +459,6 @@ loop.conversation = (function(mozL10n) {
|
||||
setTimeout(this.closeWindow, 0);
|
||||
},
|
||||
|
||||
closeWindow: function() {
|
||||
window.close();
|
||||
},
|
||||
|
||||
/**
|
||||
* Accepts an incoming call.
|
||||
*/
|
||||
@ -541,7 +537,7 @@ loop.conversation = (function(mozL10n) {
|
||||
* in progress, and hence, which view to display.
|
||||
*/
|
||||
var AppControllerView = React.createClass({displayName: 'AppControllerView',
|
||||
mixins: [Backbone.Events],
|
||||
mixins: [Backbone.Events, sharedMixins.WindowCloseMixin],
|
||||
|
||||
propTypes: {
|
||||
// XXX Old types required for incoming call view.
|
||||
@ -575,10 +571,6 @@ loop.conversation = (function(mozL10n) {
|
||||
this.stopListening(this.props.conversationAppStore);
|
||||
},
|
||||
|
||||
closeWindow: function() {
|
||||
window.close();
|
||||
},
|
||||
|
||||
render: function() {
|
||||
switch(this.state.windowType) {
|
||||
case "incoming": {
|
||||
|
@ -223,7 +223,7 @@ loop.conversation = (function(mozL10n) {
|
||||
* At the moment, it does more than that, these parts need refactoring out.
|
||||
*/
|
||||
var IncomingConversationView = React.createClass({
|
||||
mixins: [sharedMixins.AudioMixin],
|
||||
mixins: [sharedMixins.AudioMixin, sharedMixins.WindowCloseMixin],
|
||||
|
||||
propTypes: {
|
||||
client: React.PropTypes.instanceOf(loop.Client).isRequired,
|
||||
@ -315,7 +315,7 @@ loop.conversation = (function(mozL10n) {
|
||||
);
|
||||
}
|
||||
case "close": {
|
||||
window.close();
|
||||
this.closeWindow();
|
||||
return (<div/>);
|
||||
}
|
||||
}
|
||||
@ -459,10 +459,6 @@ loop.conversation = (function(mozL10n) {
|
||||
setTimeout(this.closeWindow, 0);
|
||||
},
|
||||
|
||||
closeWindow: function() {
|
||||
window.close();
|
||||
},
|
||||
|
||||
/**
|
||||
* Accepts an incoming call.
|
||||
*/
|
||||
@ -541,7 +537,7 @@ loop.conversation = (function(mozL10n) {
|
||||
* in progress, and hence, which view to display.
|
||||
*/
|
||||
var AppControllerView = React.createClass({
|
||||
mixins: [Backbone.Events],
|
||||
mixins: [Backbone.Events, sharedMixins.WindowCloseMixin],
|
||||
|
||||
propTypes: {
|
||||
// XXX Old types required for incoming call view.
|
||||
@ -575,10 +571,6 @@ loop.conversation = (function(mozL10n) {
|
||||
this.stopListening(this.props.conversationAppStore);
|
||||
},
|
||||
|
||||
closeWindow: function() {
|
||||
window.close();
|
||||
},
|
||||
|
||||
render: function() {
|
||||
switch(this.state.windowType) {
|
||||
case "incoming": {
|
||||
|
@ -193,7 +193,11 @@ loop.conversationViews = (function(mozL10n) {
|
||||
* Call failed view. Displayed when a call fails.
|
||||
*/
|
||||
var CallFailedView = React.createClass({displayName: 'CallFailedView',
|
||||
mixins: [Backbone.Events, sharedMixins.AudioMixin],
|
||||
mixins: [
|
||||
Backbone.Events,
|
||||
sharedMixins.AudioMixin,
|
||||
sharedMixins.WindowCloseMixin
|
||||
],
|
||||
|
||||
propTypes: {
|
||||
dispatcher: React.PropTypes.instanceOf(loop.Dispatcher).isRequired,
|
||||
@ -227,7 +231,7 @@ loop.conversationViews = (function(mozL10n) {
|
||||
var emailLink = this.props.store.getStoreState("emailLink");
|
||||
var contactEmail = _getPreferredEmail(this.props.contact).value;
|
||||
sharedUtils.composeCallUrlEmail(emailLink, contactEmail);
|
||||
window.close();
|
||||
this.closeWindow();
|
||||
},
|
||||
|
||||
_onEmailLinkError: function() {
|
||||
|
@ -193,7 +193,11 @@ loop.conversationViews = (function(mozL10n) {
|
||||
* Call failed view. Displayed when a call fails.
|
||||
*/
|
||||
var CallFailedView = React.createClass({
|
||||
mixins: [Backbone.Events, sharedMixins.AudioMixin],
|
||||
mixins: [
|
||||
Backbone.Events,
|
||||
sharedMixins.AudioMixin,
|
||||
sharedMixins.WindowCloseMixin
|
||||
],
|
||||
|
||||
propTypes: {
|
||||
dispatcher: React.PropTypes.instanceOf(loop.Dispatcher).isRequired,
|
||||
@ -227,7 +231,7 @@ loop.conversationViews = (function(mozL10n) {
|
||||
var emailLink = this.props.store.getStoreState("emailLink");
|
||||
var contactEmail = _getPreferredEmail(this.props.contact).value;
|
||||
sharedUtils.composeCallUrlEmail(emailLink, contactEmail);
|
||||
window.close();
|
||||
this.closeWindow();
|
||||
},
|
||||
|
||||
_onEmailLinkError: function() {
|
||||
|
@ -24,7 +24,7 @@ loop.shared.mixins = (function() {
|
||||
* @param {Object}
|
||||
*/
|
||||
function setRootObject(obj) {
|
||||
console.info("loop.shared.mixins: rootObject set to " + obj);
|
||||
console.log("loop.shared.mixins: rootObject set to " + obj);
|
||||
rootObject = obj;
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,6 @@ describe("loop.contacts", function() {
|
||||
|
||||
fakeWindow = {
|
||||
close: sandbox.stub(),
|
||||
//document: { addEventListener: function(){} }
|
||||
};
|
||||
loop.shared.mixins.setRootObject(fakeWindow);
|
||||
|
||||
|
@ -8,7 +8,7 @@ describe("loop.conversationViews", function () {
|
||||
|
||||
var sharedUtils = loop.shared.utils;
|
||||
var sandbox, oldTitle, view, dispatcher, contact, fakeAudioXHR;
|
||||
var fakeMozLoop;
|
||||
var fakeMozLoop, fakeWindow;
|
||||
|
||||
var CALL_STATES = loop.store.CALL_STATES;
|
||||
|
||||
@ -58,9 +58,17 @@ describe("loop.conversationViews", function () {
|
||||
callback(null, new Blob([new ArrayBuffer(10)], {type: "audio/ogg"}));
|
||||
})
|
||||
};
|
||||
|
||||
fakeWindow = {
|
||||
navigator: { mozLoop: fakeMozLoop },
|
||||
close: sandbox.stub(),
|
||||
};
|
||||
loop.shared.mixins.setRootObject(fakeWindow);
|
||||
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
loop.shared.mixins.setRootObject(window);
|
||||
document.title = oldTitle;
|
||||
view = undefined;
|
||||
delete navigator.mozLoop;
|
||||
@ -316,12 +324,11 @@ describe("loop.conversationViews", function () {
|
||||
|
||||
it("should close the conversation window once the email link is received",
|
||||
function() {
|
||||
sandbox.stub(window, "close");
|
||||
view = mountTestComponent();
|
||||
|
||||
store.setStoreState({emailLink: "http://fake.invalid/"});
|
||||
|
||||
sinon.assert.calledOnce(window.close);
|
||||
sinon.assert.calledOnce(fakeWindow.close);
|
||||
});
|
||||
|
||||
it("should display an error message in case email link retrieval failed",
|
||||
|
@ -11,6 +11,7 @@ describe("loop.conversation", function() {
|
||||
|
||||
var sharedModels = loop.shared.models,
|
||||
sharedView = loop.shared.views,
|
||||
fakeWindow,
|
||||
sandbox;
|
||||
|
||||
// XXX refactor to Just Work with "sandbox.stubComponent" or else
|
||||
@ -68,6 +69,12 @@ describe("loop.conversation", function() {
|
||||
})
|
||||
};
|
||||
|
||||
fakeWindow = {
|
||||
navigator: { mozLoop: navigator.mozLoop },
|
||||
close: sandbox.stub(),
|
||||
};
|
||||
loop.shared.mixins.setRootObject(fakeWindow);
|
||||
|
||||
// XXX These stubs should be hoisted in a common file
|
||||
// Bug 1040968
|
||||
sandbox.stub(document.mozL10n, "get", function(x) {
|
||||
@ -77,6 +84,7 @@ describe("loop.conversation", function() {
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
loop.shared.mixins.setRootObject(window);
|
||||
delete navigator.mozLoop;
|
||||
sandbox.restore();
|
||||
});
|
||||
@ -408,7 +416,6 @@ describe("loop.conversation", function() {
|
||||
|
||||
sandbox.stub(loop.CallConnectionWebSocket.prototype, "promiseConnect").returns(promise);
|
||||
sandbox.stub(loop.CallConnectionWebSocket.prototype, "close");
|
||||
sandbox.stub(window, "close");
|
||||
});
|
||||
|
||||
describe("progress - terminated (previousState = alerting)", function() {
|
||||
@ -445,12 +452,13 @@ describe("loop.conversation", function() {
|
||||
|
||||
sandbox.clock.tick(1);
|
||||
|
||||
sinon.assert.calledOnce(window.close);
|
||||
sinon.assert.calledOnce(fakeWindow.close);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe("progress - terminated (previousState not init" +
|
||||
" nor alerting)",
|
||||
function() {
|
||||
@ -521,7 +529,6 @@ describe("loop.conversation", function() {
|
||||
beforeEach(function() {
|
||||
icView = mountTestComponent();
|
||||
|
||||
sandbox.stub(window, "close");
|
||||
icView._websocket = {
|
||||
decline: sinon.stub(),
|
||||
close: sinon.stub()
|
||||
@ -539,7 +546,7 @@ describe("loop.conversation", function() {
|
||||
|
||||
sandbox.clock.tick(1);
|
||||
|
||||
sinon.assert.calledOnce(window.close);
|
||||
sinon.assert.calledOnce(fakeWindow.close);
|
||||
});
|
||||
|
||||
it("should stop alerting", function() {
|
||||
@ -567,7 +574,6 @@ describe("loop.conversation", function() {
|
||||
decline: sinon.spy(),
|
||||
close: sinon.stub()
|
||||
};
|
||||
sandbox.stub(window, "close");
|
||||
|
||||
mozLoop = {
|
||||
LOOP_SESSION_TYPE: {
|
||||
@ -626,7 +632,7 @@ describe("loop.conversation", function() {
|
||||
|
||||
sandbox.clock.tick(1);
|
||||
|
||||
sinon.assert.calledOnce(window.close);
|
||||
sinon.assert.calledOnce(fakeWindow.close);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user