blob: d736e59d350d12f59da04124e25c5c77e4594e49 [file] [log] [blame]
<!doctype html>
<html>
<head>
<title>Budget API: Make basic reserve calls.</title>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script src="/gen/layout_test_data/mojo/public/js/mojo_bindings.js"></script>
<script src="/gen/third_party/WebKit/public/platform/modules/budget_service/budget_service.mojom.js"></script>
<script src="budget-service-mock.js"></script>
</head>
<body>
<script>
promise_test(async function() {
assert_own_property(Navigator.prototype, 'budget');
budgetServiceMock.setReserveSuccess(true);
let success = await navigator.budget.reserve("silent-push");
assert_equals(success, true);
}, 'BudgetService.Reserve should return correct results.');
promise_test(async function() {
assert_own_property(Navigator.prototype, 'budget');
try {
let success = await navigator.budget.reserve("frobinator");
assert_unreached('reserve should have failed with an invalid argument.');
} catch (error) {
assert_equals(error.name, 'TypeError');
assert_equals(error.message, "Failed to execute 'reserve' on 'BudgetService': The provided value 'frobinator' is not a valid enum value of type OperationType.");
}
}, 'BudgetService.Reserve should return Type Error if an invalid argument is provided.');
</script>
</body>
</html>