| <!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> |