blob: 8ebb91b00e46067d19ed8101f9abd0601678bcc8 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<title>getCost with invalid argument fails from a Service Worker</title>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script src="../serviceworker/resources/test-helpers.js"></script>
<script src="../notifications/resources/test-helpers.js"></script>
<script src="/js-test-resources/mojo-helpers.js"></script>
<script src="budget-service-mock.js"></script>
</head>
<body>
<script>
async_test(function(test) {
var script = 'resources/instrumentation-service-worker.js';
var scope = 'resources/scope/' + location.pathname;
var port;
budgetServiceMock.then(mock => {
getActiveServiceWorkerWithMessagePort(test, script, scope)
.then(function(workerInfo) {
port = workerInfo.port;
port.postMessage({ command: 'getCostInvalidType' });
port.addEventListener('message', function(event) {
if (typeof event.data != 'object' || !event.data.command)
assert_unreached('Invalid message from the service worker');
assert_equals(event.data.command, 'getCostInvalidType');
assert_false(event.data.success,
'getCost should fail with invalid arguments.');
assert_equals(event.data.errorMessage, "Failed to execute 'getCost' on 'BudgetService': The provided value 'frobinator' is not a valid enum value of type OperationType.");
test.done();
});
})
.catch(unreached_rejection(test));
});
}, 'getCost with invalid arugment should fail from Service Worker');
</script>
</body>
</html>