Skip to content

Commit

Permalink
Merge pull request #16951 from steveck-chung/Bug-976999
Browse files Browse the repository at this point in the history
Bug 976999 - [Sora][Message][MMS]Some of the text content lost when forward the MMS. r=julienw
  • Loading branch information
steveck-chung committed Mar 11, 2014
2 parents 4455a8e + 62c490a commit 01cfa2e
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 6 deletions.
16 changes: 12 additions & 4 deletions apps/sms/js/compose.js
Original file line number Diff line number Diff line change
Expand Up @@ -409,13 +409,15 @@ var Compose = (function() {
if (element.text) {
this.append(element.text);
}
}, Compose);
});
}, this);
this.ignoreEvents = false;
this.focus();
}.bind(this));
this.ignoreEvents = true;
} else {
this.append(message.body);
this.focus();
}

this.focus();
},

getText: function() {
Expand Down Expand Up @@ -708,5 +710,11 @@ var Compose = (function() {
}
});

Object.defineProperty(compose, 'ignoreEvents', {
set: function composeIgnoreEvents(value) {
dom.message.classList.toggle('ignoreEvents', value);
}
});

return compose;
}());
4 changes: 4 additions & 0 deletions apps/sms/style/sms.css
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,10 @@ form.bottom[role="search"].messages-compose-form {
font-size: 1.8rem;
}

#messages-input.ignoreEvents {
pointer-events: none;
}

#messages-input.placeholder:after,
#messages-subject-input::-moz-placeholder {
color: #888;
Expand Down
34 changes: 32 additions & 2 deletions apps/sms/test/unit/compose_test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* global MocksHelper, MockAttachment, MockL10n, loadBodyHTML,
Compose, Attachment, MockMozActivity, Settings, Utils,
AttachmentMenu, Draft, document, XMLHttpRequest, Blob, navigator,
setTimeout, ThreadUI */
setTimeout, ThreadUI, SMIL */

/*jshint strict:false */
/*jslint node: true */
Expand All @@ -22,6 +22,7 @@ requireApp('sms/test/unit/mock_settings.js');
requireApp('sms/test/unit/mock_utils.js');
requireApp('sms/test/unit/mock_moz_activity.js');
requireApp('sms/test/unit/mock_thread_ui.js');
require('/test/unit/mock_smil.js');

var mocksHelperForCompose = new MocksHelper([
'AttachmentMenu',
Expand All @@ -30,7 +31,8 @@ var mocksHelperForCompose = new MocksHelper([
'Utils',
'MozActivity',
'Attachment',
'ThreadUI'
'ThreadUI',
'SMIL'
]).init();

suite('compose_test.js', function() {
Expand Down Expand Up @@ -714,6 +716,34 @@ suite('compose_test.js', function() {
assert.equal(message.getAttribute('x-inputmode'), '-moz-sms');
});
});

suite('Compose fromMessage', function() {
setup(function() {
this.sinon.spy(Compose, 'append');
this.sinon.spy(HTMLElement.prototype, 'focus');
this.sinon.stub(SMIL, 'parse');
});
test('from sms', function() {
Compose.fromMessage({type: 'sms', body: 'test'});
sinon.assert.called(Compose.append);
sinon.assert.called(message.focus);
});

test('from mms', function() {
var testString = ['test\nstring 1\nin slide 1',
'test\nstring 2\nin slide 2'];
Compose.fromMessage({type: 'mms'});

// Should not be focused before parse complete.
sinon.assert.notCalled(message.focus);
assert.isTrue(message.classList.contains('ignoreEvents'));
SMIL.parse.yield([{text: testString[0]}, {text: testString[1]}]);

sinon.assert.calledWith(Compose.append);
sinon.assert.called(message.focus);
assert.isFalse(message.classList.contains('ignoreEvents'));
});
});
});

suite('Attachment pre-send menu', function() {
Expand Down

0 comments on commit 01cfa2e

Please sign in to comment.