blob: 600d7b3dfe166982e6e7f0889e06f1d2a45fdb81 [file] [log] [blame]
<!doctype html>
<html>
<head>
<title>Notifications: Creating a notification in a detached context should
throw a TypeError.</title>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script src="resources/test-helpers.js"></script>
</head>
<body>
<script>
if (window.testRunner) {
testRunner.setPermission('notifications', 'granted', location.origin, location.origin);
testRunner.setCanOpenWindows();
}
async_test(test => {
const remoteWindow = window.open('resources/window-detached-context.html');
let remoteNotificationObj = null;
window.addEventListener('message', test.step_func(event => {
switch (event.data) {
case 'opened':
assert_own_property(remoteWindow, 'Notification');
remoteNotificationObj = remoteWindow.Notification;
remoteWindow.close();
break;
case 'closed':
try {
new remoteNotificationObj('Title');
assert_unreached('Expected a TypeError but no error thrown.');
} catch (e) {
assert_equals(e.name, 'TypeError');
assert_equals(
e.message, "Failed to construct 'Notification': Illegal invocation.");
}
test.done();
break;
default:
assert_unreached('Unrecognized message from the opened window.');
break;
}
}));
}, 'Creating a notification in a detached context should throw.');
</script>
</body>
</html>