blob: 29a50679ff245761f3f81995810c7fde249505f3 [file] [log] [blame]
<!doctype html>
<html>
<head>
<title>Budget API: Make basic getCost 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.setCost("silent-push", TEST_BUDGET_COST);
let cost = await navigator.budget.getCost("silent-push");
assert_equals(cost, TEST_BUDGET_COST);
}, 'BudgetService.GetCost should return correct results.');
promise_test(async function() {
assert_own_property(Navigator.prototype, 'budget');
try {
let cost = await navigator.budget.getCost("frobinator");
assert_unreached('getCost should have failed with an invalid argument.');
} catch (error) {
assert_equals(error.name, 'TypeError');
assert_equals(error.message, "Failed to execute 'getCost' on 'BudgetService': The provided value 'frobinator' is not a valid enum value of type OperationType.");
}
}, 'BudgetService.GetCost should return Type Error if an invalid argument is provided.');
</script>
</body>
</html>