You need to chain the promises:
p = f(500, 0);
p = p.then(function() {
return f(300, 1);
});
p = p.then(function() {
return f(100, 2);
});
Or more idiomatic:
f(500, 0).then(function() {
return f(300, 1);
}).then(function() {
return f(100, 2);
});