blob: f8bc5926c47b7534c5a62db168d1c3d38b0c8119 [file] [log] [blame]
<!doctype html>
<title>Notifications: Calling openWindow() in a Service Worker should not crash.</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>
// Tests that calling openWindow() in a Service Worker in response to a
// notificationclick event does not cause the browser to crash.
async_test(function(test) {
var scope = 'resources/scope/' + location.pathname;
var script = 'instrumentation-service-worker.js';
var port;
testRunner.setPermission('notifications', 'granted', location.origin, location.origin);
getActiveServiceWorkerWithMessagePort(test, script, scope).then(function(info) {
port = info.port;
// (1) Display a persistent notification with an OPENWINDOW trigger.
return info.registration.showNotification(scope, {
}).then(function() {
// (2) Simulate a click on the notification, invokes the Service Worker event.
return simulateNotificationClick(scope, -1 /* action_index */, port);
}).then(function(data) {
// (3) Confirm that the service worker successfully handled the notificationclick
// event for the correct notification.
assert_equals(data.notification.title, scope);
}, 'Opening a window in a Service Worker should not trigger a DCHECK.');