Index: test/synchronizer.js |
=================================================================== |
--- a/test/synchronizer.js |
+++ b/test/synchronizer.js |
@@ -321,49 +321,49 @@ |
{ |
return [Cr.NS_OK, 200, "[Adblock]\n!Redirect: http://example.com/redirected\nbar"]; |
}); |
let requests; |
this.runScheduledTasks(30).then(() => |
{ |
- test.equal(FilterStorage.subscriptions[0], subscription, "Invalid redirect ignored"); |
+ test.equal([...FilterStorage.subscriptions()][0], subscription, "Invalid redirect ignored"); |
test.equal(subscription.downloadStatus, "synchronize_connection_error", "Connection error recorded"); |
test.equal(subscription.errors, 2, "Number of download errors"); |
requests = []; |
this.registerHandler("/redirected", metadata => |
{ |
requests.push(this.getTimeOffset()); |
return [Cr.NS_OK, 200, "[Adblock]\n! Expires: 8 hours\nbar"]; |
}); |
resetSubscription(subscription); |
return this.runScheduledTasks(15); |
}).then(() => |
{ |
- test.equal(FilterStorage.subscriptions[0].url, "http://example.com/redirected", "Redirect followed"); |
+ test.equal([...FilterStorage.subscriptions()][0].url, "http://example.com/redirected", "Redirect followed"); |
test.deepEqual(requests, [0 + initialDelay, 8 + initialDelay], "Resulting requests"); |
this.registerHandler("/redirected", metadata => |
{ |
return [Cr.NS_OK, 200, "[Adblock]\n!Redirect: http://example.com/subscription\nbar"]; |
}); |
subscription = Subscription.fromURL("http://example.com/subscription"); |
resetSubscription(subscription); |
- FilterStorage.removeSubscription(FilterStorage.subscriptions[0]); |
+ FilterStorage.removeSubscription([...FilterStorage.subscriptions()][0]); |
FilterStorage.addSubscription(subscription); |
return this.runScheduledTasks(2); |
}).then(() => |
{ |
- test.equal(FilterStorage.subscriptions[0], subscription, "Redirect not followed on redirect loop"); |
+ test.equal([...FilterStorage.subscriptions()][0], subscription, "Redirect not followed on redirect loop"); |
test.equal(subscription.downloadStatus, "synchronize_connection_error", "Download status after redirect loop"); |
}).catch(unexpectedError.bind(test)).then(() => test.done()); |
}; |
exports.testFallback = function(test) |
{ |
Prefs.subscriptions_fallbackerrors = 3; |
Prefs.subscriptions_fallbackurl = "http://example.com/fallback?%SUBSCRIPTION%&%CHANNELSTATUS%&%RESPONSESTATUS%"; |
@@ -402,68 +402,68 @@ |
{ |
test.deepEqual(requests, [0 + initialDelay, 24 + initialDelay, 48 + initialDelay], "Stop trying if the fallback responds with Gone"); |
test.equal(fallbackParams, "http://example.com/subscription&0&404", "Fallback arguments"); |
// Fallback redirecting to a missing file |
subscription = Subscription.fromURL("http://example.com/subscription"); |
resetSubscription(subscription); |
- FilterStorage.removeSubscription(FilterStorage.subscriptions[0]); |
+ FilterStorage.removeSubscription([...FilterStorage.subscriptions()][0]); |
FilterStorage.addSubscription(subscription); |
requests = []; |
this.registerHandler("/fallback", metadata => |
{ |
return [Cr.NS_OK, 200, "301 http://example.com/redirected"]; |
}); |
return this.runScheduledTasks(100); |
}).then(() => |
{ |
- test.equal(FilterStorage.subscriptions[0].url, "http://example.com/subscription", "Ignore invalid redirect from fallback"); |
+ test.equal([...FilterStorage.subscriptions()][0].url, "http://example.com/subscription", "Ignore invalid redirect from fallback"); |
test.deepEqual(requests, [0 + initialDelay, 24 + initialDelay, 48 + initialDelay, 72 + initialDelay, 96 + initialDelay], "Requests not affected by invalid redirect"); |
// Fallback redirecting to an existing file |
resetSubscription(subscription); |
requests = []; |
redirectedRequests = []; |
this.registerHandler("/redirected", metadata => |
{ |
redirectedRequests.push(this.getTimeOffset()); |
return [Cr.NS_OK, 200, "[Adblock]\n!Expires: 1day\nfoo\nbar"]; |
}); |
return this.runScheduledTasks(100); |
}).then(() => |
{ |
- test.equal(FilterStorage.subscriptions[0].url, "http://example.com/redirected", "Valid redirect from fallback is followed"); |
+ test.equal([...FilterStorage.subscriptions()][0].url, "http://example.com/redirected", "Valid redirect from fallback is followed"); |
test.deepEqual(requests, [0 + initialDelay, 24 + initialDelay, 48 + initialDelay], "Stop polling original URL after a valid redirect from fallback"); |
test.deepEqual(redirectedRequests, [48 + initialDelay, 72 + initialDelay, 96 + initialDelay], "Request new URL after a valid redirect from fallback"); |
// Redirect loop |
this.registerHandler("/subscription", metadata => |
{ |
return [Cr.NS_OK, 200, "[Adblock]\n! Redirect: http://example.com/subscription2"]; |
}); |
this.registerHandler("/subscription2", metadata => |
{ |
return [Cr.NS_OK, 200, "[Adblock]\n! Redirect: http://example.com/subscription"]; |
}); |
subscription = Subscription.fromURL("http://example.com/subscription"); |
resetSubscription(subscription); |
- FilterStorage.removeSubscription(FilterStorage.subscriptions[0]); |
+ FilterStorage.removeSubscription([...FilterStorage.subscriptions()][0]); |
FilterStorage.addSubscription(subscription); |
return this.runScheduledTasks(100); |
}).then(() => |
{ |
- test.equal(FilterStorage.subscriptions[0].url, "http://example.com/redirected", "Fallback can still redirect even after a redirect loop"); |
+ test.equal([...FilterStorage.subscriptions()][0].url, "http://example.com/redirected", "Fallback can still redirect even after a redirect loop"); |
}).catch(unexpectedError.bind(test)).then(() => test.done()); |
}; |
exports.testStateFields = function(test) |
{ |
let subscription = Subscription.fromURL("http://example.com/subscription"); |
FilterStorage.addSubscription(subscription); |