blob: 97558e5b02f118beef4bd8b1cd0d88569cef9537 [file] [log] [blame]
<!doctype html>
<html>
<head>
<title>Notifications: ServiceWorkerRegistration.showNotification() fails on too much data.</title>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script src="../serviceworker/resources/test-helpers.js"></script>
<script src="resources/test-helpers.js"></script>
</head>
<body>
<script>
// Tests that the showNotification() function rejects the promise when the
// developer-provided data exceeds a megabyte. This is an implementation-
// defined limit to prevent abuse.
async_test(function(test) {
var scope = 'resources/scope/' + location.pathname,
script = 'instrumentation-service-worker.js';
testRunner.setPermission('notifications', 'granted', location.origin, location.origin);
var workerInfo = null;
getActiveServiceWorkerWithMessagePort(test, script, scope).then(function(info) {
workerInfo = info;
// (1) Display a Web Notification from the document.
assert_inherits(workerInfo.registration, 'showNotification', 'showNotification() must be exposed.');
return workerInfo.registration.showNotification(scope, {
body: 'Hello, world!',
icon: '/icon.png',
data: new Array(1024 * 1024 * 2).join('.'), // 2 million dots
});
}).then(unreached_fulfillment(test))
.catch(function() {
test.done();
});
}, 'ServiceWorkerRegistration.showNotification() fails on too much data.');
</script>
</body>
</html>