mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1227539: allow a single argument to be passed to push message subscribers. r=Standard8
This commit is contained in:
parent
e0a4c47e8a
commit
19ebfdffc2
@ -151,7 +151,11 @@ var loop = loop || {};
|
||||
return;
|
||||
}
|
||||
gSubscriptionsMap[eventName].forEach(function(cb) {
|
||||
cb.apply(null, message.data[1]);
|
||||
var data = message.data[1];
|
||||
if (!Array.isArray(data)) {
|
||||
data = [data];
|
||||
}
|
||||
cb.apply(null, data);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -243,6 +243,16 @@ describe("loopapi-client", function() {
|
||||
sinon.assert.calledOnce(stub3);
|
||||
sinon.assert.calledWithExactly(stub3, "Foo", "Bar");
|
||||
});
|
||||
|
||||
it("should invoke subscription with non-array arguments too", function() {
|
||||
var stub = sinon.stub();
|
||||
loop.subscribe("LoopStatusChanged", stub);
|
||||
|
||||
sendMessage({ data: ["LoopStatusChanged", "Foo"] });
|
||||
|
||||
sinon.assert.calledOnce(stub);
|
||||
sinon.assert.calledWithExactly(stub, "Foo");
|
||||
});
|
||||
});
|
||||
|
||||
describe("unsubscribe", function() {
|
||||
|
Loading…
Reference in New Issue
Block a user