Skip to content

Commit

Permalink
Fixed bug in subscription cache in phantomjs
Browse files Browse the repository at this point in the history
  • Loading branch information
Paolo Scanferla committed Jul 16, 2014
1 parent 32f9047 commit de3ff3e
Show file tree
Hide file tree
Showing 13 changed files with 268 additions and 250 deletions.
4 changes: 2 additions & 2 deletions dist/asteroid.js
Original file line number Diff line number Diff line change
Expand Up @@ -1038,11 +1038,11 @@ Asteroid.prototype.subscribe = function (name /* , param1, param2, ... */) {
// Assert arguments type
must.beString(name);
// Hash the arguments to get a key for _subscriptionsCache
var hash = JSON.stringify(arguments);
var params = Array.prototype.slice.call(arguments, 1);
var hash = JSON.stringify(params);
// Only subscribe if there is no cached subscription
if (!this._subscriptionsCache[hash]) {
// Collect arguments into array
var params = Array.prototype.slice.call(arguments, 1);
var sub = new Subscription(name, params, hash, this);
this._subscriptionsCache[hash] = sub;
this.subscriptions[sub.id] = sub;
Expand Down
2 changes: 1 addition & 1 deletion dist/asteroid.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/node.asteroid.js
Original file line number Diff line number Diff line change
Expand Up @@ -833,11 +833,11 @@ Asteroid.prototype.subscribe = function (name /* , param1, param2, ... */) {
// Assert arguments type
must.beString(name);
// Hash the arguments to get a key for _subscriptionsCache
var hash = JSON.stringify(arguments);
var params = Array.prototype.slice.call(arguments, 1);
var hash = JSON.stringify(params);
// Only subscribe if there is no cached subscription
if (!this._subscriptionsCache[hash]) {
// Collect arguments into array
var params = Array.prototype.slice.call(arguments, 1);
var sub = new Subscription(name, params, hash, this);
this._subscriptionsCache[hash] = sub;
this.subscriptions[sub.id] = sub;
Expand Down
4 changes: 2 additions & 2 deletions src/subscription.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ Asteroid.prototype.subscribe = function (name /* , param1, param2, ... */) {
// Assert arguments type
must.beString(name);
// Hash the arguments to get a key for _subscriptionsCache
var hash = JSON.stringify(arguments);
var params = Array.prototype.slice.call(arguments, 1);
var hash = JSON.stringify(params);
// Only subscribe if there is no cached subscription
if (!this._subscriptionsCache[hash]) {
// Collect arguments into array
var params = Array.prototype.slice.call(arguments, 1);
var sub = new Subscription(name, params, hash, this);
this._subscriptionsCache[hash] = sub;
this.subscriptions[sub.id] = sub;
Expand Down
138 changes: 72 additions & 66 deletions test/coverage/Chrome 35.0.1916 (Mac OS X 10.9.4)/dist/asteroid.js.html

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions test/coverage/Chrome 35.0.1916 (Mac OS X 10.9.4)/dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@
<h1>Code coverage report for <span class="entity">dist/</span></h1>
<h2>

Statements: <span class="metric">62.4% <small>(317 / 508)</small></span> &nbsp;&nbsp;&nbsp;&nbsp;
Statements: <span class="metric">62.55% <small>(319 / 510)</small></span> &nbsp;&nbsp;&nbsp;&nbsp;


Branches: <span class="metric">46.84% <small>(74 / 158)</small></span> &nbsp;&nbsp;&nbsp;&nbsp;
Expand All @@ -208,7 +208,7 @@ <h2>
Functions: <span class="metric">60.2% <small>(59 / 98)</small></span> &nbsp;&nbsp;&nbsp;&nbsp;


Lines: <span class="metric">62.48% <small>(313 / 501)</small></span> &nbsp;&nbsp;&nbsp;&nbsp;
Lines: <span class="metric">62.62% <small>(315 / 503)</small></span> &nbsp;&nbsp;&nbsp;&nbsp;

Ignored: <span class="metric"><span class="ignore-none">none</span></span> &nbsp;&nbsp;&nbsp;&nbsp;
</h2>
Expand All @@ -233,23 +233,23 @@ <h2>
</thead>
<tbody><tr>
<td class="file medium" data-value="asteroid.js"><a href="asteroid.js.html">asteroid.js</a></td>
<td data-value="62.4" class="pic medium"><span class="cover-fill" style="width: 62px;"></span><span class="cover-empty" style="width:38px;"></span></td>
<td data-value="62.4" class="pct medium">62.4%</td>
<td data-value="508" class="abs medium">(317&nbsp;/&nbsp;508)</td>
<td data-value="62.55" class="pic medium"><span class="cover-fill" style="width: 62px;"></span><span class="cover-empty" style="width:38px;"></span></td>
<td data-value="62.55" class="pct medium">62.55%</td>
<td data-value="510" class="abs medium">(319&nbsp;/&nbsp;510)</td>
<td data-value="46.84" class="pct low">46.84%</td>
<td data-value="158" class="abs low">(74&nbsp;/&nbsp;158)</td>
<td data-value="60.2" class="pct medium">60.2%</td>
<td data-value="98" class="abs medium">(59&nbsp;/&nbsp;98)</td>
<td data-value="62.48" class="pct medium">62.48%</td>
<td data-value="501" class="abs medium">(313&nbsp;/&nbsp;501)</td>
<td data-value="62.62" class="pct medium">62.62%</td>
<td data-value="503" class="abs medium">(315&nbsp;/&nbsp;503)</td>
</tr>

</tbody>
</table>
</div>
</div>
<div class="footer">
<div class="meta">Generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Thu Jul 10 2014 22:33:44 GMT+0200 (CEST)</div>
<div class="meta">Generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Wed Jul 16 2014 11:57:47 GMT+0200 (CEST)</div>
</div>

<script src="../prettify.js"></script>
Expand Down
16 changes: 8 additions & 8 deletions test/coverage/Chrome 35.0.1916 (Mac OS X 10.9.4)/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@
<h1>Code coverage report for <span class="entity">All files</span></h1>
<h2>

Statements: <span class="metric">62.4% <small>(317 / 508)</small></span> &nbsp;&nbsp;&nbsp;&nbsp;
Statements: <span class="metric">62.55% <small>(319 / 510)</small></span> &nbsp;&nbsp;&nbsp;&nbsp;


Branches: <span class="metric">46.84% <small>(74 / 158)</small></span> &nbsp;&nbsp;&nbsp;&nbsp;
Expand All @@ -208,7 +208,7 @@ <h2>
Functions: <span class="metric">60.2% <small>(59 / 98)</small></span> &nbsp;&nbsp;&nbsp;&nbsp;


Lines: <span class="metric">62.48% <small>(313 / 501)</small></span> &nbsp;&nbsp;&nbsp;&nbsp;
Lines: <span class="metric">62.62% <small>(315 / 503)</small></span> &nbsp;&nbsp;&nbsp;&nbsp;

Ignored: <span class="metric"><span class="ignore-none">none</span></span> &nbsp;&nbsp;&nbsp;&nbsp;
</h2>
Expand All @@ -233,23 +233,23 @@ <h2>
</thead>
<tbody><tr>
<td class="file medium" data-value="dist/"><a href="dist/index.html">dist/</a></td>
<td data-value="62.4" class="pic medium"><span class="cover-fill" style="width: 62px;"></span><span class="cover-empty" style="width:38px;"></span></td>
<td data-value="62.4" class="pct medium">62.4%</td>
<td data-value="508" class="abs medium">(317&nbsp;/&nbsp;508)</td>
<td data-value="62.55" class="pic medium"><span class="cover-fill" style="width: 62px;"></span><span class="cover-empty" style="width:38px;"></span></td>
<td data-value="62.55" class="pct medium">62.55%</td>
<td data-value="510" class="abs medium">(319&nbsp;/&nbsp;510)</td>
<td data-value="46.84" class="pct low">46.84%</td>
<td data-value="158" class="abs low">(74&nbsp;/&nbsp;158)</td>
<td data-value="60.2" class="pct medium">60.2%</td>
<td data-value="98" class="abs medium">(59&nbsp;/&nbsp;98)</td>
<td data-value="62.48" class="pct medium">62.48%</td>
<td data-value="501" class="abs medium">(313&nbsp;/&nbsp;501)</td>
<td data-value="62.62" class="pct medium">62.62%</td>
<td data-value="503" class="abs medium">(315&nbsp;/&nbsp;503)</td>
</tr>

</tbody>
</table>
</div>
</div>
<div class="footer">
<div class="meta">Generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Thu Jul 10 2014 22:33:44 GMT+0200 (CEST)</div>
<div class="meta">Generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Wed Jul 16 2014 11:57:47 GMT+0200 (CEST)</div>
</div>

<script src="prettify.js"></script>
Expand Down
Loading

0 comments on commit de3ff3e

Please sign in to comment.