chromium/third_party/blink/web_tests/http/tests/push_messaging/subscribe-failure-no-manifest-in-service-worker.html

<!DOCTYPE html>
<html>
<head>
<title>subscribe fails in service worker because the manifest cannot be read</title>
<link rel="manifest" href="resources/push_manifest.json">
<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>
</head>
<body>
<script>
// This test uses the test runner. If running manually, grant permission when prompted.
async_test(function(test) {
    if (window.testRunner)
        testRunner.setPermission('push-messaging', 'granted', location.origin, location.origin);

    var script = 'resources/instrumentation-service-worker.js';
    var scope = 'resources/scope/' + location.pathname;

    getActiveServiceWorkerWithMessagePort(test, script, scope)
        .then(function(workerInfo) {
            // Call subscribe in service worker context. It will fail because
            // although the sender id has been specified in the manifest, the
            // manifest cannot be read in a service worker context, and no
            // previous subscription will exist from a document context.
            workerInfo.port.postMessage({command: 'subscribe'});

            workerInfo.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, 'subscribe');
                assert_false(event.data.success, 'subscribe is not expected to succeed.');
                assert_regexp_match(
                    event.data.errorMessage,
                    /missing applicationServerKey, and gcm_sender_id not found in manifest/);

                test.done();
            });
        })
        .catch(unreached_rejection(test));
}, 'subscribe fails in service worker because the manifest cannot be read');
</script>
</body>
</html>