Fix some lint errors from previous commit.

This commit is contained in:
Ian Gulliver
2015-10-15 21:55:55 +02:00
parent a59f7f97f3
commit f77007e047
2 changed files with 14 additions and 8 deletions

View File

@@ -290,8 +290,10 @@ Cosmopolite.prototype.subscribe = function(subjects, opt_messages, opt_lastID) {
var subject = subjects[i];
ret.push(this.newPromise_(function(resolve, reject) {
if (subject['local'] && (subject['readable_only_by'] || subject['writable_only_by'])) {
console.log(this.loggingPrefix_(), 'local subjects can\'t have ACLs:', subject);
if (subject['local'] &&
(subject['readable_only_by'] || subject['writable_only_by'])) {
console.log(this.loggingPrefix_(),
'local subjects can\'t have ACLs:', subject);
reject();
return;
}
@@ -407,8 +409,10 @@ Cosmopolite.prototype.unsubscribe = function(subject) {
*/
Cosmopolite.prototype.sendMessage = function(subject, message) {
return this.newPromise_(function(resolve, reject) {
if (subject['local'] && (subject['readable_only_by'] || subject['writable_only_by'])) {
console.log(this.loggingPrefix_(), 'local subjects can\'t have ACLs:', subject);
if (subject['local'] &&
(subject['readable_only_by'] || subject['writable_only_by'])) {
console.log(this.loggingPrefix_(),
'local subjects can\'t have ACLs:', subject);
reject();
return;
}
@@ -529,12 +533,13 @@ Cosmopolite.prototype.pin = function(subject, message) {
var onSuccess = function() {
this.pins_[id] = args;
resolve(id);
}
};
if (subject['local']) {
onSuccess.bind(this)();
// Ugly hack, but we need this to promise to resolve before the callback fires.
// This is the equivalent of sched_yield(), and probably about as reliable.
// Ugly hack, but we need this to promise to resolve before the callback
// fires. This is the equivalent of sched_yield(), and probably about as
// reliable.
window.setTimeout(this.onPin_.bind(this, Object.create(args)), 0);
return;
}

View File

@@ -660,7 +660,8 @@ QUnit.asyncTest('Local subject -- Message round trip', function(assert) {
var cosmo = new Cosmopolite(null, randstring());
cosmo.addEventListener('message', function(e) {
assert.equal(e.detail['subject']['name'], subject['name'], 'subject matches');
assert.equal(e.detail['subject']['name'], subject['name'],
'subject matches');
assert.ok(e.detail['subject']['local'], 'subject still local');
assert.equal(e.detail['message'], message, 'message matches');
cosmo.shutdown();